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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java

Issue 1416093004: Remove CustomTab and have all CustomTabActivity using Tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed clang build error Created 5 years, 2 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/tab/Tab.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
index 5b88514e35a2aaec0f1b7c1cd8336e634ebb0981..80796ee5257d73e7ad47f544151c8845f13d5530 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
@@ -44,7 +44,6 @@ import org.chromium.chrome.browser.UrlConstants;
import org.chromium.chrome.browser.WebContentsFactory;
import org.chromium.chrome.browser.banners.AppBannerManager;
import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager;
-import org.chromium.chrome.browser.contextmenu.ChromeContextMenuPopulator;
import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator;
import org.chromium.chrome.browser.contextualsearch.ContextualSearchTabHelper;
import org.chromium.chrome.browser.crash.MinidumpUploadService;
@@ -515,6 +514,8 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
}
};
+ private TabDelegateFactory mDelegateFactory;
+
/**
* Creates an instance of a {@link Tab}.
* @param id The id this tab should be identified with.
@@ -1242,19 +1243,21 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
* created.
* @param tabContentManager A {@link TabContentManager} instance or {@code null} if the web
* content will be managed/displayed manually.
+ * @param delegateFactory The {@link TabDelegateFactory} to be used for delegate creation.
* @param initiallyHidden Only used if {@code webContents} is {@code null}. Determines
* whether or not the newly created {@link WebContents} will be hidden
* or not.
*/
public final void initialize(WebContents webContents, TabContentManager tabContentManager,
- boolean initiallyHidden) {
+ TabDelegateFactory delegateFactory, boolean initiallyHidden) {
try {
TraceEvent.begin("Tab.initialize");
+ mDelegateFactory = delegateFactory;
initializeNative();
if (AppBannerManager.isEnabled()) {
- mAppBannerManager = createAppBannerManager();
+ mAppBannerManager = mDelegateFactory.createAppBannerManager(this);
if (mAppBannerManager != null) addObserver(mAppBannerManager);
}
@@ -1293,10 +1296,11 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
}
/**
- * @return {@link AppBannerManager} to be used for this tab. May be null.
+ * @return The delegate factory for testing purposes only.
*/
- protected AppBannerManager createAppBannerManager() {
- return new AppBannerManager(this, mActivity);
+ @VisibleForTesting
+ public TabDelegateFactory getDelegateFactoryForTest() {
+ return mDelegateFactory;
}
/**
@@ -1510,7 +1514,7 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
new FrameLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
- mWebContentsDelegate = createWebContentsDelegate();
+ mWebContentsDelegate = mDelegateFactory.createWebContentsDelegate(this, mActivity);
mWebContentsObserver =
new TabWebContentsObserver(mContentViewCore.getWebContents(), this);
@@ -1521,7 +1525,8 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
assert mNativeTabAndroid != 0;
nativeInitWebContents(
mNativeTabAndroid, mIncognito, mContentViewCore, mWebContentsDelegate,
- new TabContextMenuPopulator(createContextMenuPopulator(), this));
+ new TabContextMenuPopulator(
+ mDelegateFactory.createContextMenuPopulator(this, mActivity), this));
// In the case where restoring a Tab or showing a prerendered one we already have a
// valid infobar container, no need to recreate one.
@@ -1549,7 +1554,8 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
mActivity.getTabModelSelector(), this);
cvc.setDownloadDelegate(mDownloadDelegate);
- setInterceptNavigationDelegate(createInterceptNavigationDelegate());
+ setInterceptNavigationDelegate(mDelegateFactory
+ .createInterceptNavigationDelegate(this, mActivity));
if (mGestureStateListener == null) {
mGestureStateListener = createGestureStateListener();
@@ -2048,14 +2054,6 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
}
/**
- * A helper method to allow subclasses to build their own delegate.
- * @return An instance of a {@link TabWebContentsDelegateAndroid}.
- */
- protected TabWebContentsDelegateAndroid createWebContentsDelegate() {
- return new TabWebContentsDelegateAndroid(this, mActivity);
- }
-
- /**
* A helper method to allow subclasses to handle the Instant support
* disabled event.
*/
@@ -2065,14 +2063,6 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
}
/**
- * A helper method to allow subclasses to build their own menu populator.
- * @return An instance of a {@link ContextMenuPopulator}.
- */
- protected ContextMenuPopulator createContextMenuPopulator() {
- return new ChromeContextMenuPopulator(new TabContextMenuItemDelegate(this, mActivity));
- }
-
- /**
* @return The {@link WindowAndroid} associated with this {@link Tab}.
*/
public WindowAndroid getWindowAndroid() {
@@ -2632,15 +2622,6 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
}
/**
- * Factory method for {@link InterceptNavigationDelegateImpl}. Meant to be overridden by
- * subclasses.
- * @return A new instance of {@link InterceptNavigationDelegateImpl}.
- */
- protected InterceptNavigationDelegateImpl createInterceptNavigationDelegate() {
- return new InterceptNavigationDelegateImpl(mActivity, this);
- }
-
- /**
* See {@link #mInterceptNavigationDelegate}.
*/
@VisibleForTesting

Powered by Google App Engine
This is Rietveld 408576698