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

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

Issue 819743002: Add more methods to delegates for more upstreaming (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/tabmodel/document/TabDelegate.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/tabmodel/document/ActivityDelegate.java
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 61d3ac583512d4bb2d436521bd6cc21a0ef5a0ff..e227acb7fcb009dfe81296c06f75491645f841d2 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();
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/tabmodel/document/TabDelegate.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698