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

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

Issue 2013883002: ✈ Remove unnecessary flag and DocumentModeManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/DocumentModeAssassin.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/DocumentModeAssassin.java b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/DocumentModeAssassin.java
index f3328c49529c66d67ec810cdaf48f0013d465d98..d50dba9df10c5d09c348553f1afb53bd0a584fe1 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/DocumentModeAssassin.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/DocumentModeAssassin.java
@@ -24,7 +24,6 @@ import org.chromium.chrome.browser.document.DocumentActivity;
import org.chromium.chrome.browser.document.DocumentUtils;
import org.chromium.chrome.browser.document.IncognitoDocumentActivity;
import org.chromium.chrome.browser.incognito.IncognitoNotificationManager;
-import org.chromium.chrome.browser.preferences.DocumentModeManager;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tabmodel.TabPersistentStore.TabModelMetadata;
import org.chromium.chrome.browser.tabmodel.document.ActivityDelegate;
@@ -105,6 +104,11 @@ public class DocumentModeAssassin {
/** Which TabModelSelectorImpl to copy files into during migration. */
private static final int TAB_MODEL_INDEX = 0;
+ public static final String OPT_OUT_STATE = "opt_out_state";
gone 2016/05/25 17:48:51 Add a comment here describing how these are/were u
Peter Wen 2016/05/26 16:17:55 Done.
+ public static final int OPT_IN_TO_DOCUMENT_MODE = 0;
+ public static final int OPT_OUT_PROMO_DISMISSED = 1;
+ public static final int OPTED_OUT_OF_DOCUMENT_MODE = 2;
+
/** Creates and holds the Singleton. */
private static class LazyHolder {
private static final DocumentModeAssassin INSTANCE = new DocumentModeAssassin();
@@ -364,8 +368,7 @@ public class DocumentModeAssassin {
// Record that the user has opted-out of document mode now that their data has been
// safely copied to the other directory.
Log.d(TAG, "Setting tabbed mode preference.");
- DocumentModeManager.getInstance(getContext()).setOptedOutState(
- DocumentModeManager.OPTED_OUT_OF_DOCUMENT_MODE);
+ setOptedOutState(OPTED_OUT_OF_DOCUMENT_MODE);
TabSwitcherCallout.setIsTabSwitcherCalloutNecessary(getContext(), true);
// Remove all the {@link DocumentActivity} tasks from Android's Recents list. Users
@@ -545,4 +548,15 @@ public class DocumentModeAssassin {
protected File getTabbedDataDirectory() {
return TabPersistentStore.getOrCreateSelectorStateDirectory(TAB_MODEL_INDEX);
}
-}
+
+ /** @return Whether the user set a preference to not use the document mode. */
+ public static boolean isOptedOutOfDocumentMode() {
+ return ContextUtils.getAppSharedPreferences().getInt(
+ OPT_OUT_STATE, OPTED_OUT_OF_DOCUMENT_MODE) == OPTED_OUT_OF_DOCUMENT_MODE;
gone 2016/05/25 18:26:05 I'm really wary of this logic change. Can you do
Peter Wen 2016/05/26 16:17:55 I've been trying to test the migration path this m
+ }
+
+ /** @param state One of OPTED_OUT_OF_DOCUMENT_MODE or OPT_OUT_PROMO_DISMISSED. */
+ public static void setOptedOutState(int state) {
gone 2016/05/25 18:26:05 private?
Peter Wen 2016/05/26 16:17:55 Done.
+ ContextUtils.getAppSharedPreferences().edit().putInt(OPT_OUT_STATE, state).apply();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698