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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc

Issue 1006553002: Add third-party VPN support to network details dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@f_2_460428_add_ash_ui
Patch Set: Prepare for removal of GetManagedPropertiesResult() by tracking VPN providers and networks separate… Created 5 years, 9 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/ui/webui/options/chromeos/internet_options_handler.h" 5 #include "chrome/browser/ui/webui/options/chromeos/internet_options_handler.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/bind_helpers.h" 15 #include "base/bind_helpers.h"
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/chromeos/mobile_config.h" 21 #include "chrome/browser/chromeos/mobile_config.h"
22 #include "chrome/browser/chromeos/net/onc_utils.h" 22 #include "chrome/browser/chromeos/net/onc_utils.h"
23 #include "chrome/browser/chromeos/options/network_config_view.h" 23 #include "chrome/browser/chromeos/options/network_config_view.h"
24 #include "chrome/browser/chromeos/options/network_property_ui_data.h" 24 #include "chrome/browser/chromeos/options/network_property_ui_data.h"
25 #include "chrome/browser/chromeos/profiles/profile_helper.h"
25 #include "chrome/browser/chromeos/settings/cros_settings.h" 26 #include "chrome/browser/chromeos/settings/cros_settings.h"
26 #include "chrome/browser/chromeos/sim_dialog_delegate.h" 27 #include "chrome/browser/chromeos/sim_dialog_delegate.h"
27 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" 28 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h"
28 #include "chrome/browser/chromeos/ui/mobile_config_ui.h" 29 #include "chrome/browser/chromeos/ui/mobile_config_ui.h"
29 #include "chrome/browser/chromeos/ui_proxy_config_service.h" 30 #include "chrome/browser/chromeos/ui_proxy_config_service.h"
30 #include "chrome/browser/profiles/profile.h" 31 #include "chrome/browser/profiles/profile.h"
31 #include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h" 32 #include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h"
32 #include "chrome/browser/ui/webui/options/chromeos/internet_options_handler_stri ngs.h" 33 #include "chrome/browser/ui/webui/options/chromeos/internet_options_handler_stri ngs.h"
33 #include "chromeos/chromeos_switches.h" 34 #include "chromeos/chromeos_switches.h"
34 #include "chromeos/login/login_state.h" 35 #include "chromeos/login/login_state.h"
35 #include "chromeos/network/device_state.h" 36 #include "chromeos/network/device_state.h"
36 #include "chromeos/network/managed_network_configuration_handler.h" 37 #include "chromeos/network/managed_network_configuration_handler.h"
37 #include "chromeos/network/network_connection_handler.h" 38 #include "chromeos/network/network_connection_handler.h"
38 #include "chromeos/network/network_device_handler.h" 39 #include "chromeos/network/network_device_handler.h"
39 #include "chromeos/network/network_event_log.h" 40 #include "chromeos/network/network_event_log.h"
40 #include "chromeos/network/network_ip_config.h" 41 #include "chromeos/network/network_ip_config.h"
41 #include "chromeos/network/network_profile.h" 42 #include "chromeos/network/network_profile.h"
42 #include "chromeos/network/network_profile_handler.h" 43 #include "chromeos/network/network_profile_handler.h"
43 #include "chromeos/network/network_state.h" 44 #include "chromeos/network/network_state.h"
44 #include "chromeos/network/network_state_handler.h" 45 #include "chromeos/network/network_state_handler.h"
45 #include "chromeos/network/network_util.h" 46 #include "chromeos/network/network_util.h"
46 #include "chromeos/network/onc/onc_signature.h" 47 #include "chromeos/network/onc/onc_signature.h"
47 #include "chromeos/network/onc/onc_translation_tables.h" 48 #include "chromeos/network/onc/onc_translation_tables.h"
48 #include "chromeos/network/onc/onc_translator.h" 49 #include "chromeos/network/onc/onc_translator.h"
49 #include "chromeos/network/onc/onc_utils.h" 50 #include "chromeos/network/onc/onc_utils.h"
50 #include "components/onc/onc_constants.h" 51 #include "components/onc/onc_constants.h"
52 #include "components/user_manager/user_manager.h"
51 #include "content/public/browser/web_contents.h" 53 #include "content/public/browser/web_contents.h"
52 #include "content/public/browser/web_ui.h" 54 #include "content/public/browser/web_ui.h"
55 #include "extensions/browser/api/vpn_provider/vpn_service.h"
56 #include "extensions/browser/api/vpn_provider/vpn_service_factory.h"
57 #include "extensions/browser/extension_registry.h"
58 #include "extensions/common/extension.h"
59 #include "extensions/common/extension_set.h"
60 #include "extensions/common/permissions/api_permission.h"
61 #include "extensions/common/permissions/permissions_data.h"
53 #include "third_party/cros_system_api/dbus/service_constants.h" 62 #include "third_party/cros_system_api/dbus/service_constants.h"
63 #include "ui/base/l10n/l10n_util.h"
54 #include "ui/base/webui/web_ui_util.h" 64 #include "ui/base/webui/web_ui_util.h"
55 #include "ui/chromeos/network/network_connect.h" 65 #include "ui/chromeos/network/network_connect.h"
66 #include "ui/chromeos/strings/grit/ui_chromeos_strings.h"
56 67
57 namespace chromeos { 68 namespace chromeos {
58 namespace options { 69 namespace options {
59 70
60 namespace { 71 namespace {
61 72
62 // Keys for the initial "localized" dictionary values. 73 // Keys for the initial "localized" dictionary values.
63 const char kLoggedInAsOwnerKey[] = "loggedInAsOwner"; 74 const char kLoggedInAsOwnerKey[] = "loggedInAsOwner";
64 const char kShowCarrierSelectKey[] = "showCarrierSelect"; 75 const char kShowCarrierSelectKey[] = "showCarrierSelect";
65 const char kNetworkDataKey[] = "networkData"; 76 const char kNetworkDataKey[] = "networkData";
66 77
67 // Keys for the network description dictionary passed to the web ui. Make sure 78 // Keys for the network description dictionary passed to the web ui. Make sure
68 // to keep the strings in sync with what the JavaScript side uses. 79 // to keep the strings in sync with what the JavaScript side uses.
69 const char kNetworkInfoKeyPolicyManaged[] = "policyManaged"; 80 const char kNetworkInfoKeyPolicyManaged[] = "policyManaged";
70 81
71 // Functions we call in JavaScript. 82 // Functions we call in JavaScript.
83 const char kSetVPNProvidersFunction[] =
84 "options.VPNProviders.setProviders";
72 const char kRefreshNetworkDataFunction[] = 85 const char kRefreshNetworkDataFunction[] =
73 "options.network.NetworkList.refreshNetworkData"; 86 "options.network.NetworkList.refreshNetworkData";
74 const char kGetManagedPropertiesResultFunction[] = 87 const char kGetManagedPropertiesResultFunction[] =
75 "options.internet.DetailsInternetPage.getManagedPropertiesResult"; 88 "options.internet.DetailsInternetPage.getManagedPropertiesResult";
76 const char kUpdateConnectionDataFunction[] = 89 const char kUpdateConnectionDataFunction[] =
77 "options.internet.DetailsInternetPage.updateConnectionData"; 90 "options.internet.DetailsInternetPage.updateConnectionData";
78 const char kUpdateCarrierFunction[] = 91 const char kUpdateCarrierFunction[] =
79 "options.internet.DetailsInternetPage.updateCarrier"; 92 "options.internet.DetailsInternetPage.updateCarrier";
80 93
81 // Setter methods called from JS that still need to be converted to match 94 // Setter methods called from JS that still need to be converted to match
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 const char kTagWifiEnabled[] = "wifiEnabled"; 128 const char kTagWifiEnabled[] = "wifiEnabled";
116 const char kTagWimaxAvailable[] = "wimaxAvailable"; 129 const char kTagWimaxAvailable[] = "wimaxAvailable";
117 const char kTagWimaxEnabled[] = "wimaxEnabled"; 130 const char kTagWimaxEnabled[] = "wimaxEnabled";
118 const char kTagWiredList[] = "wiredList"; 131 const char kTagWiredList[] = "wiredList";
119 const char kTagWirelessList[] = "wirelessList"; 132 const char kTagWirelessList[] = "wirelessList";
120 133
121 // Pseudo-ONC chrome specific properties appended to the ONC dictionary. 134 // Pseudo-ONC chrome specific properties appended to the ONC dictionary.
122 const char kNetworkInfoKeyServicePath[] = "servicePath"; 135 const char kNetworkInfoKeyServicePath[] = "servicePath";
123 const char kTagErrorMessage[] = "errorMessage"; 136 const char kTagErrorMessage[] = "errorMessage";
124 const char kTagShowViewAccountButton[] = "showViewAccountButton"; 137 const char kTagShowViewAccountButton[] = "showViewAccountButton";
138 const char kTagVPNProviderID[] = "VPNProviderID";
139
140 // ID used for the built-in OpenVPN/L2TP VPN provider. This must be kept in sync
141 // with chrome/browser/resources/options/chromeos/vpn_providers.js.
142 const char kBuiltInVPNProviderID[] = "built-in";
michaelpg 2015/03/16 05:45:20 nit: make this a @const in vpn_providers.js and ad
bartfab (slow) 2015/03/16 10:04:51 Done.
125 143
126 void ShillError(const std::string& function, 144 void ShillError(const std::string& function,
127 const std::string& error_name, 145 const std::string& error_name,
128 scoped_ptr<base::DictionaryValue> error_data) { 146 scoped_ptr<base::DictionaryValue> error_data) {
129 // UpdateConnectionData may send requests for stale services; ignore 147 // UpdateConnectionData may send requests for stale services; ignore
130 // these errors. 148 // these errors.
131 if (function == "UpdateConnectionData" && 149 if (function == "UpdateConnectionData" &&
132 error_name == network_handler::kDBusFailedError) 150 error_name == network_handler::kDBusFailedError)
133 return; 151 return;
134 NET_LOG_ERROR("Shill Error from InternetOptionsHandler: " + error_name, 152 NET_LOG_ERROR("Shill Error from InternetOptionsHandler: " + error_name,
(...skipping 13 matching lines...) Expand all
148 const PrefService* profile_prefs) { 166 const PrefService* profile_prefs) {
149 scoped_ptr<base::DictionaryValue> network_info = 167 scoped_ptr<base::DictionaryValue> network_info =
150 network_util::TranslateNetworkStateToONC(network); 168 network_util::TranslateNetworkStateToONC(network);
151 169
152 bool has_policy = onc::HasPolicyForNetwork( 170 bool has_policy = onc::HasPolicyForNetwork(
153 profile_prefs, g_browser_process->local_state(), *network); 171 profile_prefs, g_browser_process->local_state(), *network);
154 network_info->SetBoolean(kNetworkInfoKeyPolicyManaged, has_policy); 172 network_info->SetBoolean(kNetworkInfoKeyPolicyManaged, has_policy);
155 173
156 network_info->SetString(kNetworkInfoKeyServicePath, network->path()); 174 network_info->SetString(kNetworkInfoKeyServicePath, network->path());
157 175
176 if (network->type() == shill::kTypeVPN) {
177 std::string provider_id = network->vpn_provider_extension_id();
178 if (provider_id.empty())
179 provider_id = kBuiltInVPNProviderID;
180 network_info->SetString(kTagVPNProviderID, provider_id);
181 }
stevenjb 2015/03/15 17:00:08 This should be done in network_state.cc, not here,
bartfab (slow) 2015/03/16 10:04:51 Fully ack. My goal was to prepare things so that w
182
158 return network_info.release(); 183 return network_info.release();
159 } 184 }
160 185
161 bool ShowViewAccountButton(const NetworkState* cellular) { 186 bool ShowViewAccountButton(const NetworkState* cellular) {
162 if (cellular->activation_state() != shill::kActivationStateActivating && 187 if (cellular->activation_state() != shill::kActivationStateActivating &&
163 cellular->activation_state() != shill::kActivationStateActivated) 188 cellular->activation_state() != shill::kActivationStateActivated)
164 return false; 189 return false;
165 190
166 const DeviceState* device = 191 const DeviceState* device =
167 NetworkHandler::Get()->network_state_handler()->GetDeviceState( 192 NetworkHandler::Get()->network_state_handler()->GetDeviceState(
(...skipping 25 matching lines...) Expand all
193 device->properties().GetStringWithoutPathExpansion(shill::kMdnProperty, 218 device->properties().GetStringWithoutPathExpansion(shill::kMdnProperty,
194 &mdn); 219 &mdn);
195 } 220 }
196 if (mdn.empty()) 221 if (mdn.empty())
197 return false; 222 return false;
198 } 223 }
199 224
200 return true; 225 return true;
201 } 226 }
202 227
228 bool IsVPNProvider(const extensions::Extension* extension) {
229 return extension->permissions_data()->HasAPIPermission(
230 extensions::APIPermission::kVpnProvider);
michaelpg 2015/03/16 05:45:20 nit: remove extra indentation
bartfab (slow) 2015/03/16 10:04:51 Done.
231 }
232
233 Profile* GetProfileForPrimaryUser() {
234 return chromeos::ProfileHelper::Get()->GetProfileByUser(
235 user_manager::UserManager::Get()->GetPrimaryUser());
236 }
237
238 extensions::ExtensionRegistry* GetExtensionRegistryForPrimaryUser() {
239 return extensions::ExtensionRegistry::Get(GetProfileForPrimaryUser());
240 }
241
203 } // namespace 242 } // namespace
204 243
205 InternetOptionsHandler::InternetOptionsHandler() 244 InternetOptionsHandler::InternetOptionsHandler()
206 : weak_factory_(this) { 245 : weak_factory_(this) {
246 GetExtensionRegistryForPrimaryUser()->AddObserver(this);
207 NetworkHandler::Get()->network_state_handler()->AddObserver(this, FROM_HERE); 247 NetworkHandler::Get()->network_state_handler()->AddObserver(this, FROM_HERE);
208 } 248 }
209 249
210 InternetOptionsHandler::~InternetOptionsHandler() { 250 InternetOptionsHandler::~InternetOptionsHandler() {
211 if (NetworkHandler::IsInitialized()) { 251 if (NetworkHandler::IsInitialized()) {
212 NetworkHandler::Get()->network_state_handler()->RemoveObserver( 252 NetworkHandler::Get()->network_state_handler()->RemoveObserver(
213 this, FROM_HERE); 253 this, FROM_HERE);
214 } 254 }
255 GetExtensionRegistryForPrimaryUser()->RemoveObserver(this);
215 } 256 }
216 257
217 void InternetOptionsHandler::GetLocalizedValues( 258 void InternetOptionsHandler::GetLocalizedValues(
218 base::DictionaryValue* localized_strings) { 259 base::DictionaryValue* localized_strings) {
219 DCHECK(localized_strings); 260 DCHECK(localized_strings);
220 internet_options_strings::RegisterLocalizedStrings(localized_strings); 261 internet_options_strings::RegisterLocalizedStrings(localized_strings);
221 262
222 // TODO(stevenjb): Find a better way to populate initial data before 263 // TODO(stevenjb): Find a better way to populate initial data before
223 // InitializePage() gets called. 264 // InitializePage() gets called.
224 std::string owner; 265 std::string owner;
225 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); 266 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner);
226 bool logged_in_as_owner = LoginState::Get()->GetLoggedInUserType() == 267 bool logged_in_as_owner = LoginState::Get()->GetLoggedInUserType() ==
227 LoginState::LOGGED_IN_USER_OWNER; 268 LoginState::LOGGED_IN_USER_OWNER;
228 localized_strings->SetBoolean(kLoggedInAsOwnerKey, logged_in_as_owner); 269 localized_strings->SetBoolean(kLoggedInAsOwnerKey, logged_in_as_owner);
229 localized_strings->SetBoolean( 270 localized_strings->SetBoolean(
230 kShowCarrierSelectKey, base::CommandLine::ForCurrentProcess()->HasSwitch( 271 kShowCarrierSelectKey, base::CommandLine::ForCurrentProcess()->HasSwitch(
231 chromeos::switches::kEnableCarrierSwitching)); 272 chromeos::switches::kEnableCarrierSwitching));
232 273
233 base::DictionaryValue* network_dictionary = new base::DictionaryValue; 274 base::DictionaryValue* network_dictionary = new base::DictionaryValue;
234 FillNetworkInfo(network_dictionary); 275 FillNetworkInfo(network_dictionary);
235 localized_strings->Set(kNetworkDataKey, network_dictionary); 276 localized_strings->Set(kNetworkDataKey, network_dictionary);
236 } 277 }
237 278
238 void InternetOptionsHandler::InitializePage() { 279 void InternetOptionsHandler::InitializePage() {
280 UpdateVPNProviders();
239 NetworkHandler::Get()->network_state_handler()->RequestScan(); 281 NetworkHandler::Get()->network_state_handler()->RequestScan();
240 RefreshNetworkData(); 282 RefreshNetworkData();
241 } 283 }
242 284
243 void InternetOptionsHandler::RegisterMessages() { 285 void InternetOptionsHandler::RegisterMessages() {
244 web_ui()->RegisterMessageCallback(kAddConnectionMessage, 286 web_ui()->RegisterMessageCallback(kAddConnectionMessage,
245 base::Bind(&InternetOptionsHandler::AddConnection, 287 base::Bind(&InternetOptionsHandler::AddConnection,
246 base::Unretained(this))); 288 base::Unretained(this)));
247 web_ui()->RegisterMessageCallback(kRemoveNetworkMessage, 289 web_ui()->RegisterMessageCallback(kRemoveNetworkMessage,
248 base::Bind(&InternetOptionsHandler::RemoveNetwork, 290 base::Bind(&InternetOptionsHandler::RemoveNetwork,
(...skipping 19 matching lines...) Expand all
268 base::Bind(&InternetOptionsHandler::GetManagedPropertiesCallback, 310 base::Bind(&InternetOptionsHandler::GetManagedPropertiesCallback,
269 base::Unretained(this))); 311 base::Unretained(this)));
270 web_ui()->RegisterMessageCallback(kStartConnectMessage, 312 web_ui()->RegisterMessageCallback(kStartConnectMessage,
271 base::Bind(&InternetOptionsHandler::StartConnectCallback, 313 base::Bind(&InternetOptionsHandler::StartConnectCallback,
272 base::Unretained(this))); 314 base::Unretained(this)));
273 web_ui()->RegisterMessageCallback(kSetPropertiesMessage, 315 web_ui()->RegisterMessageCallback(kSetPropertiesMessage,
274 base::Bind(&InternetOptionsHandler::SetPropertiesCallback, 316 base::Bind(&InternetOptionsHandler::SetPropertiesCallback,
275 base::Unretained(this))); 317 base::Unretained(this)));
276 } 318 }
277 319
320 void InternetOptionsHandler::OnExtensionLoaded(
321 content::BrowserContext* browser_context,
322 const extensions::Extension* extension) {
323 if (IsVPNProvider(extension))
324 UpdateVPNProviders();
325 }
326
327 void InternetOptionsHandler::OnExtensionUnloaded(
328 content::BrowserContext* browser_context,
329 const extensions::Extension* extension,
330 extensions::UnloadedExtensionInfo::Reason reason) {
331 if (IsVPNProvider(extension))
332 UpdateVPNProviders();
333 }
334
335 void InternetOptionsHandler::OnShutdown(
336 extensions::ExtensionRegistry* registry) {
337 registry->RemoveObserver(this);
338 }
339
278 void InternetOptionsHandler::ShowMorePlanInfoCallback( 340 void InternetOptionsHandler::ShowMorePlanInfoCallback(
279 const base::ListValue* args) { 341 const base::ListValue* args) {
280 if (!web_ui()) 342 if (!web_ui())
281 return; 343 return;
282 std::string service_path; 344 std::string service_path;
283 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { 345 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) {
284 NOTREACHED(); 346 NOTREACHED();
285 return; 347 return;
286 } 348 }
287 ui::NetworkConnect::Get()->ShowMobileSetup(service_path); 349 ui::NetworkConnect::Get()->ShowMobileSetup(service_path);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 std::string service_path; 448 std::string service_path;
387 if (!args->GetString(0, &service_path)) { 449 if (!args->GetString(0, &service_path)) {
388 NOTREACHED(); 450 NOTREACHED();
389 return; 451 return;
390 } 452 }
391 ui::NetworkConnect::Get()->ConnectToNetwork(service_path); 453 ui::NetworkConnect::Get()->ConnectToNetwork(service_path);
392 } 454 }
393 455
394 //////////////////////////////////////////////////////////////////////////////// 456 ////////////////////////////////////////////////////////////////////////////////
395 457
458 void InternetOptionsHandler::UpdateVPNProviders() {
459 extensions::ExtensionRegistry* const registry =
460 GetExtensionRegistryForPrimaryUser();
461
462 base::DictionaryValue vpn_providers;
463 const extensions::ExtensionSet& extensions = registry->enabled_extensions();
464 for (const auto& extension : extensions) {
465 if (IsVPNProvider(extension.get()))
466 vpn_providers.SetString(extension->id(), extension->name());
467 }
468 // Add the built-in OpenVPN/L2TP provider.
469 vpn_providers.SetString(
470 kBuiltInVPNProviderID,
471 l10n_util::GetStringUTF8(IDS_NETWORK_VPN_BUILT_IN_PROVIDER));
472
473 web_ui()->CallJavascriptFunction(kSetVPNProvidersFunction, vpn_providers);
474 }
475
396 void InternetOptionsHandler::RefreshNetworkData() { 476 void InternetOptionsHandler::RefreshNetworkData() {
397 base::DictionaryValue dictionary; 477 base::DictionaryValue dictionary;
398 FillNetworkInfo(&dictionary); 478 FillNetworkInfo(&dictionary);
399 web_ui()->CallJavascriptFunction(kRefreshNetworkDataFunction, dictionary); 479 web_ui()->CallJavascriptFunction(kRefreshNetworkDataFunction, dictionary);
400 } 480 }
401 481
402 void InternetOptionsHandler::UpdateConnectionData( 482 void InternetOptionsHandler::UpdateConnectionData(
403 const std::string& service_path) { 483 const std::string& service_path) {
404 NetworkHandler::Get() 484 NetworkHandler::Get()
405 ->managed_network_configuration_handler() 485 ->managed_network_configuration_handler()
(...skipping 17 matching lines...) Expand all
423 // Add a Chrome specific translated error message. TODO(stevenjb): Figure 503 // Add a Chrome specific translated error message. TODO(stevenjb): Figure
424 // out a more robust way to track errors. Service.Error is transient so we 504 // out a more robust way to track errors. Service.Error is transient so we
425 // use NetworkState.error() which accurately tracks the "last" error. 505 // use NetworkState.error() which accurately tracks the "last" error.
426 dictionary->SetString(kTagErrorMessage, 506 dictionary->SetString(kTagErrorMessage,
427 ui::NetworkConnect::Get()->GetShillErrorString( 507 ui::NetworkConnect::Get()->GetShillErrorString(
428 network->error(), service_path)); 508 network->error(), service_path));
429 // Add additional non-ONC cellular properties to inform the UI. 509 // Add additional non-ONC cellular properties to inform the UI.
430 if (network->type() == shill::kTypeCellular) { 510 if (network->type() == shill::kTypeCellular) {
431 dictionary->SetBoolean(kTagShowViewAccountButton, 511 dictionary->SetBoolean(kTagShowViewAccountButton,
432 ShowViewAccountButton(network)); 512 ShowViewAccountButton(network));
513 } else if (network->type() == shill::kTypeVPN) {
514 std::string provider_id = network->vpn_provider_extension_id();
515 if (provider_id.empty())
516 provider_id = kBuiltInVPNProviderID;
517 dictionary->SetString(kTagVPNProviderID, provider_id);
433 } 518 }
434 } 519 }
435 web_ui()->CallJavascriptFunction(js_callback_function, *dictionary); 520 web_ui()->CallJavascriptFunction(js_callback_function, *dictionary);
436 } 521 }
437 522
438 void InternetOptionsHandler::UpdateCarrier() { 523 void InternetOptionsHandler::UpdateCarrier() {
439 web_ui()->CallJavascriptFunction(kUpdateCarrierFunction); 524 web_ui()->CallJavascriptFunction(kUpdateCarrierFunction);
440 } 525 }
441 526
442 void InternetOptionsHandler::DeviceListChanged() { 527 void InternetOptionsHandler::DeviceListChanged() {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 LOG(ERROR) << "Unsupported type for AddConnection"; 606 LOG(ERROR) << "Unsupported type for AddConnection";
522 } 607 }
523 } 608 }
524 609
525 void InternetOptionsHandler::ConfigureNetwork(const base::ListValue* args) { 610 void InternetOptionsHandler::ConfigureNetwork(const base::ListValue* args) {
526 std::string service_path; 611 std::string service_path;
527 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { 612 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) {
528 NOTREACHED(); 613 NOTREACHED();
529 return; 614 return;
530 } 615 }
616
617 const NetworkState* network = GetNetworkState(service_path);
618 if (!network)
619 return;
620
621 if (network->type() == shill::kTypeVPN &&
622 !network->vpn_provider_extension_id().empty()) {
623 // Request that the third-party VPN provider used by the |network| show a
624 // configuration dialog for it.
625 VpnServiceFactory::GetForBrowserContext(GetProfileForPrimaryUser())->
626 SendShowConfigureDialogToExtension(
627 network->vpn_provider_extension_id(), network->name());
628 return;
629 }
630
531 NetworkConfigView::Show(service_path, GetNativeWindow()); 631 NetworkConfigView::Show(service_path, GetNativeWindow());
532 } 632 }
533 633
534 void InternetOptionsHandler::ActivateNetwork(const base::ListValue* args) { 634 void InternetOptionsHandler::ActivateNetwork(const base::ListValue* args) {
535 std::string service_path; 635 std::string service_path;
536 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { 636 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) {
537 NOTREACHED(); 637 NOTREACHED();
538 return; 638 return;
539 } 639 }
540 ui::NetworkConnect::Get()->ActivateCellular(service_path); 640 ui::NetworkConnect::Get()->ActivateCellular(service_path);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 dictionary->SetBoolean( 746 dictionary->SetBoolean(
647 kTagWimaxAvailable, 747 kTagWimaxAvailable,
648 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); 748 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax()));
649 dictionary->SetBoolean( 749 dictionary->SetBoolean(
650 kTagWimaxEnabled, 750 kTagWimaxEnabled,
651 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); 751 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax()));
652 } 752 }
653 753
654 } // namespace options 754 } // namespace options
655 } // namespace chromeos 755 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698