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. | |
stevenjb
2013/05/15 17:44:14
Maybe describe when these are called?
pneubeck (no reviews)
2013/05/15 20:24:48
Done. Again, hopefully I can remove this callback
| |
36 void AddNotificationCallback(base::Closure callback); | |
37 void RemoveNotificationCallback(base::Closure callback); | |
38 | |
39 // Called by UI to set the network with service path |current_network| to be | |
40 // displayed or edited. Subsequent Set*/Get* methods will use this | |
41 // network, until this method is called again. | |
42 void SetCurrentNetwork(const std::string& current_network); | |
43 | |
44 // Called from UI to make the current active network the one to be displayed | |
45 // or edited. See SetCurrentNetwork. | |
46 void MakeActiveNetworkCurrent(); | |
stevenjb
2013/05/15 17:44:14
We should use 'DefaultNetwork' here.
pneubeck (no reviews)
2013/05/15 20:24:48
I didn't touch it as it's still using network libr
| |
47 | |
48 // Called from UI to get name of the current network. | |
49 void GetCurrentNetworkName(std::string* network_name); | |
50 | |
51 // Called from UI to retrieve the stored proxy configuration, which is either | |
52 // the last proxy config of the current network or the one last set by | |
53 // SetProxyConfig. | |
54 void GetProxyConfig(UIProxyConfig* config); | |
55 | |
56 // Called from UI to update proxy configuration for different modes. Stores | |
57 // and persists |config| to shill for the current network. | |
58 void SetProxyConfig(const UIProxyConfig& config); | |
59 | |
60 private: | |
61 // Determines effective proxy config based on prefs from config tracker, | |
62 // |network| and if user is using shared proxies. The effective config is | |
63 // stored in |current_ui_config_| but not activated on network stack, and | |
64 // hence, not picked up by observers. | |
65 void DetermineEffectiveConfig(const Network& network); | |
66 | |
67 // Service path of network whose proxy configuration is being displayed or | |
68 // edited via UI, separate from |default_network_| which may be same or | |
69 // different. | |
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 |