diff options
| author | John Reck <jreck@google.com> | 2011-06-29 11:31:24 -0700 |
|---|---|---|
| committer | John Reck <jreck@google.com> | 2011-06-29 13:28:03 -0700 |
| commit | db22ec4ee014900988062d910bc810172a07df56 (patch) | |
| tree | 317dd31937a995619e36882d3b2571adf55a7916 /src/com/android/browser/IntentHandler.java | |
| parent | 749b93662b6c3152899d91dbd80139224dc46961 (diff) | |
| download | packages_apps_Browser-db22ec4ee014900988062d910bc810172a07df56.tar.gz packages_apps_Browser-db22ec4ee014900988062d910bc810172a07df56.tar.bz2 packages_apps_Browser-db22ec4ee014900988062d910bc810172a07df56.zip | |
Fix IntentHandler behavior
Bug: 4473779
Plus, TESTS! Huzzah!
Change-Id: I043e100d99d4653b7fb7885217d7fb305930a137
Diffstat (limited to 'src/com/android/browser/IntentHandler.java')
| -rw-r--r-- | src/com/android/browser/IntentHandler.java | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/src/com/android/browser/IntentHandler.java b/src/com/android/browser/IntentHandler.java index 54711d942..088a788d2 100644 --- a/src/com/android/browser/IntentHandler.java +++ b/src/com/android/browser/IntentHandler.java @@ -139,6 +139,15 @@ public class IntentHandler { mController.openTab(urlData); return; } + /* + * TODO: Don't allow javascript URIs + * 0) If this is a javascript: URI, *always* open a new tab + * 1) If this is a voice search, re-use tab for appId + * If there is no appId, use current tab + * 2) If the URL is already opened, switch to that tab + * 3-phone) Reuse tab with same appId + * 3-tablet) Open new tab + */ final String appId = intent .getStringExtra(Browser.EXTRA_APPLICATION_ID); if (!TextUtils.isEmpty(urlData.mUrl) && @@ -151,38 +160,33 @@ public class IntentHandler { // If a voice search has no appId, it means that it came // from the browser. In that case, reuse the current tab. || (activateVoiceSearch && appId != null)) - && !mActivity.getPackageName().equals(appId) - && (flags & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) { - if (activateVoiceSearch) { + && !mActivity.getPackageName().equals(appId)) { + if (activateVoiceSearch || !BrowserActivity.isTablet(mActivity)) { Tab appTab = mTabControl.getTabFromAppId(appId); if (appTab != null) { mController.reuseTab(appTab, urlData); return; - } else { - Tab tab = mController.openTab(urlData); - if (tab != null) { - tab.setAppId(appId); - } } + } + // No matching application tab, try to find a regular tab + // with a matching url. + Tab appTab = mTabControl.findTabWithUrl(urlData.mUrl); + if (appTab != null) { + // Transfer ownership + appTab.setAppId(appId); + if (current != appTab) { + mController.switchToTab(appTab); + } + // Otherwise, we are already viewing the correct tab. } else { - // No matching application tab, try to find a regular tab - // with a matching url. - Tab appTab = mTabControl.findUnusedTabWithUrl(urlData.mUrl); - if (appTab != null) { - if (current != appTab) { - mController.switchToTab(appTab); - } - // Otherwise, we are already viewing the correct tab. - } else { - // if FLAG_ACTIVITY_BROUGHT_TO_FRONT flag is on, the url - // will be opened in a new tab unless we have reached - // MAX_TABS. Then the url will be opened in the current - // tab. If a new tab is created, it will have "true" for - // exit on close. - Tab tab = mController.openTab(urlData); - if (tab != null) { - tab.setAppId(appId); - } + // if FLAG_ACTIVITY_BROUGHT_TO_FRONT flag is on, the url + // will be opened in a new tab unless we have reached + // MAX_TABS. Then the url will be opened in the current + // tab. If a new tab is created, it will have "true" for + // exit on close. + Tab tab = mController.openTab(urlData); + if (tab != null) { + tab.setAppId(appId); } } } else { |
