diff options
6 files changed, 52 insertions, 16 deletions
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/document/ActivityDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/document/ActivityDelegate.java index 61d3ac5..e227acb 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/document/ActivityDelegate.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/document/ActivityDelegate.java @@ -5,6 +5,7 @@ package org.chromium.chrome.browser.tabmodel.document; import android.annotation.TargetApi; +import android.app.Activity; import android.app.ActivityManager; import android.content.Context; import android.content.Intent; @@ -28,17 +29,27 @@ import java.util.List; */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) public class ActivityDelegate { - private final String mRegularActivityName; - private final String mIncognitoActivityName; + private final Class<?> mRegularClass; + private final Class<?> mIncognitoClass; /** * Creates a ActivityDelegate. - * @param regularName Name of the regular DocumentActivity. - * @param incognitoName Name of the Incognito DocumentActivity. + * @param regularClass Class of the regular DocumentActivity. + * @param incognitoClass Class of the Incognito DocumentActivity. */ - public ActivityDelegate(String regularName, String incognitoName) { - mRegularActivityName = regularName; - mIncognitoActivityName = incognitoName; + public ActivityDelegate(Class<?> regularClass, Class<?> incognitoClass) { + mRegularClass = regularClass; + mIncognitoClass = incognitoClass; + } + + /** + * Returns whether an Activity is a DocumentActivity. Assumes the Incognito Activity inherits + * from the regular Activity. + * @param activity Activity to check. + * @return Whether the Activity is a DocumentActivity. + */ + public boolean isDocumentActivity(Activity activity) { + return mRegularClass.isInstance(activity); } /** @@ -49,7 +60,7 @@ public class ActivityDelegate { */ public boolean isValidActivity(boolean isIncognito, Intent intent) { if (intent == null) return false; - String desiredClassName = isIncognito ? mIncognitoActivityName : mRegularActivityName; + String desiredClassName = isIncognito ? mIncognitoClass.getName() : mRegularClass.getName(); String className = null; if (intent.getComponent() == null) { Context context = ApplicationStatus.getApplicationContext(); diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/document/TabDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/document/TabDelegate.java index b2c00bb..edf4e5d 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/document/TabDelegate.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/document/TabDelegate.java @@ -7,7 +7,9 @@ package org.chromium.chrome.browser.tabmodel.document; import android.app.Activity; import org.chromium.chrome.browser.Tab; +import org.chromium.chrome.browser.document.PendingDocumentData; import org.chromium.chrome.browser.tabmodel.document.DocumentTabModel.Entry; +import org.chromium.content_public.browser.LoadUrlParams; /** * Provides Tabs to a DocumentTabModel. @@ -23,6 +25,13 @@ public interface TabDelegate { Tab getActivityTab(boolean incognito, ActivityDelegate delgate, Activity activity); /** + * Opens a new Tab in the foreground. + * Assumed to be triggered by a window.open(). + */ + void createTabInForeground(Activity parentActivity, boolean incognito, + LoadUrlParams loadUrlParams, PendingDocumentData documentParams); + + /** * Creates a frozen Tab for the Entry. * @param entry Entry containing TabState. * @return A frozen Tab. diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/tabmodel/document/DocumentTabModelImplTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/tabmodel/document/DocumentTabModelImplTest.java index 348fc1c..68675a7 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/tabmodel/document/DocumentTabModelImplTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/tabmodel/document/DocumentTabModelImplTest.java @@ -85,8 +85,7 @@ public class DocumentTabModelImplTest extends NativeLibraryTestBase { CommandLine.init(null); loadNativeLibraryAndInitBrowserProcess(); - mActivityDelegate = - new MockActivityDelegate("DocumentActivity", "IncognitoDocumentActivity"); + mActivityDelegate = new MockActivityDelegate(); mTabDelegate = new MockTabDelegate(); mContext = new AdvancedMockContext(getInstrumentation().getTargetContext()); } diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/tabmodel/document/OffTheRecordDocumentTabModelTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/tabmodel/document/OffTheRecordDocumentTabModelTest.java index 682c0a0..884abd7 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/tabmodel/document/OffTheRecordDocumentTabModelTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/tabmodel/document/OffTheRecordDocumentTabModelTest.java @@ -47,8 +47,7 @@ public class OffTheRecordDocumentTabModelTest extends NativeLibraryTestBase { mContext = getInstrumentation().getTargetContext(); mStorageDelegate = new MockStorageDelegate(mContext.getCacheDir(), true); - mActivityDelegate = - new MockActivityDelegate("DocumentActivity", "IncognitoDocumentActivity"); + mActivityDelegate = new MockActivityDelegate(); mTabDelegate = new MockTabDelegate(); } diff --git a/chrome/test/android/javatests/src/org/chromium/chrome/test/util/browser/tabmodel/document/MockActivityDelegate.java b/chrome/test/android/javatests/src/org/chromium/chrome/test/util/browser/tabmodel/document/MockActivityDelegate.java index 523fee3..4dc5ac3 100644 --- a/chrome/test/android/javatests/src/org/chromium/chrome/test/util/browser/tabmodel/document/MockActivityDelegate.java +++ b/chrome/test/android/javatests/src/org/chromium/chrome/test/util/browser/tabmodel/document/MockActivityDelegate.java @@ -6,6 +6,9 @@ package org.chromium.chrome.test.util.browser.tabmodel.document; import static junit.framework.Assert.assertTrue; +import android.app.Activity; +import android.content.Intent; + import org.chromium.chrome.browser.tabmodel.document.ActivityDelegate; import org.chromium.chrome.browser.tabmodel.document.DocumentTabModel.Entry; @@ -21,11 +24,19 @@ public class MockActivityDelegate extends ActivityDelegate { /** * Creates a MockActivityDelegate. - * @param regularName Name of the regular DocumentActivity. - * @param incognitoName Name of the Incognito DocumentActivity. */ - public MockActivityDelegate(String regularName, String incognitoName) { - super(regularName, incognitoName); + public MockActivityDelegate() { + super(null, null); + } + + @Override + public boolean isDocumentActivity(Activity activity) { + return true; + } + + @Override + public boolean isValidActivity(boolean isIncognito, Intent intent) { + return true; } @Override diff --git a/chrome/test/android/javatests/src/org/chromium/chrome/test/util/browser/tabmodel/document/MockTabDelegate.java b/chrome/test/android/javatests/src/org/chromium/chrome/test/util/browser/tabmodel/document/MockTabDelegate.java index fadc5ee..75dc0832 100644 --- a/chrome/test/android/javatests/src/org/chromium/chrome/test/util/browser/tabmodel/document/MockTabDelegate.java +++ b/chrome/test/android/javatests/src/org/chromium/chrome/test/util/browser/tabmodel/document/MockTabDelegate.java @@ -7,9 +7,11 @@ package org.chromium.chrome.test.util.browser.tabmodel.document; import android.app.Activity; import org.chromium.chrome.browser.Tab; +import org.chromium.chrome.browser.document.PendingDocumentData; import org.chromium.chrome.browser.tabmodel.document.ActivityDelegate; import org.chromium.chrome.browser.tabmodel.document.DocumentTabModel.Entry; import org.chromium.chrome.browser.tabmodel.document.TabDelegate; +import org.chromium.content_public.browser.LoadUrlParams; /** * Mocks out calls to get Tabs for the DocumentTabModel. @@ -21,6 +23,11 @@ public class MockTabDelegate implements TabDelegate { } @Override + public void createTabInForeground(Activity parentActivity, boolean incognito, + LoadUrlParams loadUrlParams, PendingDocumentData documentParams) { + } + + @Override public Tab createFrozenTab(Entry entry) { return null; } |