Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | |
| 18 | package com.android.browser; |
| 19 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 20 | import android.app.Activity; |
| 21 | import android.app.SearchManager; |
| 22 | import android.content.ContentResolver; |
| 23 | import android.content.Context; |
| 24 | import android.content.Intent; |
| 25 | import android.net.Uri; |
Jeff Hamilton | fd77aaa | 2011-06-17 16:19:33 -0500 | [diff] [blame] | 26 | import android.nfc.NfcAdapter; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 27 | import android.os.AsyncTask; |
| 28 | import android.os.Bundle; |
| 29 | import android.provider.Browser; |
| 30 | import android.provider.MediaStore; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 31 | import android.text.TextUtils; |
| 32 | import android.util.Patterns; |
| 33 | |
Michael Kolb | 315d502 | 2011-10-13 12:47:11 -0700 | [diff] [blame] | 34 | import com.android.browser.UI.ComboViews; |
Michael Kolb | e28b347 | 2011-08-04 16:54:31 -0700 | [diff] [blame] | 35 | import com.android.browser.search.SearchEngine; |
| 36 | import com.android.common.Search; |
Michael Kolb | e28b347 | 2011-08-04 16:54:31 -0700 | [diff] [blame] | 37 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 38 | import java.util.HashMap; |
| 39 | import java.util.Iterator; |
| 40 | import java.util.Map; |
| 41 | |
| 42 | /** |
| 43 | * Handle all browser related intents |
| 44 | */ |
| 45 | public class IntentHandler { |
| 46 | |
| 47 | // "source" parameter for Google search suggested by the browser |
| 48 | final static String GOOGLE_SEARCH_SOURCE_SUGGEST = "browser-suggest"; |
| 49 | // "source" parameter for Google search from unknown source |
| 50 | final static String GOOGLE_SEARCH_SOURCE_UNKNOWN = "unknown"; |
| 51 | |
| 52 | /* package */ static final UrlData EMPTY_URL_DATA = new UrlData(null); |
| 53 | |
| 54 | private Activity mActivity; |
| 55 | private Controller mController; |
| 56 | private TabControl mTabControl; |
| 57 | private BrowserSettings mSettings; |
| 58 | |
| 59 | public IntentHandler(Activity browser, Controller controller) { |
| 60 | mActivity = browser; |
| 61 | mController = controller; |
| 62 | mTabControl = mController.getTabControl(); |
| 63 | mSettings = controller.getSettings(); |
| 64 | } |
| 65 | |
| 66 | void onNewIntent(Intent intent) { |
| 67 | Tab current = mTabControl.getCurrentTab(); |
| 68 | // When a tab is closed on exit, the current tab index is set to -1. |
| 69 | // Reset before proceed as Browser requires the current tab to be set. |
| 70 | if (current == null) { |
| 71 | // Try to reset the tab in case the index was incorrect. |
| 72 | current = mTabControl.getTab(0); |
| 73 | if (current == null) { |
| 74 | // No tabs at all so just ignore this intent. |
| 75 | return; |
| 76 | } |
| 77 | mController.setActiveTab(current); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 78 | } |
| 79 | final String action = intent.getAction(); |
| 80 | final int flags = intent.getFlags(); |
| 81 | if (Intent.ACTION_MAIN.equals(action) || |
| 82 | (flags & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) { |
| 83 | // just resume the browser |
| 84 | return; |
| 85 | } |
John Reck | 439c9a5 | 2010-12-14 10:04:39 -0800 | [diff] [blame] | 86 | if (BrowserActivity.ACTION_SHOW_BOOKMARKS.equals(action)) { |
Michael Kolb | 315d502 | 2011-10-13 12:47:11 -0700 | [diff] [blame] | 87 | mController.bookmarksOrHistoryPicker(ComboViews.Bookmarks); |
John Reck | 439c9a5 | 2010-12-14 10:04:39 -0800 | [diff] [blame] | 88 | return; |
| 89 | } |
John Reck | 07af2b8 | 2011-01-18 14:24:43 -0800 | [diff] [blame] | 90 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 91 | // In case the SearchDialog is open. |
| 92 | ((SearchManager) mActivity.getSystemService(Context.SEARCH_SERVICE)) |
| 93 | .stopSearch(); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 94 | if (Intent.ACTION_VIEW.equals(action) |
Jeff Hamilton | fd77aaa | 2011-06-17 16:19:33 -0500 | [diff] [blame] | 95 | || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action) |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 96 | || Intent.ACTION_SEARCH.equals(action) |
| 97 | || MediaStore.INTENT_ACTION_MEDIA_SEARCH.equals(action) |
Michael Kolb | 5ff5c8b | 2012-05-03 11:37:58 -0700 | [diff] [blame] | 98 | || Intent.ACTION_WEB_SEARCH.equals(action)) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 99 | // If this was a search request (e.g. search query directly typed into the address bar), |
| 100 | // pass it on to the default web search provider. |
| 101 | if (handleWebSearchIntent(mActivity, mController, intent)) { |
| 102 | return; |
| 103 | } |
| 104 | |
| 105 | UrlData urlData = getUrlDataFromIntent(intent); |
| 106 | if (urlData.isEmpty()) { |
| 107 | urlData = new UrlData(mSettings.getHomePage()); |
| 108 | } |
| 109 | |
Michael Kolb | 1461244 | 2011-06-24 13:06:29 -0700 | [diff] [blame] | 110 | if (intent.getBooleanExtra(Browser.EXTRA_CREATE_NEW_TAB, false) |
| 111 | || urlData.isPreloaded()) { |
| 112 | Tab t = mController.openTab(urlData); |
Leon Scroggins | 2ed6e31 | 2011-02-22 16:37:23 -0500 | [diff] [blame] | 113 | return; |
| 114 | } |
John Reck | db22ec4 | 2011-06-29 11:31:24 -0700 | [diff] [blame] | 115 | /* |
| 116 | * TODO: Don't allow javascript URIs |
| 117 | * 0) If this is a javascript: URI, *always* open a new tab |
Michael Kolb | 5ff5c8b | 2012-05-03 11:37:58 -0700 | [diff] [blame] | 118 | * 1) If the URL is already opened, switch to that tab |
| 119 | * 2-phone) Reuse tab with same appId |
| 120 | * 2-tablet) Open new tab |
John Reck | db22ec4 | 2011-06-29 11:31:24 -0700 | [diff] [blame] | 121 | */ |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 122 | final String appId = intent |
| 123 | .getStringExtra(Browser.EXTRA_APPLICATION_ID); |
John Reck | 26b1832 | 2011-06-21 13:08:58 -0700 | [diff] [blame] | 124 | if (!TextUtils.isEmpty(urlData.mUrl) && |
| 125 | urlData.mUrl.startsWith("javascript:")) { |
| 126 | // Always open javascript: URIs in new tabs |
| 127 | mController.openTab(urlData); |
| 128 | return; |
| 129 | } |
Michael Kolb | f1286a4 | 2012-04-17 14:10:52 -0700 | [diff] [blame] | 130 | if (Intent.ACTION_VIEW.equals(action) |
| 131 | && (appId != null) |
| 132 | && appId.startsWith(mActivity.getPackageName())) { |
| 133 | Tab appTab = mTabControl.getTabFromAppId(appId); |
| 134 | if ((appTab != null) && (appTab == mController.getCurrentTab())) { |
| 135 | mController.switchToTab(appTab); |
| 136 | mController.loadUrlDataIn(appTab, urlData); |
| 137 | return; |
| 138 | } |
| 139 | } |
Michael Kolb | 5ff5c8b | 2012-05-03 11:37:58 -0700 | [diff] [blame] | 140 | if (Intent.ACTION_VIEW.equals(action) |
| 141 | && !mActivity.getPackageName().equals(appId)) { |
Michael Kolb | 8d772b0 | 2012-01-19 13:56:00 -0800 | [diff] [blame] | 142 | if (!BrowserActivity.isTablet(mActivity) |
| 143 | && !mSettings.allowAppTabs()) { |
Michael Kolb | c831b63 | 2011-05-11 09:30:34 -0700 | [diff] [blame] | 144 | Tab appTab = mTabControl.getTabFromAppId(appId); |
Michael Kolb | af0d334 | 2011-03-11 11:30:16 -0800 | [diff] [blame] | 145 | if (appTab != null) { |
John Reck | 26b1832 | 2011-06-21 13:08:58 -0700 | [diff] [blame] | 146 | mController.reuseTab(appTab, urlData); |
Michael Kolb | af0d334 | 2011-03-11 11:30:16 -0800 | [diff] [blame] | 147 | return; |
Michael Kolb | af0d334 | 2011-03-11 11:30:16 -0800 | [diff] [blame] | 148 | } |
John Reck | db22ec4 | 2011-06-29 11:31:24 -0700 | [diff] [blame] | 149 | } |
| 150 | // No matching application tab, try to find a regular tab |
| 151 | // with a matching url. |
| 152 | Tab appTab = mTabControl.findTabWithUrl(urlData.mUrl); |
| 153 | if (appTab != null) { |
| 154 | // Transfer ownership |
| 155 | appTab.setAppId(appId); |
| 156 | if (current != appTab) { |
| 157 | mController.switchToTab(appTab); |
| 158 | } |
| 159 | // Otherwise, we are already viewing the correct tab. |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 160 | } else { |
John Reck | db22ec4 | 2011-06-29 11:31:24 -0700 | [diff] [blame] | 161 | // if FLAG_ACTIVITY_BROUGHT_TO_FRONT flag is on, the url |
| 162 | // will be opened in a new tab unless we have reached |
| 163 | // MAX_TABS. Then the url will be opened in the current |
| 164 | // tab. If a new tab is created, it will have "true" for |
| 165 | // exit on close. |
| 166 | Tab tab = mController.openTab(urlData); |
| 167 | if (tab != null) { |
| 168 | tab.setAppId(appId); |
Michael Kolb | e28b347 | 2011-08-04 16:54:31 -0700 | [diff] [blame] | 169 | if ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) { |
| 170 | tab.setCloseOnBack(true); |
| 171 | } |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 172 | } |
| 173 | } |
| 174 | } else { |
| 175 | if (!urlData.isEmpty() |
| 176 | && urlData.mUrl.startsWith("about:debug")) { |
| 177 | if ("about:debug.dom".equals(urlData.mUrl)) { |
Jonathan Dixon | 4d2fcab | 2012-02-24 00:13:06 +0000 | [diff] [blame] | 178 | current.getWebViewClassic().dumpDomTree(false); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 179 | } else if ("about:debug.dom.file".equals(urlData.mUrl)) { |
Jonathan Dixon | 4d2fcab | 2012-02-24 00:13:06 +0000 | [diff] [blame] | 180 | current.getWebViewClassic().dumpDomTree(true); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 181 | } else if ("about:debug.render".equals(urlData.mUrl)) { |
Jonathan Dixon | 4d2fcab | 2012-02-24 00:13:06 +0000 | [diff] [blame] | 182 | current.getWebViewClassic().dumpRenderTree(false); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 183 | } else if ("about:debug.render.file".equals(urlData.mUrl)) { |
Jonathan Dixon | 4d2fcab | 2012-02-24 00:13:06 +0000 | [diff] [blame] | 184 | current.getWebViewClassic().dumpRenderTree(true); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 185 | } else if ("about:debug.display".equals(urlData.mUrl)) { |
Jonathan Dixon | 4d2fcab | 2012-02-24 00:13:06 +0000 | [diff] [blame] | 186 | current.getWebViewClassic().dumpDisplayTree(); |
Cary Clark | 4f4cb6b | 2011-01-18 13:03:42 -0500 | [diff] [blame] | 187 | } else if ("about:debug.nav".equals(urlData.mUrl)) { |
| 188 | current.getWebView().debugDump(); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 189 | } else { |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 190 | mSettings.toggleDebugSettings(); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 191 | } |
| 192 | return; |
| 193 | } |
| 194 | // Get rid of the subwindow if it exists |
| 195 | mController.dismissSubWindow(current); |
| 196 | // If the current Tab is being used as an application tab, |
| 197 | // remove the association, since the new Intent means that it is |
| 198 | // no longer associated with that application. |
| 199 | current.setAppId(null); |
| 200 | mController.loadUrlDataIn(current, urlData); |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | |
Michael Kolb | 1461244 | 2011-06-24 13:06:29 -0700 | [diff] [blame] | 205 | protected static UrlData getUrlDataFromIntent(Intent intent) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 206 | String url = ""; |
| 207 | Map<String, String> headers = null; |
Mathew Inwood | 29721c2 | 2011-06-29 17:55:24 +0100 | [diff] [blame] | 208 | PreloadedTabControl preloaded = null; |
| 209 | String preloadedSearchBoxQuery = null; |
Leon Scroggins | e1cab10 | 2011-01-04 10:50:13 -0500 | [diff] [blame] | 210 | if (intent != null |
| 211 | && (intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 212 | final String action = intent.getAction(); |
Jeff Hamilton | fd77aaa | 2011-06-17 16:19:33 -0500 | [diff] [blame] | 213 | if (Intent.ACTION_VIEW.equals(action) || |
| 214 | NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 215 | url = UrlUtils.smartUrlFilter(intent.getData()); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 216 | if (url != null && url.startsWith("http")) { |
| 217 | final Bundle pairs = intent |
| 218 | .getBundleExtra(Browser.EXTRA_HEADERS); |
| 219 | if (pairs != null && !pairs.isEmpty()) { |
| 220 | Iterator<String> iter = pairs.keySet().iterator(); |
| 221 | headers = new HashMap<String, String>(); |
| 222 | while (iter.hasNext()) { |
| 223 | String key = iter.next(); |
| 224 | headers.put(key, pairs.getString(key)); |
| 225 | } |
| 226 | } |
| 227 | } |
Michael Kolb | 1461244 | 2011-06-24 13:06:29 -0700 | [diff] [blame] | 228 | if (intent.hasExtra(PreloadRequestReceiver.EXTRA_PRELOAD_ID)) { |
| 229 | String id = intent.getStringExtra(PreloadRequestReceiver.EXTRA_PRELOAD_ID); |
Mathew Inwood | 29721c2 | 2011-06-29 17:55:24 +0100 | [diff] [blame] | 230 | preloadedSearchBoxQuery = intent.getStringExtra( |
| 231 | PreloadRequestReceiver.EXTRA_SEARCHBOX_SETQUERY); |
Michael Kolb | 1461244 | 2011-06-24 13:06:29 -0700 | [diff] [blame] | 232 | preloaded = Preloader.getInstance().getPreloadedTab(id); |
| 233 | } |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 234 | } else if (Intent.ACTION_SEARCH.equals(action) |
| 235 | || MediaStore.INTENT_ACTION_MEDIA_SEARCH.equals(action) |
| 236 | || Intent.ACTION_WEB_SEARCH.equals(action)) { |
| 237 | url = intent.getStringExtra(SearchManager.QUERY); |
| 238 | if (url != null) { |
| 239 | // In general, we shouldn't modify URL from Intent. |
| 240 | // But currently, we get the user-typed URL from search box as well. |
| 241 | url = UrlUtils.fixUrl(url); |
| 242 | url = UrlUtils.smartUrlFilter(url); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 243 | String searchSource = "&source=android-" + GOOGLE_SEARCH_SOURCE_SUGGEST + "&"; |
| 244 | if (url.contains(searchSource)) { |
| 245 | String source = null; |
| 246 | final Bundle appData = intent.getBundleExtra(SearchManager.APP_DATA); |
| 247 | if (appData != null) { |
| 248 | source = appData.getString(Search.SOURCE); |
| 249 | } |
| 250 | if (TextUtils.isEmpty(source)) { |
| 251 | source = GOOGLE_SEARCH_SOURCE_UNKNOWN; |
| 252 | } |
| 253 | url = url.replace(searchSource, "&source=android-"+source+"&"); |
| 254 | } |
| 255 | } |
| 256 | } |
| 257 | } |
Mathew Inwood | 9ad1eac | 2011-09-15 11:29:50 +0100 | [diff] [blame] | 258 | return new UrlData(url, headers, intent, preloaded, preloadedSearchBoxQuery); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | /** |
| 262 | * Launches the default web search activity with the query parameters if the given intent's data |
| 263 | * are identified as plain search terms and not URLs/shortcuts. |
| 264 | * @return true if the intent was handled and web search activity was launched, false if not. |
| 265 | */ |
| 266 | static boolean handleWebSearchIntent(Activity activity, |
| 267 | Controller controller, Intent intent) { |
| 268 | if (intent == null) return false; |
| 269 | |
| 270 | String url = null; |
| 271 | final String action = intent.getAction(); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 272 | if (Intent.ACTION_VIEW.equals(action)) { |
| 273 | Uri data = intent.getData(); |
| 274 | if (data != null) url = data.toString(); |
| 275 | } else if (Intent.ACTION_SEARCH.equals(action) |
| 276 | || MediaStore.INTENT_ACTION_MEDIA_SEARCH.equals(action) |
| 277 | || Intent.ACTION_WEB_SEARCH.equals(action)) { |
| 278 | url = intent.getStringExtra(SearchManager.QUERY); |
| 279 | } |
| 280 | return handleWebSearchRequest(activity, controller, url, |
| 281 | intent.getBundleExtra(SearchManager.APP_DATA), |
| 282 | intent.getStringExtra(SearchManager.EXTRA_DATA_KEY)); |
| 283 | } |
| 284 | |
| 285 | /** |
| 286 | * Launches the default web search activity with the query parameters if the given url string |
| 287 | * was identified as plain search terms and not URL/shortcut. |
| 288 | * @return true if the request was handled and web search activity was launched, false if not. |
| 289 | */ |
| 290 | private static boolean handleWebSearchRequest(Activity activity, |
| 291 | Controller controller, String inUrl, Bundle appData, |
| 292 | String extraData) { |
John Reck | 9914127 | 2010-12-21 11:34:12 -0800 | [diff] [blame] | 293 | if (inUrl == null) return false; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 294 | |
| 295 | // In general, we shouldn't modify URL from Intent. |
| 296 | // But currently, we get the user-typed URL from search box as well. |
| 297 | String url = UrlUtils.fixUrl(inUrl).trim(); |
John Reck | 9914127 | 2010-12-21 11:34:12 -0800 | [diff] [blame] | 298 | if (TextUtils.isEmpty(url)) return false; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 299 | |
| 300 | // URLs are handled by the regular flow of control, so |
| 301 | // return early. |
| 302 | if (Patterns.WEB_URL.matcher(url).matches() |
| 303 | || UrlUtils.ACCEPTED_URI_SCHEMA.matcher(url).matches()) { |
| 304 | return false; |
| 305 | } |
| 306 | |
| 307 | final ContentResolver cr = activity.getContentResolver(); |
| 308 | final String newUrl = url; |
| 309 | if (controller == null || controller.getTabControl() == null |
| 310 | || controller.getTabControl().getCurrentWebView() == null |
| 311 | || !controller.getTabControl().getCurrentWebView() |
| 312 | .isPrivateBrowsingEnabled()) { |
| 313 | new AsyncTask<Void, Void, Void>() { |
| 314 | @Override |
| 315 | protected Void doInBackground(Void... unused) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 316 | Browser.addSearchUrl(cr, newUrl); |
| 317 | return null; |
| 318 | } |
| 319 | }.execute(); |
| 320 | } |
| 321 | |
| 322 | SearchEngine searchEngine = BrowserSettings.getInstance().getSearchEngine(); |
| 323 | if (searchEngine == null) return false; |
| 324 | searchEngine.startSearch(activity, url, appData, extraData); |
| 325 | |
| 326 | return true; |
| 327 | } |
| 328 | |
| 329 | /** |
| 330 | * A UrlData class to abstract how the content will be set to WebView. |
| 331 | * This base class uses loadUrl to show the content. |
| 332 | */ |
| 333 | static class UrlData { |
| 334 | final String mUrl; |
| 335 | final Map<String, String> mHeaders; |
Mathew Inwood | 29721c2 | 2011-06-29 17:55:24 +0100 | [diff] [blame] | 336 | final PreloadedTabControl mPreloadedTab; |
| 337 | final String mSearchBoxQueryToSubmit; |
John Reck | 38b3965 | 2012-06-05 09:22:59 -0700 | [diff] [blame^] | 338 | final boolean mDisableUrlOverride; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 339 | |
| 340 | UrlData(String url) { |
| 341 | this.mUrl = url; |
| 342 | this.mHeaders = null; |
Michael Kolb | 1461244 | 2011-06-24 13:06:29 -0700 | [diff] [blame] | 343 | this.mPreloadedTab = null; |
Mathew Inwood | 29721c2 | 2011-06-29 17:55:24 +0100 | [diff] [blame] | 344 | this.mSearchBoxQueryToSubmit = null; |
John Reck | 38b3965 | 2012-06-05 09:22:59 -0700 | [diff] [blame^] | 345 | this.mDisableUrlOverride = false; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | UrlData(String url, Map<String, String> headers, Intent intent) { |
Mathew Inwood | 9ad1eac | 2011-09-15 11:29:50 +0100 | [diff] [blame] | 349 | this(url, headers, intent, null, null); |
Michael Kolb | 1461244 | 2011-06-24 13:06:29 -0700 | [diff] [blame] | 350 | } |
| 351 | |
Mathew Inwood | 29721c2 | 2011-06-29 17:55:24 +0100 | [diff] [blame] | 352 | UrlData(String url, Map<String, String> headers, Intent intent, |
Mathew Inwood | 9ad1eac | 2011-09-15 11:29:50 +0100 | [diff] [blame] | 353 | PreloadedTabControl preloaded, String searchBoxQueryToSubmit) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 354 | this.mUrl = url; |
| 355 | this.mHeaders = headers; |
Mathew Inwood | 29721c2 | 2011-06-29 17:55:24 +0100 | [diff] [blame] | 356 | this.mPreloadedTab = preloaded; |
| 357 | this.mSearchBoxQueryToSubmit = searchBoxQueryToSubmit; |
John Reck | 38b3965 | 2012-06-05 09:22:59 -0700 | [diff] [blame^] | 358 | if (intent != null) { |
| 359 | mDisableUrlOverride = intent.getBooleanExtra( |
| 360 | BrowserActivity.EXTRA_DISABLE_URL_OVERRIDE, false); |
| 361 | } else { |
| 362 | mDisableUrlOverride = false; |
| 363 | } |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | boolean isEmpty() { |
Michael Kolb | 5ff5c8b | 2012-05-03 11:37:58 -0700 | [diff] [blame] | 367 | return (mUrl == null || mUrl.length() == 0); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 368 | } |
Michael Kolb | 1461244 | 2011-06-24 13:06:29 -0700 | [diff] [blame] | 369 | |
| 370 | boolean isPreloaded() { |
| 371 | return mPreloadedTab != null; |
| 372 | } |
| 373 | |
Mathew Inwood | 29721c2 | 2011-06-29 17:55:24 +0100 | [diff] [blame] | 374 | PreloadedTabControl getPreloadedTab() { |
Michael Kolb | 1461244 | 2011-06-24 13:06:29 -0700 | [diff] [blame] | 375 | return mPreloadedTab; |
| 376 | } |
Mathew Inwood | 29721c2 | 2011-06-29 17:55:24 +0100 | [diff] [blame] | 377 | |
| 378 | String getSearchBoxQueryToSubmit() { |
| 379 | return mSearchBoxQueryToSubmit; |
| 380 | } |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | } |