| 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 CHROME_BROWSER_CHROMEOS_PROXY_CONFIG_SERVICE_IMPL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_PROXY_CONFIG_SERVICE_IMPL_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_PROXY_CONFIG_SERVICE_IMPL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_PROXY_CONFIG_SERVICE_IMPL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/chromeos/cros/network_library.h" | 14 #include "chrome/browser/chromeos/cros/network_library.h" |
| 15 #include "chrome/browser/chromeos/login/signed_settings.h" | |
| 16 #include "chrome/browser/net/pref_proxy_config_tracker_impl.h" | 15 #include "chrome/browser/net/pref_proxy_config_tracker_impl.h" |
| 17 #include "chrome/browser/prefs/pref_member.h" | 16 #include "chrome/browser/prefs/pref_member.h" |
| 18 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 19 | 18 |
| 20 namespace chromeos { | 19 namespace chromeos { |
| 21 | 20 |
| 22 // Implementation of proxy config service for chromeos that: | 21 // Implementation of proxy config service for chromeos that: |
| 23 // - extends PrefProxyConfigTrackerImpl (and so lives and runs entirely on UI | 22 // - extends PrefProxyConfigTrackerImpl (and so lives and runs entirely on UI |
| 24 // thread) to handle proxy from prefs (via PrefProxyConfigTrackerImpl) and | 23 // thread) to handle proxy from prefs (via PrefProxyConfigTrackerImpl) and |
| 25 // system i.e. network (via flimflam notifications) | 24 // system i.e. network (via flimflam notifications) |
| 26 // - exists one per profile and one per local state | 25 // - exists one per profile and one per local state |
| 27 // - retrieves initial system proxy configuration from cros settings persisted | 26 // - retrieves initial system proxy configuration from cros settings persisted |
| 28 // on chromeos device from chromeos revisions before migration to flimflam, | 27 // on chromeos device from chromeos revisions before migration to flimflam, |
| 29 // - persists proxy setting per network in flimflim | 28 // - persists proxy setting per network in flimflim |
| 30 // - provides network stack with latest effective proxy configuration for | 29 // - provides network stack with latest effective proxy configuration for |
| 31 // currently active network via PrefProxyConfigTrackerImpl's mechanism of | 30 // currently active network via PrefProxyConfigTrackerImpl's mechanism of |
| 32 // pushing config to ChromeProxyConfigService | 31 // pushing config to ChromeProxyConfigService |
| 33 // - provides UI with methods to retrieve and modify proxy configuration for | 32 // - provides UI with methods to retrieve and modify proxy configuration for |
| 34 // any remembered network (either currently active or non-active) of current | 33 // any remembered network (either currently active or non-active) of current |
| 35 // user profile | 34 // user profile |
| 36 class ProxyConfigServiceImpl | 35 class ProxyConfigServiceImpl |
| 37 : public PrefProxyConfigTrackerImpl, | 36 : public PrefProxyConfigTrackerImpl, |
| 38 public SignedSettings::Delegate<const base::Value*>, | |
| 39 public NetworkLibrary::NetworkManagerObserver, | 37 public NetworkLibrary::NetworkManagerObserver, |
| 40 public NetworkLibrary::NetworkObserver { | 38 public NetworkLibrary::NetworkObserver { |
| 41 public: | 39 public: |
| 42 // ProxyConfigServiceImpl is created in ProxyServiceFactory:: | 40 // ProxyConfigServiceImpl is created in ProxyServiceFactory:: |
| 43 // CreatePrefProxyConfigTrackerImpl via Profile::GetProxyConfigTracker() for | 41 // CreatePrefProxyConfigTrackerImpl via Profile::GetProxyConfigTracker() for |
| 44 // profile or IOThread constructor for local state and is owned by the | 42 // profile or IOThread constructor for local state and is owned by the |
| 45 // respective classes. | 43 // respective classes. |
| 46 // | 44 // |
| 47 // From the UI, it is accessed via Profile::GetProxyConfigTracker to allow | 45 // From the UI, it is accessed via Profile::GetProxyConfigTracker to allow |
| 48 // user to read or modify the proxy configuration via UIGetProxyConfig or | 46 // user to read or modify the proxy configuration via UIGetProxyConfig or |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 182 |
| 185 // Add/Remove callback functions for notification when network to be viewed is | 183 // Add/Remove callback functions for notification when network to be viewed is |
| 186 // changed by the UI. | 184 // changed by the UI. |
| 187 void AddNotificationCallback(base::Closure callback); | 185 void AddNotificationCallback(base::Closure callback); |
| 188 void RemoveNotificationCallback(base::Closure callback); | 186 void RemoveNotificationCallback(base::Closure callback); |
| 189 | 187 |
| 190 // PrefProxyConfigTrackerImpl implementation. | 188 // PrefProxyConfigTrackerImpl implementation. |
| 191 virtual void OnProxyConfigChanged(ProxyPrefs::ConfigState config_state, | 189 virtual void OnProxyConfigChanged(ProxyPrefs::ConfigState config_state, |
| 192 const net::ProxyConfig& config) OVERRIDE; | 190 const net::ProxyConfig& config) OVERRIDE; |
| 193 | 191 |
| 194 // Implementation for SignedSettings::Delegate | |
| 195 virtual void OnSettingsOpCompleted(SignedSettings::ReturnCode code, | |
| 196 const base::Value* value) OVERRIDE; | |
| 197 | |
| 198 // NetworkLibrary::NetworkManagerObserver implementation. | 192 // NetworkLibrary::NetworkManagerObserver implementation. |
| 199 virtual void OnNetworkManagerChanged(NetworkLibrary* cros) OVERRIDE; | 193 virtual void OnNetworkManagerChanged(NetworkLibrary* cros) OVERRIDE; |
| 200 | 194 |
| 201 // NetworkLibrary::NetworkObserver implementation. | 195 // NetworkLibrary::NetworkObserver implementation. |
| 202 virtual void OnNetworkChanged(NetworkLibrary* cros, | 196 virtual void OnNetworkChanged(NetworkLibrary* cros, |
| 203 const Network* network) OVERRIDE; | 197 const Network* network) OVERRIDE; |
| 204 | 198 |
| 205 // Register UseShardProxies preference. | 199 // Register UseShardProxies preference. |
| 206 static void RegisterPrefs(PrefService* pref_service); | 200 static void RegisterPrefs(PrefService* pref_service); |
| 207 | 201 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 251 |
| 258 // Returns true if proxy is to be ignored for network, which happens if | 252 // Returns true if proxy is to be ignored for network, which happens if |
| 259 // network is shared and use-shared-proxies is turned off. | 253 // network is shared and use-shared-proxies is turned off. |
| 260 bool IgnoreProxy(const Network* network) { | 254 bool IgnoreProxy(const Network* network) { |
| 261 return network->profile_type() == PROFILE_SHARED && !GetUseSharedProxies(); | 255 return network->profile_type() == PROFILE_SHARED && !GetUseSharedProxies(); |
| 262 } | 256 } |
| 263 | 257 |
| 264 // Reset UI cache variables that keep track of UI activities. | 258 // Reset UI cache variables that keep track of UI activities. |
| 265 void ResetUICache(); | 259 void ResetUICache(); |
| 266 | 260 |
| 261 void FetchProxyPolicy(); |
| 262 |
| 267 // Data members. | 263 // Data members. |
| 268 | 264 |
| 269 // Service path of currently active network (determined via flimflam | 265 // Service path of currently active network (determined via flimflam |
| 270 // notifications); if effective proxy config is from system, proxy of this | 266 // notifications); if effective proxy config is from system, proxy of this |
| 271 // network will be the one taking effect. | 267 // network will be the one taking effect. |
| 272 std::string active_network_; | 268 std::string active_network_; |
| 273 | 269 |
| 274 // State of |active_config_|. |active_config_| is only valid if | 270 // State of |active_config_|. |active_config_| is only valid if |
| 275 // |active_config_state_| is not ProxyPrefs::CONFIG_UNSET. | 271 // |active_config_state_| is not ProxyPrefs::CONFIG_UNSET. |
| 276 ProxyPrefs::ConfigState active_config_state_; | 272 ProxyPrefs::ConfigState active_config_state_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 288 std::string current_ui_network_; | 284 std::string current_ui_network_; |
| 289 | 285 |
| 290 // Proxy configuration of |current_ui_network_|. | 286 // Proxy configuration of |current_ui_network_|. |
| 291 ProxyConfig current_ui_config_; | 287 ProxyConfig current_ui_config_; |
| 292 | 288 |
| 293 // Track changes in UseSharedProxies user preference. | 289 // Track changes in UseSharedProxies user preference. |
| 294 BooleanPrefMember use_shared_proxies_; | 290 BooleanPrefMember use_shared_proxies_; |
| 295 | 291 |
| 296 content::NotificationRegistrar registrar_; | 292 content::NotificationRegistrar registrar_; |
| 297 | 293 |
| 298 // Operation to retrieve proxy setting from device. | |
| 299 scoped_refptr<SignedSettings> retrieve_property_op_; | |
| 300 | |
| 301 // Callbacks for notification when network to be viewed has been changed from | 294 // Callbacks for notification when network to be viewed has been changed from |
| 302 // the UI. | 295 // the UI. |
| 303 std::vector<base::Closure> callbacks_; | 296 std::vector<base::Closure> callbacks_; |
| 304 | 297 |
| 298 base::WeakPtrFactory<ProxyConfigServiceImpl> pointer_factory_; |
| 299 |
| 305 DISALLOW_COPY_AND_ASSIGN(ProxyConfigServiceImpl); | 300 DISALLOW_COPY_AND_ASSIGN(ProxyConfigServiceImpl); |
| 306 }; | 301 }; |
| 307 | 302 |
| 308 } // namespace chromeos | 303 } // namespace chromeos |
| 309 | 304 |
| 310 #endif // CHROME_BROWSER_CHROMEOS_PROXY_CONFIG_SERVICE_IMPL_H_ | 305 #endif // CHROME_BROWSER_CHROMEOS_PROXY_CONFIG_SERVICE_IMPL_H_ |
| OLD | NEW |