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..56568f9e3c19565457095435bb01ed2704bf2e3e |
--- /dev/null |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/NetworkPredictionOptions.java |
@@ -0,0 +1,79 @@ |
+// 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; |
+ |
Ted C
2014/10/21 16:57:20
only one blank line here
Yaron
2014/10/21 17:40:13
Done.
|
+ |
+import org.chromium.chrome.R; |
+ |
+import java.util.Locale; |
+ |
+/** |
+ * Bandwidth options available based on network. |
+ * |
Ted C
2014/10/21 16:57:20
remove this empty line
Yaron
2014/10/21 17:40:13
Done.
|
+ */ |
+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); |
+ } |
+} |