summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/browser/Controller.java52
-rw-r--r--src/com/android/browser/IntentHandler.java2
-rw-r--r--src/com/android/browser/Tab.java4
-rw-r--r--src/com/android/browser/UrlHandler.java4
-rw-r--r--src/com/android/browser/WebViewController.java5
5 files changed, 34 insertions, 33 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 0227621..f7e47fe 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -450,7 +450,7 @@ public class Controller
break;
case R.id.open_newtab_context_menu_id:
final Tab parent = mTabControl.getCurrentTab();
- final Tab newTab = openTab(url, false);
+ final Tab newTab = openTab(parent, url, false);
if (newTab != null && newTab != parent) {
parent.addChildTab(newTab);
}
@@ -856,8 +856,8 @@ public class Controller
}
@Override
- public boolean shouldOverrideUrlLoading(WebView view, String url) {
- return mUrlHandler.shouldOverrideUrlLoading(view, url);
+ public boolean shouldOverrideUrlLoading(Tab tab, WebView view, String url) {
+ return mUrlHandler.shouldOverrideUrlLoading(tab, view, url);
}
@Override
@@ -1114,7 +1114,7 @@ public class Controller
removeComboView();
if (!TextUtils.isEmpty(url)) {
if (newTab) {
- openTab(url, false);
+ openTab(mTabControl.getCurrentTab(), url, false);
} else {
final Tab currentTab = mTabControl.getCurrentTab();
dismissSubWindow(currentTab);
@@ -1317,7 +1317,8 @@ public class Controller
@Override
public boolean onMenuItemClick(MenuItem item) {
final Tab parent = mTabControl.getCurrentTab();
- final Tab newTab = openTab(extra, false);
+ final Tab newTab = openTab(parent,
+ extra, false);
if (newTab != parent) {
parent.addChildTab(newTab);
}
@@ -2057,29 +2058,40 @@ public class Controller
public Tab openTabToHomePage() {
// check for max tabs
if (mTabControl.canCreateNewTab()) {
- return openTabAndShow(mSettings.getHomePage(), false, null);
+ return openTabAndShow(null, new UrlData(mSettings.getHomePage()),
+ false, null);
} else {
mUi.showMaxTabsWarning();
return null;
}
}
- // A wrapper function of {@link #openTabAndShow(UrlData, boolean, String)}
- // that accepts url as string.
- protected Tab openTabAndShow(String url, boolean closeOnExit, String appId) {
- return openTabAndShow(new UrlData(url), closeOnExit, appId);
+ protected Tab openTab(Tab parent, String url, boolean forceForeground) {
+ if (mSettings.openInBackground() && !forceForeground) {
+ Tab tab = mTabControl.createNewTab(false, null, null,
+ (parent != null) && parent.isPrivateBrowsingEnabled());
+ if (tab != null) {
+ addTab(tab);
+ WebView view = tab.getWebView();
+ loadUrl(view, url);
+ }
+ return tab;
+ } else {
+ return openTabAndShow(parent, new UrlData(url), false, null);
+ }
}
+
// This method does a ton of stuff. It will attempt to create a new tab
// if we haven't reached MAX_TABS. Otherwise it uses the current tab. If
// url isn't null, it will load the given url.
-
- public Tab openTabAndShow(UrlData urlData, boolean closeOnExit,
+ public Tab openTabAndShow(Tab parent, UrlData urlData, boolean closeOnExit,
String appId) {
final Tab currentTab = mTabControl.getCurrentTab();
if (mTabControl.canCreateNewTab()) {
final Tab tab = mTabControl.createNewTab(closeOnExit, appId,
- urlData.mUrl, false);
+ urlData.mUrl,
+ (parent != null) && parent.isPrivateBrowsingEnabled());
WebView webview = tab.getWebView();
// We must set the new tab as the current tab to reflect the old
// animation behavior.
@@ -2100,20 +2112,6 @@ public class Controller
}
}
- protected Tab openTab(String url, boolean forceForeground) {
- if (mSettings.openInBackground() && !forceForeground) {
- Tab tab = mTabControl.createNewTab();
- if (tab != null) {
- addTab(tab);
- WebView view = tab.getWebView();
- loadUrl(view, url);
- }
- return tab;
- } else {
- return openTabAndShow(url, false, null);
- }
- }
-
@Override
public Tab openIncognitoTab() {
if (mTabControl.canCreateNewTab()) {
diff --git a/src/com/android/browser/IntentHandler.java b/src/com/android/browser/IntentHandler.java
index 6e0236f..cbbc482 100644
--- a/src/com/android/browser/IntentHandler.java
+++ b/src/com/android/browser/IntentHandler.java
@@ -155,7 +155,7 @@ public class IntentHandler {
// 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.
- mController.openTabAndShow(urlData, true, appId);
+ mController.openTabAndShow(null, urlData, true, appId);
}
}
} else {
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index 5b536f8..0ba59f4 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -533,7 +533,8 @@ class Tab {
mActivity.sendBroadcast(logIntent);
}
if (mInForeground) {
- return mWebViewController.shouldOverrideUrlLoading(view, url);
+ return mWebViewController.shouldOverrideUrlLoading(Tab.this,
+ view, url);
} else {
return false;
}
@@ -783,6 +784,7 @@ class Tab {
transport.setWebView(mSubView);
} else {
final Tab newTab = mWebViewController.openTabAndShow(
+ Tab.this,
IntentHandler.EMPTY_URL_DATA, false, null);
if (newTab != Tab.this) {
Tab.this.addChildTab(newTab);
diff --git a/src/com/android/browser/UrlHandler.java b/src/com/android/browser/UrlHandler.java
index 52945b3..37c90a6 100644
--- a/src/com/android/browser/UrlHandler.java
+++ b/src/com/android/browser/UrlHandler.java
@@ -50,7 +50,7 @@ public class UrlHandler {
mActivity = mController.getActivity();
}
- boolean shouldOverrideUrlLoading(WebView view, String url) {
+ boolean shouldOverrideUrlLoading(Tab tab, WebView view, String url) {
if (view.isPrivateBrowsingEnabled()) {
// Don't allow urls to leave the browser app when in
// private browsing mode
@@ -156,7 +156,7 @@ public class UrlHandler {
}
if (mController.isMenuDown()) {
- mController.openTab(url, false);
+ mController.openTab(tab, url, false);
mActivity.closeOptionsMenu();
return true;
}
diff --git a/src/com/android/browser/WebViewController.java b/src/com/android/browser/WebViewController.java
index 894bbec..64e97de 100644
--- a/src/com/android/browser/WebViewController.java
+++ b/src/com/android/browser/WebViewController.java
@@ -56,7 +56,7 @@ public interface WebViewController {
void onFavicon(Tab tab, WebView view, Bitmap icon);
- boolean shouldOverrideUrlLoading(WebView view, String url);
+ boolean shouldOverrideUrlLoading(Tab tab, WebView view, String url);
boolean shouldOverrideKeyEvent(KeyEvent event);
@@ -99,7 +99,8 @@ public interface WebViewController {
void dismissSubWindow(Tab tab);
- Tab openTabAndShow(UrlData urlData, boolean closeOnExit, String appId);
+ Tab openTabAndShow(Tab parent, UrlData urlData, boolean closeOnExit,
+ String appId);
boolean switchToTab(int tabindex);