Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3990)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/tabmodel/document/DocumentTabModelSelector.java

Issue 1176943002: Start unifying document-mode and tabbed-mode tab creation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/tabmodel/document/DocumentTabModelSelector.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/document/DocumentTabModelSelector.java b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/document/DocumentTabModelSelector.java
index a2ab80e9f67b0c0fb51cc51870848d38452125e4..74f26e49e7416de7d1f1ba84f81679ffaadd3751 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/document/DocumentTabModelSelector.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/document/DocumentTabModelSelector.java
@@ -23,6 +23,7 @@ import org.chromium.chrome.browser.UrlConstants;
import org.chromium.chrome.browser.document.DocumentUtils;
import org.chromium.chrome.browser.document.PendingDocumentData;
import org.chromium.chrome.browser.tabmodel.OffTheRecordTabModel.OffTheRecordTabModelDelegate;
+import org.chromium.chrome.browser.tabmodel.TabCreatorManager;
import org.chromium.chrome.browser.tabmodel.TabModel;
import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType;
import org.chromium.chrome.browser.tabmodel.TabModelSelectorBase;
@@ -35,7 +36,7 @@ import org.chromium.content_public.browser.LoadUrlParams;
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public class DocumentTabModelSelector extends TabModelSelectorBase
- implements ActivityStateListener {
+ implements ActivityStateListener, TabCreatorManager {
public static final String PREF_PACKAGE = "com.google.android.apps.chrome.document";
public static final String PREF_IS_INCOGNITO_SELECTED = "is_incognito_selected";
@@ -52,7 +53,8 @@ public class DocumentTabModelSelector extends TabModelSelectorBase
/**
* Creates new Tabs.
*/
- private final TabDelegate mTabDelegate;
+ private final TabDelegate mRegularTabDelegate;
+ private final TabDelegate mIncognitoTabDelegate;
/**
* TabModel that keeps track of regular tabs. This is always not null.
@@ -78,17 +80,19 @@ public class DocumentTabModelSelector extends TabModelSelectorBase
sPrioritizedTabId = prioritizedTabId;
}
- public DocumentTabModelSelector(ActivityDelegate activityDelegate, TabDelegate tabDelegate) {
+ public DocumentTabModelSelector(ActivityDelegate activityDelegate,
+ TabDelegate regularTabDelegate, TabDelegate incognitoTabDelegate) {
mActivityDelegate = activityDelegate;
- mTabDelegate = tabDelegate;
+ mRegularTabDelegate = regularTabDelegate;
+ mIncognitoTabDelegate = incognitoTabDelegate;
mRegularTabModel = new DocumentTabModelImpl(
- activityDelegate, tabDelegate, false, sPrioritizedTabId);
+ activityDelegate, this, false, sPrioritizedTabId);
mIncognitoTabModel = new OffTheRecordDocumentTabModel(new OffTheRecordTabModelDelegate() {
@Override
public TabModel createTabModel() {
DocumentTabModel incognitoModel = new DocumentTabModelImpl(
- mActivityDelegate, mTabDelegate, true, sPrioritizedTabId);
+ mActivityDelegate, DocumentTabModelSelector.this, true, sPrioritizedTabId);
if (mRegularTabModel.isNativeInitialized()) {
incognitoModel.initializeNative();
}
@@ -113,6 +117,11 @@ public class DocumentTabModelSelector extends TabModelSelectorBase
ApplicationStatus.registerStateListenerForAllActivities(this);
}
+ @Override
+ public TabDelegate getTabCreator(boolean incognito) {
+ return incognito ? mIncognitoTabDelegate : mRegularTabDelegate;
+ }
+
private void initializeTabIdCounter() {
int biggestId = getLargestTaskIdFromRecents();
biggestId = getMaxTabId(mRegularTabModel, biggestId);
@@ -168,7 +177,10 @@ public class DocumentTabModelSelector extends TabModelSelectorBase
Activity parentActivity =
parent == null ? null : parent.getWindowAndroid().getActivity().get();
- mTabDelegate.createTabInForeground(parentActivity, incognito, loadUrlParams, params);
+
+ TabDelegate delegate = getTabCreator(incognito);
+ Tab parentTab = delegate.getActivityTab(mActivityDelegate, parentActivity);
+ delegate.createNewTab(loadUrlParams, type, parentTab);
return null;
}

Powered by Google App Engine
This is Rietveld 408576698