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

Unified Diff: chrome/browser/prefs/proxy_prefs.cc

Issue 5701003: Intorduce a separate preference for 'proxy server mode' (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix indentation nit Created 10 years 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/browser/prefs/proxy_prefs.cc
diff --git a/chrome/browser/prefs/proxy_prefs.cc b/chrome/browser/prefs/proxy_prefs.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bf36243a4952c10de650ace5d560e10ba79669af
--- /dev/null
+++ b/chrome/browser/prefs/proxy_prefs.cc
@@ -0,0 +1,45 @@
+// Copyright (c) 2010 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.
+
+#include "chrome/browser/prefs/proxy_prefs.h"
+
+#include "base/basictypes.h"
+#include "base/logging.h"
+
+namespace {
+ // These names are exposed to the proxy extension API. They must be in sync
+ // with the constants of ProxyPrefs.
+ const char* kProxyModeNames[] = { "disabled",
+ "auto_detect",
+ "manual",
+ "system" };
+} // namespace
+
+COMPILE_ASSERT(arraysize(kProxyModeNames) == ProxyPrefs::NUM_MODES,
+ kProxyModeNames_must_have_size_of_NUM_MODES);
+
+// static
+bool ProxyPrefs::IntToProxyMode(
+ int in_value,
+ ProxyPrefs::ProxyServerMode* out_value) {
Mattias Nissler (ping if slow) 2010/12/20 13:34:03 Do these fit on the opening parentheses line?
battre (please use the other) 2010/12/21 14:18:18 Done.
+ DCHECK(out_value);
+ if (in_value < 0 || in_value >= ProxyPrefs::NUM_MODES) {
+ return false;
+ }
+ *out_value = static_cast<ProxyPrefs::ProxyServerMode>(in_value);
+ return true;
+}
+
+// static
+bool ProxyPrefs::StringToProxyMode(
+ const std::string& in_value,
+ ProxyPrefs::ProxyServerMode* out_value) {
Mattias Nissler (ping if slow) 2010/12/20 13:34:03 same here?
battre (please use the other) 2010/12/21 14:18:18 Done.
+ DCHECK(out_value);
+ for (int i = 0; i < ProxyPrefs::NUM_MODES; i++) {
+ if (in_value == kProxyModeNames[i]) {
+ return IntToProxyMode(i, out_value);
+ }
+ }
+ return false;
+}

Powered by Google App Engine
This is Rietveld 408576698