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

Side by Side Diff: chromeos/network/proxy/ui_proxy_config_service.h

Issue 2446893008: NetworkHandler: Add ui_proxy_config_service (Closed)
Patch Set: Add NetworkHandler::ShutdownPrefServices Created 4 years, 1 month 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
« no previous file with comments | « chromeos/network/network_handler.cc ('k') | chromeos/network/proxy/ui_proxy_config_service.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 CHROMEOS_NETWORK_PROXY_UI_PROXY_CONFIG_SERVICE_H_ 5 #ifndef CHROMEOS_NETWORK_PROXY_UI_PROXY_CONFIG_SERVICE_H_
6 #define CHROMEOS_NETWORK_PROXY_UI_PROXY_CONFIG_SERVICE_H_ 6 #define CHROMEOS_NETWORK_PROXY_UI_PROXY_CONFIG_SERVICE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "chromeos/chromeos_export.h" 11 #include "chromeos/chromeos_export.h"
12 #include "chromeos/network/proxy/ui_proxy_config.h" 12 #include "chromeos/network/proxy/ui_proxy_config.h"
13 #include "components/prefs/pref_change_registrar.h"
13 14
14 class PrefService; 15 class PrefService;
15 16
16 namespace chromeos { 17 namespace chromeos {
17 18
18 class NetworkState; 19 class NetworkState;
19 20
20 // This class is only accessed from the UI via Profile::GetProxyConfigTracker to 21 // This class provides an interface to the UI for getting and setting a proxy
21 // allow the user to read and modify the proxy configuration via 22 // configuration. Primarily this class caches the "current" requested config
22 // GetProxyConfig and SetProxyConfig. 23 // and populates UIProxyConfig for convenient UI consumption.
23 // 24 // NOTE: This class must be rebuilt when the logged in profile changes.
24 // Before reading/setting a proxy config, a network has to be selected using 25 // ALSO NOTE: The provided PrefService instances are used both to retreive proxy
25 // either SetCurrentNetwork (any remembered network) or 26 // configurations set by an extension, and for ONC policy information associated
26 // MakeActiveNetworkCurrent. 27 // with a network. (Per-network proxy configurations are stored in Shill,
28 // but ONC policy configuration is stored in PrefService).
27 class CHROMEOS_EXPORT UIProxyConfigService { 29 class CHROMEOS_EXPORT UIProxyConfigService {
28 public: 30 public:
29 UIProxyConfigService(); 31 // |local_state_prefs| must not be null. |profile_prefs| can be
32 // null if there is no logged in user, in which case only the local state
33 // (device) prefs will be used. See note above.
34 UIProxyConfigService(PrefService* profile_prefs,
35 PrefService* local_state_prefs);
30 ~UIProxyConfigService(); 36 ~UIProxyConfigService();
31 37
32 // After this call, proxy settings are read from |profile_prefs| and 38 // Called when ::proxy_config::prefs change or to force an update.
33 // |local_state_prefs|. In case of usage for the sign-in screen, 39 void UpdateFromPrefs(const std::string& guid);
34 // |profile_prefs| must be NULL because sign-in screen should depend only on
35 // shared settings.
36 void SetPrefs(PrefService* profile_prefs, PrefService* local_state_prefs);
37 40
38 // Called by UI to set the network with GUID |current_guid| to be 41 // Called from UI to retrieve the active proxy configuration. This will be,
39 // displayed or edited. Subsequent Set*/Get* methods will use this 42 // in highest to lowest priority order:
40 // network, until this method is called again. 43 // * A policy enforced proxy associated with |network_guid|.
41 void SetCurrentNetworkGuid(const std::string& current_guid); 44 // * A proxy set by an extension in the active PrefService.
45 // * A user specified proxy associated with |network_guid|.
46 void GetProxyConfig(const std::string& network_guid, UIProxyConfig* config);
42 47
43 void UpdateFromPrefs(); 48 // Called from the UI to update the user proxy configuration for
44 49 // |network_guid|. The proxy specified by |config| is stored by Shill.
45 // Called from UI to retrieve the stored proxy configuration, which is either 50 void SetProxyConfig(const std::string& network_guid,
46 // the last proxy config of the current network or the one last set by 51 const UIProxyConfig& config);
47 // SetProxyConfig.
48 void GetProxyConfig(UIProxyConfig* config) const;
49
50 // Called from UI to update proxy configuration for different modes. Stores
51 // and persists |config| to shill for the current network.
52 void SetProxyConfig(const UIProxyConfig& config);
53 52
54 private: 53 private:
55 // Determines effective proxy config based on prefs from config tracker, 54 // Determines effective proxy config based on prefs from config tracker,
56 // |network| and if user is using shared proxies. The effective config is 55 // |network| and if user is using shared proxies. The effective config is
57 // stored in |current_ui_config_| but not activated on network stack, and 56 // stored in |current_ui_config_| but not activated on network stack, and
58 // hence, not picked up by observers. 57 // hence, not picked up by observers.
59 void DetermineEffectiveConfig(const NetworkState& network); 58 void DetermineEffectiveConfig(const NetworkState& network);
60 59
61 // GUID of network whose proxy configuration is being displayed or 60 void OnPreferenceChanged(const std::string& pref_name);
62 // edited via UI. 61
62 // GUID of network used for current_ui_config_.
63 std::string current_ui_network_guid_; 63 std::string current_ui_network_guid_;
64 64
65 // Proxy configuration of |current_ui_network_|. 65 // Proxy configuration for |current_ui_network_guid_|.
66 UIProxyConfig current_ui_config_; 66 UIProxyConfig current_ui_config_;
67 67
68 // Not owned. 68 PrefService* profile_prefs_; // unowned
69 PrefService* profile_prefs_; 69 PrefChangeRegistrar profile_registrar_;
70 70
71 // Not owned. 71 PrefService* local_state_prefs_; // unowned
72 PrefService* local_state_prefs_; 72 PrefChangeRegistrar local_state_registrar_;
73 73
74 DISALLOW_COPY_AND_ASSIGN(UIProxyConfigService); 74 DISALLOW_COPY_AND_ASSIGN(UIProxyConfigService);
75 }; 75 };
76 76
77 } // namespace chromeos 77 } // namespace chromeos
78 78
79 #endif // CHROMEOS_NETWORK_PROXY_UI_PROXY_CONFIG_SERVICE_H_ 79 #endif // CHROMEOS_NETWORK_PROXY_UI_PROXY_CONFIG_SERVICE_H_
OLDNEW
« no previous file with comments | « chromeos/network/network_handler.cc ('k') | chromeos/network/proxy/ui_proxy_config_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698