OLD | NEW |
---|---|
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 #include "chrome/browser/chromeos/ui_proxy_config_service.h" | 5 #include "chrome/browser/chromeos/ui_proxy_config_service.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/chromeos/net/proxy_config_handler.h" | 10 #include "chrome/browser/chromeos/net/proxy_config_handler.h" |
11 #include "chrome/browser/chromeos/proxy_config_service_impl.h" | 11 #include "chrome/browser/chromeos/proxy_config_service_impl.h" |
12 #include "chromeos/network/network_state.h" | 12 #include "chromeos/network/network_state.h" |
13 #include "chromeos/network/network_state_handler.h" | 13 #include "chromeos/network/network_state_handler.h" |
14 #include "components/device_event_log/device_event_log.h" | |
14 #include "net/proxy/proxy_config.h" | 15 #include "net/proxy/proxy_config.h" |
15 | 16 |
16 namespace chromeos { | 17 namespace chromeos { |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 const char* ModeToString(UIProxyConfig::Mode mode) { | 21 const char* ModeToString(UIProxyConfig::Mode mode) { |
21 switch (mode) { | 22 switch (mode) { |
22 case UIProxyConfig::MODE_DIRECT: | 23 case UIProxyConfig::MODE_DIRECT: |
23 return "direct"; | 24 return "direct"; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 | 66 |
66 UIProxyConfigService::~UIProxyConfigService() { | 67 UIProxyConfigService::~UIProxyConfigService() { |
67 } | 68 } |
68 | 69 |
69 void UIProxyConfigService::SetPrefs(PrefService* profile_prefs, | 70 void UIProxyConfigService::SetPrefs(PrefService* profile_prefs, |
70 PrefService* local_state_prefs) { | 71 PrefService* local_state_prefs) { |
71 profile_prefs_ = profile_prefs; | 72 profile_prefs_ = profile_prefs; |
72 local_state_prefs_ = local_state_prefs; | 73 local_state_prefs_ = local_state_prefs; |
73 } | 74 } |
74 | 75 |
75 void UIProxyConfigService::SetCurrentNetwork( | 76 void UIProxyConfigService::SetCurrentNetworkGuid( |
76 const std::string& current_network) { | 77 const std::string& current_guid) { |
77 current_ui_network_ = current_network; | 78 current_ui_network_guid_ = current_guid; |
78 } | 79 } |
79 | 80 |
80 void UIProxyConfigService::UpdateFromPrefs() { | 81 void UIProxyConfigService::UpdateFromPrefs() { |
81 const NetworkState* network = NULL; | 82 const NetworkState* network = NULL; |
pneubeck (no reviews)
2015/03/12 20:53:57
indentation
stevenjb
2015/03/13 01:20:14
Done.
| |
82 if (!current_ui_network_.empty()) { | 83 if (!current_ui_network_guid_.empty()) { |
83 network = NetworkHandler::Get() | 84 network = |
84 ->network_state_handler() | 85 NetworkHandler::Get()->network_state_handler()->GetNetworkStateFromGuid( |
85 ->GetNetworkStateFromServicePath(current_ui_network_, | 86 current_ui_network_guid_); |
86 true /* configured_only */); | |
87 LOG_IF(ERROR, !network) << "Couldn't find NetworkState for network " | |
88 << current_ui_network_; | |
89 } | 87 } |
90 if (!network) { | 88 if (!network || !network->IsInProfile()) { |
91 current_ui_network_.clear(); | 89 NET_LOG(ERROR) << "No configured NetworkState for guid: " |
90 << current_ui_network_guid_; | |
91 current_ui_network_guid_.clear(); | |
92 current_ui_config_ = UIProxyConfig(); | 92 current_ui_config_ = UIProxyConfig(); |
93 return; | 93 return; |
94 } | 94 } |
95 | 95 |
96 DetermineEffectiveConfig(*network); | 96 DetermineEffectiveConfig(*network); |
97 VLOG(1) << "Current ui network: " << network->name() << ", " | 97 VLOG(1) << "Current ui network: " << network->name() << ", " |
98 << ModeToString(current_ui_config_.mode) << ", " | 98 << ModeToString(current_ui_config_.mode) << ", " |
99 << ProxyPrefs::ConfigStateToDebugString(current_ui_config_.state) | 99 << ProxyPrefs::ConfigStateToDebugString(current_ui_config_.state) |
100 << ", modifiable:" << current_ui_config_.user_modifiable; | 100 << ", modifiable:" << current_ui_config_.user_modifiable; |
101 } | 101 } |
102 | 102 |
103 void UIProxyConfigService::GetProxyConfig(UIProxyConfig* config) const { | 103 void UIProxyConfigService::GetProxyConfig(UIProxyConfig* config) const { |
104 *config = current_ui_config_; | 104 *config = current_ui_config_; |
105 } | 105 } |
106 | 106 |
107 void UIProxyConfigService::SetProxyConfig(const UIProxyConfig& config) { | 107 void UIProxyConfigService::SetProxyConfig(const UIProxyConfig& config) { |
108 current_ui_config_ = config; | 108 current_ui_config_ = config; |
109 if (current_ui_network_.empty()) | 109 if (current_ui_network_guid_.empty()) |
110 return; | 110 return; |
111 | 111 |
112 const NetworkState* network = | 112 const NetworkState* network = |
113 NetworkHandler::Get() | 113 NetworkHandler::Get()->network_state_handler()->GetNetworkStateFromGuid( |
114 ->network_state_handler() | 114 current_ui_network_guid_); |
115 ->GetNetworkStateFromServicePath(current_ui_network_, | 115 if (!network || !network->IsInProfile()) { |
116 true /* configured_only */); | 116 NET_LOG(ERROR) << "No configured NetworkState for guid: " |
117 if (!network) { | 117 << current_ui_network_guid_; |
118 LOG(ERROR) << "Couldn't find NetworkState for network " | |
119 << current_ui_network_; | |
120 return; | 118 return; |
121 } | 119 } |
122 | 120 |
123 // Store config for this network. | 121 // Store config for this network. |
124 scoped_ptr<base::DictionaryValue> proxy_config_value( | 122 scoped_ptr<base::DictionaryValue> proxy_config_value( |
125 config.ToPrefProxyConfig()); | 123 config.ToPrefProxyConfig()); |
126 ProxyConfigDictionary proxy_config_dict(proxy_config_value.get()); | 124 ProxyConfigDictionary proxy_config_dict(proxy_config_value.get()); |
127 | 125 |
128 VLOG(1) << "Set proxy for " << current_ui_network_ | 126 VLOG(1) << "Set proxy for " << current_ui_network_guid_ |
129 << " to " << *proxy_config_value; | 127 << " to " << *proxy_config_value; |
130 | 128 |
131 proxy_config::SetProxyConfigForNetwork(proxy_config_dict, *network); | 129 proxy_config::SetProxyConfigForNetwork(proxy_config_dict, *network); |
132 current_ui_config_.state = ProxyPrefs::CONFIG_SYSTEM; | 130 current_ui_config_.state = ProxyPrefs::CONFIG_SYSTEM; |
133 } | 131 } |
134 | 132 |
135 void UIProxyConfigService::DetermineEffectiveConfig( | 133 void UIProxyConfigService::DetermineEffectiveConfig( |
136 const NetworkState& network) { | 134 const NetworkState& network) { |
137 DCHECK(local_state_prefs_); | 135 DCHECK(local_state_prefs_); |
138 | 136 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 } else if (!IsNetworkProxySettingsEditable(onc_source)) { | 175 } else if (!IsNetworkProxySettingsEditable(onc_source)) { |
178 current_ui_config_.state = ProxyPrefs::CONFIG_POLICY; | 176 current_ui_config_.state = ProxyPrefs::CONFIG_POLICY; |
179 current_ui_config_.user_modifiable = false; | 177 current_ui_config_.user_modifiable = false; |
180 } else { | 178 } else { |
181 current_ui_config_.user_modifiable = !ProxyConfigServiceImpl::IgnoreProxy( | 179 current_ui_config_.user_modifiable = !ProxyConfigServiceImpl::IgnoreProxy( |
182 profile_prefs_, network.profile_path(), onc_source); | 180 profile_prefs_, network.profile_path(), onc_source); |
183 } | 181 } |
184 } | 182 } |
185 | 183 |
186 } // namespace chromeos | 184 } // namespace chromeos |
OLD | NEW |