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

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: Updated to read the extension ID from the new ONC property. 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/memory/scoped_ptr.h"
17 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
18 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
19 #include "base/values.h" 20 #include "base/values.h"
20 #include "chrome/browser/browser_process.h" 21 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/chromeos/mobile_config.h" 22 #include "chrome/browser/chromeos/mobile_config.h"
22 #include "chrome/browser/chromeos/net/onc_utils.h" 23 #include "chrome/browser/chromeos/net/onc_utils.h"
23 #include "chrome/browser/chromeos/options/network_config_view.h" 24 #include "chrome/browser/chromeos/options/network_config_view.h"
24 #include "chrome/browser/chromeos/options/network_property_ui_data.h" 25 #include "chrome/browser/chromeos/options/network_property_ui_data.h"
26 #include "chrome/browser/chromeos/profiles/profile_helper.h"
25 #include "chrome/browser/chromeos/settings/cros_settings.h" 27 #include "chrome/browser/chromeos/settings/cros_settings.h"
26 #include "chrome/browser/chromeos/sim_dialog_delegate.h" 28 #include "chrome/browser/chromeos/sim_dialog_delegate.h"
27 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" 29 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h"
28 #include "chrome/browser/chromeos/ui/mobile_config_ui.h" 30 #include "chrome/browser/chromeos/ui/mobile_config_ui.h"
29 #include "chrome/browser/chromeos/ui_proxy_config_service.h" 31 #include "chrome/browser/chromeos/ui_proxy_config_service.h"
30 #include "chrome/browser/profiles/profile.h" 32 #include "chrome/browser/profiles/profile.h"
31 #include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h" 33 #include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h"
32 #include "chrome/browser/ui/webui/options/chromeos/internet_options_handler_stri ngs.h" 34 #include "chrome/browser/ui/webui/options/chromeos/internet_options_handler_stri ngs.h"
33 #include "chromeos/chromeos_switches.h" 35 #include "chromeos/chromeos_switches.h"
34 #include "chromeos/login/login_state.h" 36 #include "chromeos/login/login_state.h"
35 #include "chromeos/network/device_state.h" 37 #include "chromeos/network/device_state.h"
36 #include "chromeos/network/managed_network_configuration_handler.h" 38 #include "chromeos/network/managed_network_configuration_handler.h"
37 #include "chromeos/network/network_connection_handler.h" 39 #include "chromeos/network/network_connection_handler.h"
38 #include "chromeos/network/network_device_handler.h" 40 #include "chromeos/network/network_device_handler.h"
39 #include "chromeos/network/network_event_log.h" 41 #include "chromeos/network/network_event_log.h"
40 #include "chromeos/network/network_ip_config.h" 42 #include "chromeos/network/network_ip_config.h"
41 #include "chromeos/network/network_profile.h" 43 #include "chromeos/network/network_profile.h"
42 #include "chromeos/network/network_profile_handler.h" 44 #include "chromeos/network/network_profile_handler.h"
43 #include "chromeos/network/network_state.h" 45 #include "chromeos/network/network_state.h"
44 #include "chromeos/network/network_state_handler.h" 46 #include "chromeos/network/network_state_handler.h"
45 #include "chromeos/network/network_util.h" 47 #include "chromeos/network/network_util.h"
46 #include "chromeos/network/onc/onc_signature.h" 48 #include "chromeos/network/onc/onc_signature.h"
47 #include "chromeos/network/onc/onc_translation_tables.h" 49 #include "chromeos/network/onc/onc_translation_tables.h"
48 #include "chromeos/network/onc/onc_translator.h" 50 #include "chromeos/network/onc/onc_translator.h"
49 #include "chromeos/network/onc/onc_utils.h" 51 #include "chromeos/network/onc/onc_utils.h"
50 #include "components/onc/onc_constants.h" 52 #include "components/onc/onc_constants.h"
53 #include "components/user_manager/user_manager.h"
51 #include "content/public/browser/web_contents.h" 54 #include "content/public/browser/web_contents.h"
52 #include "content/public/browser/web_ui.h" 55 #include "content/public/browser/web_ui.h"
56 #include "extensions/browser/api/vpn_provider/vpn_service.h"
57 #include "extensions/browser/api/vpn_provider/vpn_service_factory.h"
58 #include "extensions/browser/extension_registry.h"
59 #include "extensions/common/extension.h"
60 #include "extensions/common/extension_set.h"
61 #include "extensions/common/permissions/api_permission.h"
62 #include "extensions/common/permissions/permissions_data.h"
53 #include "third_party/cros_system_api/dbus/service_constants.h" 63 #include "third_party/cros_system_api/dbus/service_constants.h"
64 #include "ui/base/l10n/l10n_util.h"
54 #include "ui/base/webui/web_ui_util.h" 65 #include "ui/base/webui/web_ui_util.h"
55 #include "ui/chromeos/network/network_connect.h" 66 #include "ui/chromeos/network/network_connect.h"
67 #include "ui/chromeos/strings/grit/ui_chromeos_strings.h"
56 68
57 namespace chromeos { 69 namespace chromeos {
58 namespace options { 70 namespace options {
59 71
60 namespace { 72 namespace {
61 73
62 // Keys for the initial "localized" dictionary values. 74 // Keys for the initial "localized" dictionary values.
63 const char kLoggedInAsOwnerKey[] = "loggedInAsOwner"; 75 const char kLoggedInAsOwnerKey[] = "loggedInAsOwner";
64 const char kShowCarrierSelectKey[] = "showCarrierSelect"; 76 const char kShowCarrierSelectKey[] = "showCarrierSelect";
65 const char kNetworkDataKey[] = "networkData"; 77 const char kNetworkDataKey[] = "networkData";
66 78
67 // Keys for the network description dictionary passed to the web ui. Make sure 79 // 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. 80 // to keep the strings in sync with what the JavaScript side uses.
69 const char kNetworkInfoKeyPolicyManaged[] = "policyManaged"; 81 const char kNetworkInfoKeyPolicyManaged[] = "policyManaged";
70 82
71 // Functions we call in JavaScript. 83 // Functions we call in JavaScript.
84 const char kSetVPNProvidersFunction[] = "options.VPNProviders.setProviders";
72 const char kRefreshNetworkDataFunction[] = 85 const char kRefreshNetworkDataFunction[] =
73 "options.network.NetworkList.refreshNetworkData"; 86 "options.network.NetworkList.refreshNetworkData";
74 const char kUpdateConnectionDataFunction[] = 87 const char kUpdateConnectionDataFunction[] =
75 "options.internet.DetailsInternetPage.updateConnectionData"; 88 "options.internet.DetailsInternetPage.updateConnectionData";
76 const char kUpdateCarrierFunction[] = 89 const char kUpdateCarrierFunction[] =
77 "options.internet.DetailsInternetPage.updateCarrier"; 90 "options.internet.DetailsInternetPage.updateCarrier";
78 91
79 // Setter methods called from JS that still need to be converted to match 92 // Setter methods called from JS that still need to be converted to match
80 // networkingPrivate methods. 93 // networkingPrivate methods.
81 const char kSetCarrierMessage[] = "setCarrier"; 94 const char kSetCarrierMessage[] = "setCarrier";
82 const char kShowMorePlanInfoMessage[] = "showMorePlanInfo"; 95 const char kShowMorePlanInfoMessage[] = "showMorePlanInfo";
83 const char kSimOperationMessage[] = "simOperation"; 96 const char kSimOperationMessage[] = "simOperation";
97 const char kUpdateVPNProviders[] = "updateVPNProviders";
84 98
85 // TODO(stevenjb): Replace these with the matching networkingPrivate methods. 99 // TODO(stevenjb): Replace these with the matching networkingPrivate methods.
86 // crbug.com/279351. 100 // crbug.com/279351.
87 const char kStartConnectMessage[] = "startConnect"; 101 const char kStartConnectMessage[] = "startConnect";
88 102
89 // TODO(stevenjb): Deprecate this once we handle events in the JS. 103 // TODO(stevenjb): Deprecate this once we handle events in the JS.
90 const char kSetNetworkGuidMessage[] = "setNetworkGuid"; 104 const char kSetNetworkGuidMessage[] = "setNetworkGuid";
91 105
92 // TODO(stevenjb): Add these to networkingPrivate. 106 // TODO(stevenjb): Add these to networkingPrivate.
93 const char kRemoveNetworkMessage[] = "removeNetwork"; 107 const char kRemoveNetworkMessage[] = "removeNetwork";
94 108
95 // TODO(stevenjb): Deprecate these and integrate with settings Web UI. 109 // TODO(stevenjb): Deprecate these and integrate with settings Web UI.
96 const char kAddConnectionMessage[] = "addConnection"; 110 const char kAddConnectionMessage[] = "addConnection";
97 const char kConfigureNetworkMessage[] = "configureNetwork"; 111 const char kConfigureNetworkMessage[] = "configureNetwork";
98 const char kActivateNetworkMessage[] = "activateNetwork"; 112 const char kActivateNetworkMessage[] = "activateNetwork";
99 113
100 // These are strings used to communicate with JavaScript. 114 // These are strings used to communicate with JavaScript.
101 const char kTagCellularAvailable[] = "cellularAvailable"; 115 const char kTagCellularAvailable[] = "cellularAvailable";
102 const char kTagCellularEnabled[] = "cellularEnabled"; 116 const char kTagCellularEnabled[] = "cellularEnabled";
103 const char kTagCellularSimAbsent[] = "cellularSimAbsent"; 117 const char kTagCellularSimAbsent[] = "cellularSimAbsent";
104 const char kTagCellularSimLockType[] = "cellularSimLockType"; 118 const char kTagCellularSimLockType[] = "cellularSimLockType";
105 const char kTagCellularSupportsScan[] = "cellularSupportsScan"; 119 const char kTagCellularSupportsScan[] = "cellularSupportsScan";
106 const char kTagRememberedList[] = "rememberedList"; 120 const char kTagRememberedList[] = "rememberedList";
107 const char kTagSimOpChangePin[] = "changePin"; 121 const char kTagSimOpChangePin[] = "changePin";
108 const char kTagSimOpConfigure[] = "configure"; 122 const char kTagSimOpConfigure[] = "configure";
109 const char kTagSimOpSetLocked[] = "setLocked"; 123 const char kTagSimOpSetLocked[] = "setLocked";
110 const char kTagSimOpSetUnlocked[] = "setUnlocked"; 124 const char kTagSimOpSetUnlocked[] = "setUnlocked";
111 const char kTagSimOpUnlock[] = "unlock"; 125 const char kTagSimOpUnlock[] = "unlock";
126 const char kTagVPNProviderName[] = "name";
127 const char kTagVPNProviderExtensionID[] = "extensionID";
112 const char kTagVpnList[] = "vpnList"; 128 const char kTagVpnList[] = "vpnList";
113 const char kTagWifiAvailable[] = "wifiAvailable"; 129 const char kTagWifiAvailable[] = "wifiAvailable";
114 const char kTagWifiEnabled[] = "wifiEnabled"; 130 const char kTagWifiEnabled[] = "wifiEnabled";
115 const char kTagWimaxAvailable[] = "wimaxAvailable"; 131 const char kTagWimaxAvailable[] = "wimaxAvailable";
116 const char kTagWimaxEnabled[] = "wimaxEnabled"; 132 const char kTagWimaxEnabled[] = "wimaxEnabled";
117 const char kTagWiredList[] = "wiredList"; 133 const char kTagWiredList[] = "wiredList";
118 const char kTagWirelessList[] = "wirelessList"; 134 const char kTagWirelessList[] = "wirelessList";
119 135
120 // Pseudo-ONC chrome specific properties appended to the ONC dictionary. 136 // Pseudo-ONC chrome specific properties appended to the ONC dictionary.
121 const char kTagShowViewAccountButton[] = "showViewAccountButton"; 137 const char kTagShowViewAccountButton[] = "showViewAccountButton";
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 device->properties().GetStringWithoutPathExpansion(shill::kMdnProperty, 211 device->properties().GetStringWithoutPathExpansion(shill::kMdnProperty,
196 &mdn); 212 &mdn);
197 } 213 }
198 if (mdn.empty()) 214 if (mdn.empty())
199 return false; 215 return false;
200 } 216 }
201 217
202 return true; 218 return true;
203 } 219 }
204 220
221 bool IsVPNProvider(const extensions::Extension* extension) {
222 return extension->permissions_data()->HasAPIPermission(
223 extensions::APIPermission::kVpnProvider);
224 }
225
226 Profile* GetProfileForPrimaryUser() {
227 return chromeos::ProfileHelper::Get()->GetProfileByUser(
228 user_manager::UserManager::Get()->GetPrimaryUser());
229 }
230
231 extensions::ExtensionRegistry* GetExtensionRegistryForPrimaryUser() {
232 return extensions::ExtensionRegistry::Get(GetProfileForPrimaryUser());
233 }
234
235 scoped_ptr<base::DictionaryValue> BuildVPNProviderDictionary(
236 const std::string& name,
237 const std::string& third_party_provider_extension_id) {
238 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
239 dict->SetString(kTagVPNProviderName, name);
240 if (!third_party_provider_extension_id.empty()) {
241 dict->SetString(kTagVPNProviderExtensionID,
242 third_party_provider_extension_id);
243 }
244 return dict.Pass();
245 }
246
205 } // namespace 247 } // namespace
206 248
207 InternetOptionsHandler::InternetOptionsHandler() 249 InternetOptionsHandler::InternetOptionsHandler()
208 : weak_factory_(this) { 250 : weak_factory_(this) {
251 GetExtensionRegistryForPrimaryUser()->AddObserver(this);
209 NetworkHandler::Get()->network_state_handler()->AddObserver(this, FROM_HERE); 252 NetworkHandler::Get()->network_state_handler()->AddObserver(this, FROM_HERE);
210 } 253 }
211 254
212 InternetOptionsHandler::~InternetOptionsHandler() { 255 InternetOptionsHandler::~InternetOptionsHandler() {
213 if (NetworkHandler::IsInitialized()) { 256 if (NetworkHandler::IsInitialized()) {
214 NetworkHandler::Get()->network_state_handler()->RemoveObserver( 257 NetworkHandler::Get()->network_state_handler()->RemoveObserver(
215 this, FROM_HERE); 258 this, FROM_HERE);
216 } 259 }
260 GetExtensionRegistryForPrimaryUser()->RemoveObserver(this);
217 } 261 }
218 262
219 void InternetOptionsHandler::GetLocalizedValues( 263 void InternetOptionsHandler::GetLocalizedValues(
220 base::DictionaryValue* localized_strings) { 264 base::DictionaryValue* localized_strings) {
221 DCHECK(localized_strings); 265 DCHECK(localized_strings);
222 internet_options_strings::RegisterLocalizedStrings(localized_strings); 266 internet_options_strings::RegisterLocalizedStrings(localized_strings);
223 267
224 // TODO(stevenjb): Find a better way to populate initial data before 268 // TODO(stevenjb): Find a better way to populate initial data before
225 // InitializePage() gets called. 269 // InitializePage() gets called.
226 std::string owner; 270 std::string owner;
227 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); 271 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner);
228 bool logged_in_as_owner = LoginState::Get()->GetLoggedInUserType() == 272 bool logged_in_as_owner = LoginState::Get()->GetLoggedInUserType() ==
229 LoginState::LOGGED_IN_USER_OWNER; 273 LoginState::LOGGED_IN_USER_OWNER;
230 localized_strings->SetBoolean(kLoggedInAsOwnerKey, logged_in_as_owner); 274 localized_strings->SetBoolean(kLoggedInAsOwnerKey, logged_in_as_owner);
231 localized_strings->SetBoolean( 275 localized_strings->SetBoolean(
232 kShowCarrierSelectKey, base::CommandLine::ForCurrentProcess()->HasSwitch( 276 kShowCarrierSelectKey, base::CommandLine::ForCurrentProcess()->HasSwitch(
233 chromeos::switches::kEnableCarrierSwitching)); 277 chromeos::switches::kEnableCarrierSwitching));
234 278
235 base::DictionaryValue* network_dictionary = new base::DictionaryValue; 279 base::DictionaryValue* network_dictionary = new base::DictionaryValue;
236 FillNetworkInfo(network_dictionary); 280 FillNetworkInfo(network_dictionary);
237 localized_strings->Set(kNetworkDataKey, network_dictionary); 281 localized_strings->Set(kNetworkDataKey, network_dictionary);
238 } 282 }
239 283
240 void InternetOptionsHandler::InitializePage() { 284 void InternetOptionsHandler::InitializePage() {
285 UpdateVPNProviders();
241 NetworkHandler::Get()->network_state_handler()->RequestScan(); 286 NetworkHandler::Get()->network_state_handler()->RequestScan();
242 RefreshNetworkData(); 287 RefreshNetworkData();
243 } 288 }
244 289
245 void InternetOptionsHandler::RegisterMessages() { 290 void InternetOptionsHandler::RegisterMessages() {
246 web_ui()->RegisterMessageCallback(kAddConnectionMessage, 291 web_ui()->RegisterMessageCallback(kAddConnectionMessage,
247 base::Bind(&InternetOptionsHandler::AddConnection, 292 base::Bind(&InternetOptionsHandler::AddConnection,
248 base::Unretained(this))); 293 base::Unretained(this)));
249 web_ui()->RegisterMessageCallback(kRemoveNetworkMessage, 294 web_ui()->RegisterMessageCallback(kRemoveNetworkMessage,
250 base::Bind(&InternetOptionsHandler::RemoveNetwork, 295 base::Bind(&InternetOptionsHandler::RemoveNetwork,
251 base::Unretained(this))); 296 base::Unretained(this)));
252 web_ui()->RegisterMessageCallback(kConfigureNetworkMessage, 297 web_ui()->RegisterMessageCallback(kConfigureNetworkMessage,
253 base::Bind(&InternetOptionsHandler::ConfigureNetwork, 298 base::Bind(&InternetOptionsHandler::ConfigureNetwork,
254 base::Unretained(this))); 299 base::Unretained(this)));
255 web_ui()->RegisterMessageCallback(kActivateNetworkMessage, 300 web_ui()->RegisterMessageCallback(kActivateNetworkMessage,
256 base::Bind(&InternetOptionsHandler::ActivateNetwork, 301 base::Bind(&InternetOptionsHandler::ActivateNetwork,
257 base::Unretained(this))); 302 base::Unretained(this)));
258 web_ui()->RegisterMessageCallback(kShowMorePlanInfoMessage, 303 web_ui()->RegisterMessageCallback(kShowMorePlanInfoMessage,
259 base::Bind(&InternetOptionsHandler::ShowMorePlanInfoCallback, 304 base::Bind(&InternetOptionsHandler::ShowMorePlanInfoCallback,
260 base::Unretained(this))); 305 base::Unretained(this)));
261 web_ui()->RegisterMessageCallback(kSetCarrierMessage, 306 web_ui()->RegisterMessageCallback(kSetCarrierMessage,
262 base::Bind(&InternetOptionsHandler::SetCarrierCallback, 307 base::Bind(&InternetOptionsHandler::SetCarrierCallback,
263 base::Unretained(this))); 308 base::Unretained(this)));
264 web_ui()->RegisterMessageCallback(kSimOperationMessage, 309 web_ui()->RegisterMessageCallback(kSimOperationMessage,
265 base::Bind(&InternetOptionsHandler::SimOperationCallback, 310 base::Bind(&InternetOptionsHandler::SimOperationCallback,
266 base::Unretained(this))); 311 base::Unretained(this)));
312 web_ui()->RegisterMessageCallback(
313 kUpdateVPNProviders,
314 base::Bind(&InternetOptionsHandler::UpdateVPNProvidersCallback,
315 base::Unretained(this)));
267 316
268 web_ui()->RegisterMessageCallback(kSetNetworkGuidMessage, 317 web_ui()->RegisterMessageCallback(kSetNetworkGuidMessage,
269 base::Bind(&InternetOptionsHandler::SetNetworkGuidCallback, 318 base::Bind(&InternetOptionsHandler::SetNetworkGuidCallback,
270 base::Unretained(this))); 319 base::Unretained(this)));
271 320
272 // networkingPrivate methods 321 // networkingPrivate methods
273 web_ui()->RegisterMessageCallback(kStartConnectMessage, 322 web_ui()->RegisterMessageCallback(kStartConnectMessage,
274 base::Bind(&InternetOptionsHandler::StartConnectCallback, 323 base::Bind(&InternetOptionsHandler::StartConnectCallback,
275 base::Unretained(this))); 324 base::Unretained(this)));
276 } 325 }
277 326
327 void InternetOptionsHandler::OnExtensionLoaded(
328 content::BrowserContext* browser_context,
329 const extensions::Extension* extension) {
330 if (IsVPNProvider(extension))
331 UpdateVPNProviders();
332 }
333
334 void InternetOptionsHandler::OnExtensionUnloaded(
335 content::BrowserContext* browser_context,
336 const extensions::Extension* extension,
337 extensions::UnloadedExtensionInfo::Reason reason) {
338 if (IsVPNProvider(extension))
339 UpdateVPNProviders();
340 }
341
342 void InternetOptionsHandler::OnShutdown(
343 extensions::ExtensionRegistry* registry) {
344 registry->RemoveObserver(this);
345 }
346
278 void InternetOptionsHandler::ShowMorePlanInfoCallback( 347 void InternetOptionsHandler::ShowMorePlanInfoCallback(
279 const base::ListValue* args) { 348 const base::ListValue* args) {
280 if (!web_ui()) 349 if (!web_ui())
281 return; 350 return;
282 std::string guid; 351 std::string guid;
283 if (args->GetSize() != 1 || !args->GetString(0, &guid)) { 352 if (args->GetSize() != 1 || !args->GetString(0, &guid)) {
284 NOTREACHED(); 353 NOTREACHED();
285 return; 354 return;
286 } 355 }
287 std::string service_path = ServicePathFromGuid(guid); 356 std::string service_path = ServicePathFromGuid(guid);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 mode = SimDialogDelegate::SIM_DIALOG_UNLOCK; 418 mode = SimDialogDelegate::SIM_DIALOG_UNLOCK;
350 } else if (operation == kTagSimOpChangePin) { 419 } else if (operation == kTagSimOpChangePin) {
351 mode = SimDialogDelegate::SIM_DIALOG_CHANGE_PIN; 420 mode = SimDialogDelegate::SIM_DIALOG_CHANGE_PIN;
352 } else { 421 } else {
353 NOTREACHED(); 422 NOTREACHED();
354 return; 423 return;
355 } 424 }
356 SimDialogDelegate::ShowDialog(GetNativeWindow(), mode); 425 SimDialogDelegate::ShowDialog(GetNativeWindow(), mode);
357 } 426 }
358 427
428 void InternetOptionsHandler::UpdateVPNProvidersCallback(
429 const base::ListValue* args) {
430 UpdateVPNProviders();
431 }
432
359 //////////////////////////////////////////////////////////////////////////////// 433 ////////////////////////////////////////////////////////////////////////////////
360 // TODO(stevenjb): Deprecate this once events are handled in the JS. 434 // TODO(stevenjb): Deprecate this once events are handled in the JS.
361 435
362 void InternetOptionsHandler::SetNetworkGuidCallback( 436 void InternetOptionsHandler::SetNetworkGuidCallback(
363 const base::ListValue* args) { 437 const base::ListValue* args) {
364 std::string guid; 438 std::string guid;
365 if (args->GetSize() != 1 || !args->GetString(0, &guid)) { 439 if (args->GetSize() != 1 || !args->GetString(0, &guid)) {
366 NOTREACHED(); 440 NOTREACHED();
367 return; 441 return;
368 } 442 }
(...skipping 12 matching lines...) Expand all
381 NOTREACHED(); 455 NOTREACHED();
382 return; 456 return;
383 } 457 }
384 std::string service_path = ServicePathFromGuid(guid); 458 std::string service_path = ServicePathFromGuid(guid);
385 if (!service_path.empty()) 459 if (!service_path.empty())
386 ui::NetworkConnect::Get()->ConnectToNetwork(service_path); 460 ui::NetworkConnect::Get()->ConnectToNetwork(service_path);
387 } 461 }
388 462
389 //////////////////////////////////////////////////////////////////////////////// 463 ////////////////////////////////////////////////////////////////////////////////
390 464
465 void InternetOptionsHandler::UpdateVPNProviders() {
466 extensions::ExtensionRegistry* const registry =
467 GetExtensionRegistryForPrimaryUser();
468
469 base::ListValue vpn_providers;
470 const extensions::ExtensionSet& extensions = registry->enabled_extensions();
471 for (const auto& extension : extensions) {
472 if (IsVPNProvider(extension.get()))
pneubeck (no reviews) 2015/03/18 20:41:30 nit: missing {}
bartfab (slow) 2015/03/18 21:10:48 Done.
473 vpn_providers.Append(BuildVPNProviderDictionary(
474 extension->name(), extension->id()).release());
475 }
476 // Add the built-in OpenVPN/L2TP provider.
477 vpn_providers.Append(
478 BuildVPNProviderDictionary(
pneubeck (no reviews) 2015/03/18 20:41:30 still required?
bartfab (slow) 2015/03/18 21:10:48 Yes, CL 1017443002 will require the full list of a
479 l10n_util::GetStringUTF8(IDS_NETWORK_VPN_BUILT_IN_PROVIDER),
480 std::string() /* third_party_provider_extension_id */).release());
481 web_ui()->CallJavascriptFunction(kSetVPNProvidersFunction, vpn_providers);
482 }
483
391 void InternetOptionsHandler::RefreshNetworkData() { 484 void InternetOptionsHandler::RefreshNetworkData() {
392 base::DictionaryValue dictionary; 485 base::DictionaryValue dictionary;
393 FillNetworkInfo(&dictionary); 486 FillNetworkInfo(&dictionary);
394 web_ui()->CallJavascriptFunction(kRefreshNetworkDataFunction, dictionary); 487 web_ui()->CallJavascriptFunction(kRefreshNetworkDataFunction, dictionary);
395 } 488 }
396 489
397 void InternetOptionsHandler::UpdateConnectionData( 490 void InternetOptionsHandler::UpdateConnectionData(
398 const std::string& service_path) { 491 const std::string& service_path) {
399 NetworkHandler::Get() 492 NetworkHandler::Get()
400 ->managed_network_configuration_handler() 493 ->managed_network_configuration_handler()
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 LOG(ERROR) << "Unsupported type for AddConnection"; 584 LOG(ERROR) << "Unsupported type for AddConnection";
492 } 585 }
493 } 586 }
494 587
495 void InternetOptionsHandler::ConfigureNetwork(const base::ListValue* args) { 588 void InternetOptionsHandler::ConfigureNetwork(const base::ListValue* args) {
496 std::string guid; 589 std::string guid;
497 if (args->GetSize() != 1 || !args->GetString(0, &guid)) { 590 if (args->GetSize() != 1 || !args->GetString(0, &guid)) {
498 NOTREACHED(); 591 NOTREACHED();
499 return; 592 return;
500 } 593 }
501 std::string service_path = ServicePathFromGuid(guid); 594 const std::string service_path = ServicePathFromGuid(guid);
502 if (!service_path.empty()) 595 if (service_path.empty())
503 NetworkConfigView::Show(service_path, GetNativeWindow()); 596 return;
597
598 const NetworkState* network = GetNetworkState(service_path);
599 if (!network)
600 return;
601
602 if (network->type() == shill::kTypeVPN &&
603 network->vpn_provider_type() == shill::kProviderThirdPartyVpn) {
604 // Request that the third-party VPN provider used by the |network| show a
605 // configuration dialog for it.
606 VpnServiceFactory::GetForBrowserContext(GetProfileForPrimaryUser())
607 ->SendShowConfigureDialogToExtension(
608 network->third_party_vpn_provider_extension_id(), network->name());
609 return;
610 }
611
612 NetworkConfigView::Show(service_path, GetNativeWindow());
504 } 613 }
505 614
506 void InternetOptionsHandler::ActivateNetwork(const base::ListValue* args) { 615 void InternetOptionsHandler::ActivateNetwork(const base::ListValue* args) {
507 std::string guid; 616 std::string guid;
508 if (args->GetSize() != 1 || !args->GetString(0, &guid)) { 617 if (args->GetSize() != 1 || !args->GetString(0, &guid)) {
509 NOTREACHED(); 618 NOTREACHED();
510 return; 619 return;
511 } 620 }
512 std::string service_path = ServicePathFromGuid(guid); 621 std::string service_path = ServicePathFromGuid(guid);
513 if (!service_path.empty()) 622 if (!service_path.empty())
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 dictionary->SetBoolean( 732 dictionary->SetBoolean(
624 kTagWimaxAvailable, 733 kTagWimaxAvailable,
625 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); 734 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax()));
626 dictionary->SetBoolean( 735 dictionary->SetBoolean(
627 kTagWimaxEnabled, 736 kTagWimaxEnabled,
628 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); 737 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax()));
629 } 738 }
630 739
631 } // namespace options 740 } // namespace options
632 } // namespace chromeos 741 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698