OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/prefs/proxy_prefs.h" | |
6 | |
7 #include "base/logging.h" | |
8 | |
9 // static | |
10 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
| |
11 int in_value, | |
12 ProxyPrefs::ProxyServerMode* out_value) { | |
13 DCHECK(out_value); | |
14 if (in_value == ProxyPrefs::DISABLED) { | |
15 *out_value = ProxyPrefs::DISABLED; | |
16 return true; | |
17 } else if (in_value == ProxyPrefs::SYSTEM) { | |
18 *out_value = ProxyPrefs::SYSTEM; | |
19 return true; | |
20 } else if (in_value == ProxyPrefs::AUTO_DETECT) { | |
21 *out_value = ProxyPrefs::AUTO_DETECT; | |
22 return true; | |
23 } else if (in_value == ProxyPrefs::MANUAL) { | |
24 *out_value = ProxyPrefs::MANUAL; | |
25 return true; | |
26 } else { | |
27 return false; | |
28 } | |
29 } | |
30 | |
31 // static | |
32 bool ProxyPrefs::StringToMode( | |
33 const std::string& in_value, | |
34 ProxyPrefs::ProxyServerMode* out_value) { | |
35 DCHECK(out_value); | |
36 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.
| |
37 *out_value = ProxyPrefs::DISABLED; | |
38 return true; | |
39 } else if (in_value == "system") { | |
40 *out_value = ProxyPrefs::SYSTEM; | |
41 return true; | |
42 } else if (in_value == "auto_detect") { | |
43 *out_value = ProxyPrefs::AUTO_DETECT; | |
44 return true; | |
45 } else if (in_value == "manual") { | |
46 *out_value = ProxyPrefs::MANUAL; | |
47 return true; | |
48 } else { | |
49 return false; | |
50 } | |
51 } | |
OLD | NEW |