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..8d01f1e2791092eb1ab367e9d52d9e7a044cfde0 |
| --- /dev/null |
| +++ b/chrome/browser/prefs/proxy_prefs.cc |
| @@ -0,0 +1,51 @@ |
| +// 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/logging.h" |
| + |
| +// static |
| +bool ProxyPrefs::IntToMode( |
|
danno
2010/12/16 16:29:29
If you use const int constants instead of an enum,
gfeher
2010/12/16 23:54:29
That's true. But I've managed to simplify this fun
|
| + int in_value, |
| + ProxyPrefs::ProxyServerMode* out_value) { |
| + DCHECK(out_value); |
| + if (in_value == ProxyPrefs::DISABLED) { |
| + *out_value = ProxyPrefs::DISABLED; |
| + return true; |
| + } else if (in_value == ProxyPrefs::SYSTEM) { |
| + *out_value = ProxyPrefs::SYSTEM; |
| + return true; |
| + } else if (in_value == ProxyPrefs::AUTO_DETECT) { |
| + *out_value = ProxyPrefs::AUTO_DETECT; |
| + return true; |
| + } else if (in_value == ProxyPrefs::MANUAL) { |
| + *out_value = ProxyPrefs::MANUAL; |
| + return true; |
| + } else { |
| + return false; |
| + } |
| +} |
| + |
| +// static |
| +bool ProxyPrefs::StringToMode( |
| + const std::string& in_value, |
| + ProxyPrefs::ProxyServerMode* out_value) { |
| + DCHECK(out_value); |
| + if (in_value == "disable") { |
|
danno
2010/12/16 16:29:29
Do this with a small table?
gfeher
2010/12/16 23:54:29
Done.
|
| + *out_value = ProxyPrefs::DISABLED; |
| + return true; |
| + } else if (in_value == "system") { |
| + *out_value = ProxyPrefs::SYSTEM; |
| + return true; |
| + } else if (in_value == "auto_detect") { |
| + *out_value = ProxyPrefs::AUTO_DETECT; |
| + return true; |
| + } else if (in_value == "manual") { |
| + *out_value = ProxyPrefs::MANUAL; |
| + return true; |
| + } else { |
| + return false; |
| + } |
| +} |