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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/NetworkPredictionOptions.java

Issue 666063002: [Android] Upstream ChromeNativePreferences as PrefServiceBridge (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.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/preferences/NetworkPredictionOptions.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/NetworkPredictionOptions.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/NetworkPredictionOptions.java
new file mode 100644
index 0000000000000000000000000000000000000000..fc8b585ace11cc68813f9bc7729e81fc6181373a
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/NetworkPredictionOptions.java
@@ -0,0 +1,77 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.preferences;
+
+import org.chromium.chrome.R;
+
+import java.util.Locale;
+
+/**
+ * Bandwidth options available based on network.
+ */
+public enum NetworkPredictionOptions {
+ NETWORK_PREDICTION_ALWAYS,
+ NETWORK_PREDICTION_WIFI_ONLY,
+ NETWORK_PREDICTION_NEVER;
+
+ public static final NetworkPredictionOptions DEFAULT = NETWORK_PREDICTION_WIFI_ONLY;
+
+ /**
+ * @return The number of choices offered for the user.
+ */
+ public static int choiceCount() {
+ return values().length;
+ }
+
+ /**
+ * Fetch the display title for the preference.
+ * @return resource for the title.
+ */
+ public int getDisplayTitle() {
+ switch(this) {
+ case NETWORK_PREDICTION_ALWAYS:
+ return R.string.always_prefetch_bandwidth_entry;
+ case NETWORK_PREDICTION_WIFI_ONLY :
+ return R.string.wifi_prefetch_bandwidth_entry;
+ case NETWORK_PREDICTION_NEVER:
+ return R.string.never_prefetch_bandwidth_entry;
+ default:
+ assert false;
+ return 0;
+ }
+ }
+
+ /**
+ * Convert an integer to enum NetworkPredictionOptions.
+ * @return NetworkPredictionOptions instance.
+ */
+ public static NetworkPredictionOptions intToEnum(int index) {
+ return NetworkPredictionOptions.values()[index];
+ }
+
+ /**
+ * Convert an enum NetworkPredictionOptions to integer.
+ * @return Integer corresponding to NetworkPredictionOptions instance.
+ */
+ public int enumToInt() {
+ return ordinal();
+ }
+
+ /**
+ * Convert an string to enum NetworkPredictionOptions.
+ * @return NetworkPredictionOptions instance.
+ */
+ public static NetworkPredictionOptions stringToEnum(String name) {
+ return valueOf(name.toUpperCase(Locale.US));
+ }
+
+ /**
+ * Convert an enum NetworkPredictionOptions to String.
+ * @return String corresponding to NetworkPredictionOptions instance.
+ */
+ public String enumToString() {
+ return name().toLowerCase(Locale.US);
+ }
+}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698