 Chromium Code Reviews
 Chromium Code Reviews 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
    
  
    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| OLD | NEW | 
|---|---|
| 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 Loading... | |
| 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 const char kLoadVPNProviders[] = "loadVPNProviders"; | 114 const char kLoadVPNProviders[] = "loadVPNProviders"; | 
| 114 | 115 | 
| 115 // These are strings used to communicate with JavaScript. | 116 // These are strings used to communicate with JavaScript. | 
| 116 const char kTagCellularAvailable[] = "cellularAvailable"; | 117 const char kTagCellularAvailable[] = "cellularAvailable"; | 
| 117 const char kTagCellularEnabled[] = "cellularEnabled"; | 118 const char kTagCellularEnabled[] = "cellularEnabled"; | 
| 118 const char kTagCellularSimAbsent[] = "cellularSimAbsent"; | 119 const char kTagCellularSimAbsent[] = "cellularSimAbsent"; | 
| 119 const char kTagCellularSimLockType[] = "cellularSimLockType"; | 120 const char kTagCellularSimLockType[] = "cellularSimLockType"; | 
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 localized_strings->Set(kNetworkDataKey, network_dictionary); | 283 localized_strings->Set(kNetworkDataKey, network_dictionary); | 
| 283 } | 284 } | 
| 284 | 285 | 
| 285 void InternetOptionsHandler::InitializePage() { | 286 void InternetOptionsHandler::InitializePage() { | 
| 286 UpdateVPNProviders(); | 287 UpdateVPNProviders(); | 
| 287 NetworkHandler::Get()->network_state_handler()->RequestScan(); | 288 NetworkHandler::Get()->network_state_handler()->RequestScan(); | 
| 288 RefreshNetworkData(); | 289 RefreshNetworkData(); | 
| 289 } | 290 } | 
| 290 | 291 | 
| 291 void InternetOptionsHandler::RegisterMessages() { | 292 void InternetOptionsHandler::RegisterMessages() { | 
| 292 web_ui()->RegisterMessageCallback(kAddConnectionMessage, | 293 web_ui()->RegisterMessageCallback(kAddVPNConnectionMessage, | 
| 293 base::Bind(&InternetOptionsHandler::AddConnection, | 294 base::Bind(&InternetOptionsHandler::AddVPNConnection, | 
| 295 base::Unretained(this))); | |
| 296 web_ui()->RegisterMessageCallback(kAddNonVPNConnectionMessage, | |
| 297 base::Bind(&InternetOptionsHandler::AddNonVPNConnection, | |
| 294 base::Unretained(this))); | 298 base::Unretained(this))); | 
| 295 web_ui()->RegisterMessageCallback(kRemoveNetworkMessage, | 299 web_ui()->RegisterMessageCallback(kRemoveNetworkMessage, | 
| 296 base::Bind(&InternetOptionsHandler::RemoveNetwork, | 300 base::Bind(&InternetOptionsHandler::RemoveNetwork, | 
| 297 base::Unretained(this))); | 301 base::Unretained(this))); | 
| 298 web_ui()->RegisterMessageCallback(kConfigureNetworkMessage, | 302 web_ui()->RegisterMessageCallback(kConfigureNetworkMessage, | 
| 299 base::Bind(&InternetOptionsHandler::ConfigureNetwork, | 303 base::Bind(&InternetOptionsHandler::ConfigureNetwork, | 
| 300 base::Unretained(this))); | 304 base::Unretained(this))); | 
| 301 web_ui()->RegisterMessageCallback(kActivateNetworkMessage, | 305 web_ui()->RegisterMessageCallback(kActivateNetworkMessage, | 
| 302 base::Bind(&InternetOptionsHandler::ActivateNetwork, | 306 base::Bind(&InternetOptionsHandler::ActivateNetwork, | 
| 303 base::Unretained(this))); | 307 base::Unretained(this))); | 
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 558 } | 562 } | 
| 559 | 563 | 
| 560 gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const { | 564 gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const { | 
| 561 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); | 565 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); | 
| 562 } | 566 } | 
| 563 | 567 | 
| 564 const PrefService* InternetOptionsHandler::GetPrefs() const { | 568 const PrefService* InternetOptionsHandler::GetPrefs() const { | 
| 565 return Profile::FromWebUI(web_ui())->GetPrefs(); | 569 return Profile::FromWebUI(web_ui())->GetPrefs(); | 
| 566 } | 570 } | 
| 567 | 571 | 
| 568 void InternetOptionsHandler::AddConnection(const base::ListValue* args) { | 572 | 
| 573 void InternetOptionsHandler::AddVPNConnection(const base::ListValue* args) { | |
| 574 if (args->empty()) { | |
| 575 // Show the "add network" dialog for the built-in OpenVPN/L2TP provider. | |
| 576 NetworkConfigView::ShowForType(shill::kTypeVPN, GetNativeWindow()); | |
| 577 return; | |
| 578 } | |
| 579 | |
| 580 std::string extension_id; | |
| 581 if (args->GetSize() != 1 || !args->GetString(0, &extension_id)) { | |
| 582 NOTREACHED(); | |
| 583 return; | |
| 584 } | |
| 585 | |
| 586 // Request that the third-party VPN provider identified by |provider_id| | |
| 587 // show its "add network" dialog. | |
| 588 chromeos::VpnServiceFactory::GetForBrowserContext( | |
| 589 GetProfileForPrimaryUser())->SendShowAddDialogToExtension(extension_id); | |
| 590 } | |
| 591 | |
| 592 void InternetOptionsHandler::AddNonVPNConnection(const base::ListValue* args) { | |
| 
stevenjb
2015/03/19 16:02:02
I think I would have preferred leaving this functi
 
bartfab (slow)
2015/03/19 16:22:05
Acknowledged.
 | |
| 569 std::string onc_type; | 593 std::string onc_type; | 
| 570 if (args->GetSize() != 1 || !args->GetString(0, &onc_type)) { | 594 if (args->GetSize() != 1 || !args->GetString(0, &onc_type)) { | 
| 571 NOTREACHED(); | 595 NOTREACHED(); | 
| 572 return; | 596 return; | 
| 573 } | 597 } | 
| 574 if (onc_type == ::onc::network_type::kWiFi) { | 598 if (onc_type == ::onc::network_type::kWiFi) { | 
| 575 NetworkConfigView::ShowForType(shill::kTypeWifi, GetNativeWindow()); | 599 NetworkConfigView::ShowForType(shill::kTypeWifi, GetNativeWindow()); | 
| 576 } else if (onc_type == ::onc::network_type::kVPN) { | |
| 577 NetworkConfigView::ShowForType(shill::kTypeVPN, GetNativeWindow()); | |
| 578 } else if (onc_type == ::onc::network_type::kCellular) { | 600 } else if (onc_type == ::onc::network_type::kCellular) { | 
| 579 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow()); | 601 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow()); | 
| 580 } else { | 602 } else { | 
| 581 LOG(ERROR) << "Unsupported type for AddConnection"; | 603 LOG(ERROR) << "Unsupported type for AddConnection"; | 
| 582 } | 604 } | 
| 583 } | 605 } | 
| 584 | 606 | 
| 585 void InternetOptionsHandler::ConfigureNetwork(const base::ListValue* args) { | 607 void InternetOptionsHandler::ConfigureNetwork(const base::ListValue* args) { | 
| 586 std::string guid; | 608 std::string guid; | 
| 587 if (args->GetSize() != 1 || !args->GetString(0, &guid)) { | 609 if (args->GetSize() != 1 || !args->GetString(0, &guid)) { | 
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 734 dictionary->SetBoolean( | 756 dictionary->SetBoolean( | 
| 735 kTagWimaxAvailable, | 757 kTagWimaxAvailable, | 
| 736 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); | 758 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); | 
| 737 dictionary->SetBoolean( | 759 dictionary->SetBoolean( | 
| 738 kTagWimaxEnabled, | 760 kTagWimaxEnabled, | 
| 739 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); | 761 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); | 
| 740 } | 762 } | 
| 741 | 763 | 
| 742 } // namespace options | 764 } // namespace options | 
| 743 } // namespace chromeos | 765 } // namespace chromeos | 
| OLD | NEW |