Chromium Code Reviews| 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..0dc0a09db7e6481d1a83ce105698cedd1fc6ca8b |
| --- /dev/null |
| +++ b/chrome/browser/prefs/proxy_prefs.cc |
| @@ -0,0 +1,43 @@ |
| +// 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 |
|
eroman
2010/12/21 22:55:21
nit: don't indent within the namespace.
battre
2010/12/22 10:01:27
Done.
|
| + // with the constants of ProxyPrefs. |
| + const char* kProxyModeNames[] = { "disabled", |
| + "auto_detect", |
| + "pac_script", |
| + "fixed_servers", |
| + "system" }; |
| +} // namespace |
| + |
| +namespace ProxyPrefs { |
| + |
| +COMPILE_ASSERT(arraysize(kProxyModeNames) == NUM_MODES, |
| + kProxyModeNames_must_have_size_of_NUM_MODES); |
| + |
| +bool IntToProxyMode(int in_value, ProxyMode* out_value) { |
| + DCHECK(out_value); |
| + if (in_value < 0 || in_value >= NUM_MODES) |
| + return false; |
| + *out_value = static_cast<ProxyMode>(in_value); |
| + return true; |
| +} |
| + |
| +// static |
| +bool StringToProxyMode(const std::string& in_value, ProxyMode* out_value) { |
| + DCHECK(out_value); |
| + for (int i = 0; i < NUM_MODES; i++) { |
| + if (in_value == kProxyModeNames[i]) |
| + return IntToProxyMode(i, out_value); |
| + } |
| + return false; |
| +} |
| + |
| +} // namespace |