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

Side by Side Diff: net/proxy/proxy_config_service_mac.cc

Issue 6046009: Move base/mac_util.h to base/mac and use the base::mac namespace.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gfx/test_suite.h ('k') | net/proxy/proxy_resolver_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/proxy/proxy_config_service_mac.h" 5 #include "net/proxy/proxy_config_service_mac.h"
6 6
7 #include <CoreFoundation/CoreFoundation.h> 7 #include <CoreFoundation/CoreFoundation.h>
8 #include <SystemConfiguration/SystemConfiguration.h> 8 #include <SystemConfiguration/SystemConfiguration.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/mac_util.h" 11 #include "base/mac/mac_util.h"
12 #include "base/mac/scoped_cftyperef.h" 12 #include "base/mac/scoped_cftyperef.h"
13 #include "base/sys_string_conversions.h" 13 #include "base/sys_string_conversions.h"
14 #include "net/base/net_errors.h" 14 #include "net/base/net_errors.h"
15 #include "net/proxy/proxy_config.h" 15 #include "net/proxy/proxy_config.h"
16 #include "net/proxy/proxy_info.h" 16 #include "net/proxy/proxy_info.h"
17 #include "net/proxy/proxy_server.h" 17 #include "net/proxy/proxy_server.h"
18 18
19 namespace net { 19 namespace net {
20 20
21 namespace { 21 namespace {
22 22
23 const int kPollIntervalSec = 5; 23 const int kPollIntervalSec = 5;
24 24
25 // Utility function to pull out a boolean value from a dictionary and return it, 25 // Utility function to pull out a boolean value from a dictionary and return it,
26 // returning a default value if the key is not present. 26 // returning a default value if the key is not present.
27 bool GetBoolFromDictionary(CFDictionaryRef dict, 27 bool GetBoolFromDictionary(CFDictionaryRef dict,
28 CFStringRef key, 28 CFStringRef key,
29 bool default_value) { 29 bool default_value) {
30 CFNumberRef number = (CFNumberRef)mac_util::GetValueFromDictionary( 30 CFNumberRef number = (CFNumberRef)base::mac::GetValueFromDictionary(
31 dict, key, CFNumberGetTypeID()); 31 dict, key, CFNumberGetTypeID());
32 if (!number) 32 if (!number)
33 return default_value; 33 return default_value;
34 34
35 int int_value; 35 int int_value;
36 if (CFNumberGetValue(number, kCFNumberIntType, &int_value)) 36 if (CFNumberGetValue(number, kCFNumberIntType, &int_value))
37 return int_value; 37 return int_value;
38 else 38 else
39 return default_value; 39 return default_value;
40 } 40 }
(...skipping 11 matching lines...) Expand all
52 config->set_auto_detect( 52 config->set_auto_detect(
53 GetBoolFromDictionary(config_dict.get(), 53 GetBoolFromDictionary(config_dict.get(),
54 kSCPropNetProxiesProxyAutoDiscoveryEnable, 54 kSCPropNetProxiesProxyAutoDiscoveryEnable,
55 false)); 55 false));
56 56
57 // PAC file 57 // PAC file
58 58
59 if (GetBoolFromDictionary(config_dict.get(), 59 if (GetBoolFromDictionary(config_dict.get(),
60 kSCPropNetProxiesProxyAutoConfigEnable, 60 kSCPropNetProxiesProxyAutoConfigEnable,
61 false)) { 61 false)) {
62 CFStringRef pac_url_ref = (CFStringRef)mac_util::GetValueFromDictionary( 62 CFStringRef pac_url_ref = (CFStringRef)base::mac::GetValueFromDictionary(
63 config_dict.get(), 63 config_dict.get(),
64 kSCPropNetProxiesProxyAutoConfigURLString, 64 kSCPropNetProxiesProxyAutoConfigURLString,
65 CFStringGetTypeID()); 65 CFStringGetTypeID());
66 if (pac_url_ref) 66 if (pac_url_ref)
67 config->set_pac_url(GURL(base::SysCFStringRefToUTF8(pac_url_ref))); 67 config->set_pac_url(GURL(base::SysCFStringRefToUTF8(pac_url_ref)));
68 } 68 }
69 69
70 // proxies (for now ftp, http, https, and SOCKS) 70 // proxies (for now ftp, http, https, and SOCKS)
71 71
72 if (GetBoolFromDictionary(config_dict.get(), 72 if (GetBoolFromDictionary(config_dict.get(),
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 if (proxy_server.is_valid()) { 122 if (proxy_server.is_valid()) {
123 config->proxy_rules().type = 123 config->proxy_rules().type =
124 ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME; 124 ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME;
125 config->proxy_rules().fallback_proxy = proxy_server; 125 config->proxy_rules().fallback_proxy = proxy_server;
126 } 126 }
127 } 127 }
128 128
129 // proxy bypass list 129 // proxy bypass list
130 130
131 CFArrayRef bypass_array_ref = 131 CFArrayRef bypass_array_ref =
132 (CFArrayRef)mac_util::GetValueFromDictionary( 132 (CFArrayRef)base::mac::GetValueFromDictionary(
133 config_dict.get(), 133 config_dict.get(),
134 kSCPropNetProxiesExceptionsList, 134 kSCPropNetProxiesExceptionsList,
135 CFArrayGetTypeID()); 135 CFArrayGetTypeID());
136 if (bypass_array_ref) { 136 if (bypass_array_ref) {
137 CFIndex bypass_array_count = CFArrayGetCount(bypass_array_ref); 137 CFIndex bypass_array_count = CFArrayGetCount(bypass_array_ref);
138 for (CFIndex i = 0; i < bypass_array_count; ++i) { 138 for (CFIndex i = 0; i < bypass_array_count; ++i) {
139 CFStringRef bypass_item_ref = 139 CFStringRef bypass_item_ref =
140 (CFStringRef)CFArrayGetValueAtIndex(bypass_array_ref, i); 140 (CFStringRef)CFArrayGetValueAtIndex(bypass_array_ref, i);
141 if (CFGetTypeID(bypass_item_ref) != CFStringGetTypeID()) { 141 if (CFGetTypeID(bypass_item_ref) != CFStringGetTypeID()) {
142 LOG(WARNING) << "Expected value for item " << i 142 LOG(WARNING) << "Expected value for item " << i
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 259
260 // Keep track of the last value we have seen. 260 // Keep track of the last value we have seen.
261 has_fetched_config_ = true; 261 has_fetched_config_ = true;
262 last_config_fetched_ = new_config; 262 last_config_fetched_ = new_config;
263 263
264 // Notify all the observers. 264 // Notify all the observers.
265 FOR_EACH_OBSERVER(Observer, observers_, OnProxyConfigChanged(new_config)); 265 FOR_EACH_OBSERVER(Observer, observers_, OnProxyConfigChanged(new_config));
266 } 266 }
267 267
268 } // namespace net 268 } // namespace net
OLDNEW
« no previous file with comments | « gfx/test_suite.h ('k') | net/proxy/proxy_resolver_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698