OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef NET_PROXY_PROXY_CONFIG_SERVICE_WIN_H_ | 5 #ifndef NET_PROXY_PROXY_CONFIG_SERVICE_WIN_H_ |
6 #define NET_PROXY_PROXY_CONFIG_SERVICE_WIN_H_ | 6 #define NET_PROXY_PROXY_CONFIG_SERVICE_WIN_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <winhttp.h> | 9 #include <winhttp.h> |
10 | 10 |
| 11 #include <memory> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
14 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
15 #include "net/proxy/polling_proxy_config_service.h" | 16 #include "net/proxy/polling_proxy_config_service.h" |
16 | 17 |
17 namespace base { | 18 namespace base { |
18 namespace win { | 19 namespace win { |
19 class RegKey; | 20 class RegKey; |
20 } | 21 } |
(...skipping 27 matching lines...) Expand all Loading... |
48 : public PollingProxyConfigService { | 49 : public PollingProxyConfigService { |
49 public: | 50 public: |
50 ProxyConfigServiceWin(); | 51 ProxyConfigServiceWin(); |
51 ~ProxyConfigServiceWin() override; | 52 ~ProxyConfigServiceWin() override; |
52 | 53 |
53 // Overrides a function from PollingProxyConfigService. | 54 // Overrides a function from PollingProxyConfigService. |
54 void AddObserver(Observer* observer) override; | 55 void AddObserver(Observer* observer) override; |
55 | 56 |
56 private: | 57 private: |
57 FRIEND_TEST_ALL_PREFIXES(ProxyConfigServiceWinTest, SetFromIEConfig); | 58 FRIEND_TEST_ALL_PREFIXES(ProxyConfigServiceWinTest, SetFromIEConfig); |
58 typedef std::vector<base::win::RegKey*> RegKeyList; | |
59 | 59 |
60 // Registers change observers on the registry keys relating to proxy settings. | 60 // Registers change observers on the registry keys relating to proxy settings. |
61 void StartWatchingRegistryForChanges(); | 61 void StartWatchingRegistryForChanges(); |
62 | 62 |
63 // Creates a new key and appends it to |keys_to_watch_|. If the key fails to | 63 // Creates a new key and appends it to |keys_to_watch_|. If the key fails to |
64 // be created, it is not appended to the list and we return false. | 64 // be created, it is not appended to the list and we return false. |
65 bool AddKeyToWatchList(HKEY rootkey, const wchar_t* subkey); | 65 bool AddKeyToWatchList(HKEY rootkey, const wchar_t* subkey); |
66 | 66 |
67 // This is called whenever one of the registry keys we are watching change. | 67 // This is called whenever one of the registry keys we are watching change. |
68 void OnObjectSignaled(base::win::RegKey* key); | 68 void OnObjectSignaled(base::win::RegKey* key); |
69 | 69 |
70 static void GetCurrentProxyConfig(ProxyConfig* config); | 70 static void GetCurrentProxyConfig(ProxyConfig* config); |
71 | 71 |
72 // Set |config| using the proxy configuration values of |ie_config|. | 72 // Set |config| using the proxy configuration values of |ie_config|. |
73 static void SetFromIEConfig( | 73 static void SetFromIEConfig( |
74 ProxyConfig* config, | 74 ProxyConfig* config, |
75 const WINHTTP_CURRENT_USER_IE_PROXY_CONFIG& ie_config); | 75 const WINHTTP_CURRENT_USER_IE_PROXY_CONFIG& ie_config); |
76 | 76 |
77 RegKeyList keys_to_watch_; | 77 std::vector<std::unique_ptr<base::win::RegKey>> keys_to_watch_; |
78 }; | 78 }; |
79 | 79 |
80 } // namespace net | 80 } // namespace net |
81 | 81 |
82 #endif // NET_PROXY_PROXY_CONFIG_SERVICE_WIN_H_ | 82 #endif // NET_PROXY_PROXY_CONFIG_SERVICE_WIN_H_ |
OLD | NEW |