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

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

Issue 1017443002: Allow users to add third-party VPNs from the settings page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@f_3_460428_update_details_dialog
Patch Set: 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>
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // crbug.com/279351. 99 // crbug.com/279351.
100 const char kStartConnectMessage[] = "startConnect"; 100 const char kStartConnectMessage[] = "startConnect";
101 101
102 // TODO(stevenjb): Deprecate this once we handle events in the JS. 102 // TODO(stevenjb): Deprecate this once we handle events in the JS.
103 const char kSetNetworkGuidMessage[] = "setNetworkGuid"; 103 const char kSetNetworkGuidMessage[] = "setNetworkGuid";
104 104
105 // TODO(stevenjb): Add these to networkingPrivate. 105 // TODO(stevenjb): Add these to networkingPrivate.
106 const char kRemoveNetworkMessage[] = "removeNetwork"; 106 const char kRemoveNetworkMessage[] = "removeNetwork";
107 107
108 // TODO(stevenjb): Deprecate these and integrate with settings Web UI. 108 // TODO(stevenjb): Deprecate these and integrate with settings Web UI.
109 const char kAddConnectionMessage[] = "addConnection"; 109 const char kAddVPNConnectionMessage[] = "addVPNConnection";
110 const char kAddNonVPNConnectionMessage[] = "addNonVPNConnection";
110 const char kConfigureNetworkMessage[] = "configureNetwork"; 111 const char kConfigureNetworkMessage[] = "configureNetwork";
111 const char kActivateNetworkMessage[] = "activateNetwork"; 112 const char kActivateNetworkMessage[] = "activateNetwork";
112 113
113 // These are strings used to communicate with JavaScript. 114 // These are strings used to communicate with JavaScript.
114 const char kTagCellularAvailable[] = "cellularAvailable"; 115 const char kTagCellularAvailable[] = "cellularAvailable";
115 const char kTagCellularEnabled[] = "cellularEnabled"; 116 const char kTagCellularEnabled[] = "cellularEnabled";
116 const char kTagCellularSimAbsent[] = "cellularSimAbsent"; 117 const char kTagCellularSimAbsent[] = "cellularSimAbsent";
117 const char kTagCellularSimLockType[] = "cellularSimLockType"; 118 const char kTagCellularSimLockType[] = "cellularSimLockType";
118 const char kTagCellularSupportsScan[] = "cellularSupportsScan"; 119 const char kTagCellularSupportsScan[] = "cellularSupportsScan";
119 const char kTagRememberedList[] = "rememberedList"; 120 const char kTagRememberedList[] = "rememberedList";
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 localized_strings->Set(kNetworkDataKey, network_dictionary); 279 localized_strings->Set(kNetworkDataKey, network_dictionary);
279 } 280 }
280 281
281 void InternetOptionsHandler::InitializePage() { 282 void InternetOptionsHandler::InitializePage() {
282 UpdateVPNProviders(); 283 UpdateVPNProviders();
283 NetworkHandler::Get()->network_state_handler()->RequestScan(); 284 NetworkHandler::Get()->network_state_handler()->RequestScan();
284 RefreshNetworkData(); 285 RefreshNetworkData();
285 } 286 }
286 287
287 void InternetOptionsHandler::RegisterMessages() { 288 void InternetOptionsHandler::RegisterMessages() {
288 web_ui()->RegisterMessageCallback(kAddConnectionMessage, 289 web_ui()->RegisterMessageCallback(kAddVPNConnectionMessage,
289 base::Bind(&InternetOptionsHandler::AddConnection, 290 base::Bind(&InternetOptionsHandler::AddVPNConnection,
291 base::Unretained(this)));
292 web_ui()->RegisterMessageCallback(kAddNonVPNConnectionMessage,
293 base::Bind(&InternetOptionsHandler::AddNonVPNConnection,
290 base::Unretained(this))); 294 base::Unretained(this)));
291 web_ui()->RegisterMessageCallback(kRemoveNetworkMessage, 295 web_ui()->RegisterMessageCallback(kRemoveNetworkMessage,
292 base::Bind(&InternetOptionsHandler::RemoveNetwork, 296 base::Bind(&InternetOptionsHandler::RemoveNetwork,
293 base::Unretained(this))); 297 base::Unretained(this)));
294 web_ui()->RegisterMessageCallback(kConfigureNetworkMessage, 298 web_ui()->RegisterMessageCallback(kConfigureNetworkMessage,
295 base::Bind(&InternetOptionsHandler::ConfigureNetwork, 299 base::Bind(&InternetOptionsHandler::ConfigureNetwork,
296 base::Unretained(this))); 300 base::Unretained(this)));
297 web_ui()->RegisterMessageCallback(kActivateNetworkMessage, 301 web_ui()->RegisterMessageCallback(kActivateNetworkMessage,
298 base::Bind(&InternetOptionsHandler::ActivateNetwork, 302 base::Bind(&InternetOptionsHandler::ActivateNetwork,
299 base::Unretained(this))); 303 base::Unretained(this)));
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 } 557 }
554 558
555 gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const { 559 gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const {
556 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); 560 return web_ui()->GetWebContents()->GetTopLevelNativeWindow();
557 } 561 }
558 562
559 const PrefService* InternetOptionsHandler::GetPrefs() const { 563 const PrefService* InternetOptionsHandler::GetPrefs() const {
560 return Profile::FromWebUI(web_ui())->GetPrefs(); 564 return Profile::FromWebUI(web_ui())->GetPrefs();
561 } 565 }
562 566
563 void InternetOptionsHandler::AddConnection(const base::ListValue* args) { 567
568 void InternetOptionsHandler::AddVPNConnection(const base::ListValue* args) {
569 std::string provider_id;
570 if (args->GetSize() != 1 || !args->GetString(0, &provider_id)) {
571 NOTREACHED();
572 return;
573 }
574
575 if (provider_id == kBuiltInVPNProviderID) {
576 // Show the "add network" dialog for the built-in OpenVPN/L2TP provider.
577 NetworkConfigView::ShowForType(shill::kTypeVPN, GetNativeWindow());
578 } else {
579 // Request that the third-party VPN provider identified by |provider_id|
580 // show its "add network" dialog.
581 chromeos::VpnServiceFactory::GetForBrowserContext(
582 GetProfileForPrimaryUser())->SendShowAddDialogToExtension(provider_id);
583 }
584 }
585
586 void InternetOptionsHandler::AddNonVPNConnection(const base::ListValue* args) {
564 std::string onc_type; 587 std::string onc_type;
565 if (args->GetSize() != 1 || !args->GetString(0, &onc_type)) { 588 if (args->GetSize() != 1 || !args->GetString(0, &onc_type)) {
566 NOTREACHED(); 589 NOTREACHED();
567 return; 590 return;
568 } 591 }
569 if (onc_type == ::onc::network_type::kWiFi) { 592 if (onc_type == ::onc::network_type::kWiFi) {
570 NetworkConfigView::ShowForType(shill::kTypeWifi, GetNativeWindow()); 593 NetworkConfigView::ShowForType(shill::kTypeWifi, GetNativeWindow());
571 } else if (onc_type == ::onc::network_type::kVPN) {
572 NetworkConfigView::ShowForType(shill::kTypeVPN, GetNativeWindow());
573 } else if (onc_type == ::onc::network_type::kCellular) { 594 } else if (onc_type == ::onc::network_type::kCellular) {
574 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow()); 595 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow());
575 } else { 596 } else {
576 LOG(ERROR) << "Unsupported type for AddConnection"; 597 LOG(ERROR) << "Unsupported type for AddConnection";
577 } 598 }
578 } 599 }
579 600
580 void InternetOptionsHandler::ConfigureNetwork(const base::ListValue* args) { 601 void InternetOptionsHandler::ConfigureNetwork(const base::ListValue* args) {
581 std::string guid; 602 std::string guid;
582 if (args->GetSize() != 1 || !args->GetString(0, &guid)) { 603 if (args->GetSize() != 1 || !args->GetString(0, &guid)) {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 dictionary->SetBoolean( 745 dictionary->SetBoolean(
725 kTagWimaxAvailable, 746 kTagWimaxAvailable,
726 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); 747 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax()));
727 dictionary->SetBoolean( 748 dictionary->SetBoolean(
728 kTagWimaxEnabled, 749 kTagWimaxEnabled,
729 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); 750 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax()));
730 } 751 }
731 752
732 } // namespace options 753 } // namespace options
733 } // namespace chromeos 754 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698