OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_CHROMEOS_UI_PROXY_CONFIG_SERVICE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_UI_PROXY_CONFIG_SERVICE_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "base/callback.h" |
| 13 #include "chrome/browser/chromeos/ui_proxy_config.h" |
| 14 |
| 15 class PrefService; |
| 16 |
| 17 namespace chromeos { |
| 18 |
| 19 class Network; |
| 20 class ProxyConfigServiceImpl; |
| 21 |
| 22 // This class is only accessed from the UI via Profile::GetProxyConfigTracker to |
| 23 // allow the user to read and modify the proxy configuration via |
| 24 // GetProxyConfig and SetProxyConfig. |
| 25 // |
| 26 // Before reading/setting a proxy config, a network has to be selected using |
| 27 // either SetCurrentNetwork (any remembered network) or |
| 28 // MakeActiveNetworkCurrent. |
| 29 class UIProxyConfigService { |
| 30 public: |
| 31 explicit UIProxyConfigService(PrefService* pref_service); |
| 32 ~UIProxyConfigService(); |
| 33 |
| 34 // Add/Remove callback functions for notification when network to be viewed is |
| 35 // changed by the UI. |
| 36 // Currently, these are only called by CoreChromeOSOptionsHandler. |
| 37 void AddNotificationCallback(base::Closure callback); |
| 38 void RemoveNotificationCallback(base::Closure callback); |
| 39 |
| 40 // Called by UI to set the network with service path |current_network| to be |
| 41 // displayed or edited. Subsequent Set*/Get* methods will use this |
| 42 // network, until this method is called again. |
| 43 void SetCurrentNetwork(const std::string& current_network); |
| 44 |
| 45 // Called from UI to make the current active network the one to be displayed |
| 46 // or edited. See SetCurrentNetwork. |
| 47 void MakeActiveNetworkCurrent(); |
| 48 |
| 49 // Called from UI to get name of the current network. |
| 50 void GetCurrentNetworkName(std::string* network_name); |
| 51 |
| 52 // Called from UI to retrieve the stored proxy configuration, which is either |
| 53 // the last proxy config of the current network or the one last set by |
| 54 // SetProxyConfig. |
| 55 void GetProxyConfig(UIProxyConfig* config); |
| 56 |
| 57 // Called from UI to update proxy configuration for different modes. Stores |
| 58 // and persists |config| to shill for the current network. |
| 59 void SetProxyConfig(const UIProxyConfig& config); |
| 60 |
| 61 private: |
| 62 // Determines effective proxy config based on prefs from config tracker, |
| 63 // |network| and if user is using shared proxies. The effective config is |
| 64 // stored in |current_ui_config_| but not activated on network stack, and |
| 65 // hence, not picked up by observers. |
| 66 void DetermineEffectiveConfig(const Network& network); |
| 67 |
| 68 // Service path of network whose proxy configuration is being displayed or |
| 69 // edited via UI. |
| 70 std::string current_ui_network_; |
| 71 |
| 72 // Proxy configuration of |current_ui_network_|. |
| 73 UIProxyConfig current_ui_config_; |
| 74 |
| 75 // Callbacks for notification when network to be viewed has been changed from |
| 76 // the UI. |
| 77 std::vector<base::Closure> callbacks_; |
| 78 |
| 79 PrefService* pref_service_; |
| 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(UIProxyConfigService); |
| 82 }; |
| 83 |
| 84 } // namespace chromeos |
| 85 |
| 86 #endif // CHROME_BROWSER_CHROMEOS_UI_PROXY_CONFIG_SERVICE_H_ |
OLD | NEW |