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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsConfig.java

Issue 2434263002: 📰 Refresh the visiblity of AllDismissed when items change (Closed)
Patch Set: Created 4 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/ntp/snippets/SnippetsConfig.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsConfig.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsConfig.java
index d5c43b27ebeca7588944d3edabfaf7e76aef17fd..ae1e361760ec255804c3f2853aa9fcfdda050772 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsConfig.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsConfig.java
@@ -4,25 +4,44 @@
package org.chromium.chrome.browser.ntp.snippets;
+import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.offlinepages.OfflinePageBridge;
+import java.util.Set;
+
/**
* Provides configuration details for NTP snippets.
*/
public final class SnippetsConfig {
+ /** Map that stores substitution feature flags for tests. */
+ private static Set<String> sTestEnabledFeatures;
private SnippetsConfig() {}
+ /**
+ * Sets the feature flags to use in JUnit tests, since native calls are not available there.
+ * Note: Always set it back to {@code null} at the end of the test!
+ */
+ @VisibleForTesting
+ public static void setTestEnabledFeatures(Set<String> featureList) {
+ sTestEnabledFeatures = featureList;
+ }
+
public static boolean isEnabled() {
- return ChromeFeatureList.isEnabled(ChromeFeatureList.NTP_SNIPPETS);
+ return isFeatureEnabled(ChromeFeatureList.NTP_SNIPPETS);
}
public static boolean isSaveToOfflineEnabled() {
- return ChromeFeatureList.isEnabled(ChromeFeatureList.NTP_SNIPPETS_SAVE_TO_OFFLINE)
+ return isFeatureEnabled(ChromeFeatureList.NTP_SNIPPETS_SAVE_TO_OFFLINE)
&& OfflinePageBridge.isBackgroundLoadingEnabled();
}
public static boolean isSectionDismissalEnabled() {
- return ChromeFeatureList.isEnabled(ChromeFeatureList.NTP_SUGGESTIONS_SECTION_DISMISSAL);
+ return isFeatureEnabled(ChromeFeatureList.NTP_SUGGESTIONS_SECTION_DISMISSAL);
+ }
+
+ private static boolean isFeatureEnabled(String feature) {
+ if (sTestEnabledFeatures == null) return ChromeFeatureList.isEnabled(feature);
+ return sTestEnabledFeatures.contains(feature);
}
}

Powered by Google App Engine
This is Rietveld 408576698