Prefs: Implement and use Prefs::GetBoolean/SetBoolean.

Adds a pair of functions GetBoolean/SetBoolean to the list Prefs
class to read and write persisted boolean values. The stored
values are not compatible with the SetInt64 and will return
false when attempting to get or set a value of the other type.

These functions are now used to store the update over cellular
user setting.

BUG=chromium:213401
TEST=sudo ./update_engine_unittests

Change-Id: I44107e33f8e81ae900671d9ba6a4f5779c2353db
Reviewed-on: https://gerrit.chromium.org/gerrit/61352
Reviewed-by: Joy Chen <joychen@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
diff --git a/prefs.cc b/prefs.cc
index 496b59e..dda1919 100644
--- a/prefs.cc
+++ b/prefs.cc
@@ -53,6 +53,26 @@
   return SetString(key, base::Int64ToString(value));
 }
 
+bool Prefs::GetBoolean(const std::string& key, bool* value) {
+  string str_value;
+  if (!GetString(key, &str_value))
+    return false;
+  TrimWhitespaceASCII(str_value, TRIM_ALL, &str_value);
+  if (str_value == "false") {
+    *value = false;
+    return true;
+  }
+  if (str_value == "true") {
+    *value = true;
+    return true;
+  }
+  return false;
+}
+
+bool Prefs::SetBoolean(const std::string& key, const bool value) {
+  return SetString(key, value ? "true" : "false");
+}
+
 bool Prefs::Exists(const string& key) {
   FilePath filename;
   TEST_AND_RETURN_FALSE(GetFileNameForKey(key, &filename));