diff options
| author | Patrick Scott <phanna@android.com> | 2009-07-16 09:42:58 -0400 |
|---|---|---|
| committer | Patrick Scott <phanna@android.com> | 2009-07-16 12:40:20 -0400 |
| commit | cd11589fc3930906d4b9b7dd18aa52a9f1eb0c8a (patch) | |
| tree | 3523c3a967cbd585b14099e3456d0477d8fa2ea1 /src/com/android/browser/BrowserActivity.java | |
| parent | 2d60d1edffc4fb0b1e135468637b9104d9af5024 (diff) | |
| download | packages_apps_Browser-cd11589fc3930906d4b9b7dd18aa52a9f1eb0c8a.tar.gz packages_apps_Browser-cd11589fc3930906d4b9b7dd18aa52a9f1eb0c8a.tar.bz2 packages_apps_Browser-cd11589fc3930906d4b9b7dd18aa52a9f1eb0c8a.zip | |
Try to reuse tabs with matching urls to avoid loading a new page.
If there is no matching application tab, try to find a regular tab (created in
the browser) with a matching url. This avoids opening a new tab and loading a
new page for a page that has already been loaded.
TODO: There is a ton of duplicate code around animations to/from the tab
overview. It is a massive amount of cruft and I really want to rewrite it all in
a separate change.
Diffstat (limited to 'src/com/android/browser/BrowserActivity.java')
| -rw-r--r-- | src/com/android/browser/BrowserActivity.java | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java index 585b8ff34..1bccd4139 100644 --- a/src/com/android/browser/BrowserActivity.java +++ b/src/com/android/browser/BrowserActivity.java @@ -891,7 +891,7 @@ public class BrowserActivity extends Activity (flags & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) { final String appId = intent.getStringExtra(Browser.EXTRA_APPLICATION_ID); - final TabControl.Tab appTab = mTabControl.getTabFromId(appId); + TabControl.Tab appTab = mTabControl.getTabFromId(appId); if (appTab != null) { Log.i(LOGTAG, "Reusing tab for " + appId); // Dismiss the subwindow if applicable. @@ -922,12 +922,32 @@ public class BrowserActivity extends Activity } } return; + } else { + // No matching application tab, try to find a regular tab + // with a matching url. + appTab = mTabControl.findUnusedTabWithUrl(urlData.mUrl); + if (appTab != null) { + if (current != appTab) { + // Use EMPTY_URL_DATA so we do not reload the page + showTab(appTab, EMPTY_URL_DATA); + } else { + if (mTabOverview != null && mAnimationCount == 0) { + sendAnimateFromOverview(appTab, false, + EMPTY_URL_DATA, TAB_OVERVIEW_DELAY, + null); + } + // Don't do anything here since we are on the + // correct page. + } + } 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. + openTabAndShow(urlData, null, true, 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. - openTabAndShow(urlData, null, true, appId); } else { if ("about:debug".equals(urlData.mUrl)) { mSettings.toggleDebugSettings(); |
