summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/Controller.java
diff options
context:
space:
mode:
authorMichael Kolb <kolby@google.com>2011-06-24 13:06:29 -0700
committerMichael Kolb <kolby@google.com>2011-06-30 12:00:49 -0700
commit1461244018a225006a8d4c203f9dfe294ffe94fa (patch)
tree3dd496c312755b5f0560c36fc3be4dffa639197a /src/com/android/browser/Controller.java
parent4399b13ca463824bbab1ba422f4004cff100b483 (diff)
downloadpackages_apps_browser-1461244018a225006a8d4c203f9dfe294ffe94fa.zip
packages_apps_browser-1461244018a225006a8d4c203f9dfe294ffe94fa.tar.gz
packages_apps_browser-1461244018a225006a8d4c203f9dfe294ffe94fa.tar.bz2
Preloading support in browser
Apps like the QSB can request the browser to preload a web page. - preloaded pages are not added to the browser history if they'r not seen by the user - when a request is received, a new tab is created for the preloaded page, but not added to the tab list - upon receiving the view intent for the preloaded page the tab is added to the tab list, and shown - if several pages are preloaded consecutively in the same tab, the back stack is cleared before it is displayed - preloaded pages use the main browser cookie jar, so pages that have never been viewed by the user can drop cookies Change-Id: I9ed21f2c9560fda0ed042b460b73bb33988a2e8a
Diffstat (limited to 'src/com/android/browser/Controller.java')
-rw-r--r--src/com/android/browser/Controller.java31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 447e61b..9046745 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -229,6 +229,7 @@ public class Controller
mTabControl = new TabControl(this);
mSettings.setController(this);
mCrashRecoveryHandler = CrashRecoveryHandler.initialize(this);
+ mFactory = new BrowserWebViewFactory(browser);
mUrlHandler = new UrlHandler(this);
mIntentHandler = new IntentHandler(mActivity, this);
@@ -312,7 +313,7 @@ public class Controller
// If the intent is ACTION_VIEW and data is not null, the Browser is
// invoked to view the content by another application. In this case,
// the tab will be close when exit.
- UrlData urlData = mIntentHandler.getUrlDataFromIntent(intent);
+ UrlData urlData = IntentHandler.getUrlDataFromIntent(intent);
Tab t = null;
if (urlData.isEmpty()) {
t = openTabToHomePage();
@@ -356,10 +357,6 @@ public class Controller
}
}
- void setWebViewFactory(WebViewFactory factory) {
- mFactory = factory;
- }
-
@Override
public WebViewFactory getWebViewFactory() {
return mFactory;
@@ -381,6 +378,11 @@ public class Controller
}
@Override
+ public Context getContext() {
+ return mActivity;
+ }
+
+ @Override
public Activity getActivity() {
return mActivity;
}
@@ -1637,6 +1639,7 @@ public class Controller
return id;
}
+ @Override
protected void onPostExecute(Long id) {
if (id > 0) {
createNewSnapshotTab(id, true);
@@ -2247,11 +2250,19 @@ public class Controller
// open a non inconito tab with the given url data
// and set as active tab
public Tab openTab(UrlData urlData) {
- Tab tab = createNewTab(false, true, true);
- if ((tab != null) && !urlData.isEmpty()) {
- loadUrlDataIn(tab, urlData);
+ if (urlData.isPreloaded()) {
+ Tab tab = urlData.getPreloadedTab();
+ tab.getWebView().clearHistory();
+ mTabControl.addPreloadedTab(tab);
+ setActiveTab(tab);
+ return tab;
+ } else {
+ Tab tab = createNewTab(false, true, true);
+ if ((tab != null) && !urlData.isEmpty()) {
+ loadUrlDataIn(tab, urlData);
+ }
+ return tab;
}
- return tab;
}
@Override
@@ -2417,6 +2428,8 @@ public class Controller
if (data != null) {
if (data.mVoiceIntent != null) {
t.activateVoiceSearchMode(data.mVoiceIntent);
+ } else if (data.isPreloaded()) {
+ // this isn't called for preloaded tabs
} else {
loadUrl(t, data.mUrl, data.mHeaders);
}