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/basictypes.h" | |
8 #include "base/logging.h" | |
9 | |
10 namespace { | |
11 // These names are exposed to the proxy extension API. They must be in sync | |
12 // with the constants of ProxyPrefs. | |
13 const char* kProxyModeNames[] = { "disabled", | |
14 "auto_detect", | |
15 "manual", | |
16 "system" }; | |
17 } // namespace | |
18 | |
19 COMPILE_ASSERT(arraysize(kProxyModeNames) == ProxyPrefs::NUM_MODES, | |
20 kProxyModeNames_must_have_size_of_NUM_MODES); | |
21 | |
22 // static | |
23 bool ProxyPrefs::IntToProxyMode( | |
24 int in_value, | |
25 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.
| |
26 DCHECK(out_value); | |
27 if (in_value < 0 || in_value >= ProxyPrefs::NUM_MODES) { | |
28 return false; | |
29 } | |
30 *out_value = static_cast<ProxyPrefs::ProxyServerMode>(in_value); | |
31 return true; | |
32 } | |
33 | |
34 // static | |
35 bool ProxyPrefs::StringToProxyMode( | |
36 const std::string& in_value, | |
37 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.
| |
38 DCHECK(out_value); | |
39 for (int i = 0; i < ProxyPrefs::NUM_MODES; i++) { | |
40 if (in_value == kProxyModeNames[i]) { | |
41 return IntToProxyMode(i, out_value); | |
42 } | |
43 } | |
44 return false; | |
45 } | |
OLD | NEW |