| 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 kAddVPNConnectionMessage[] = "addVPNConnection"; | 109 const char kAddConnectionMessage[] = "addConnection"; | 
| 110 const char kAddNonVPNConnectionMessage[] = "addNonVPNConnection"; |  | 
| 111 const char kConfigureNetworkMessage[] = "configureNetwork"; | 110 const char kConfigureNetworkMessage[] = "configureNetwork"; | 
| 112 const char kActivateNetworkMessage[] = "activateNetwork"; | 111 const char kActivateNetworkMessage[] = "activateNetwork"; | 
| 113 | 112 | 
| 114 const char kLoadVPNProviders[] = "loadVPNProviders"; | 113 const char kLoadVPNProviders[] = "loadVPNProviders"; | 
| 115 | 114 | 
| 116 // These are strings used to communicate with JavaScript. | 115 // These are strings used to communicate with JavaScript. | 
| 117 const char kTagCellularAvailable[] = "cellularAvailable"; | 116 const char kTagCellularAvailable[] = "cellularAvailable"; | 
| 118 const char kTagCellularEnabled[] = "cellularEnabled"; | 117 const char kTagCellularEnabled[] = "cellularEnabled"; | 
| 119 const char kTagCellularSimAbsent[] = "cellularSimAbsent"; | 118 const char kTagCellularSimAbsent[] = "cellularSimAbsent"; | 
| 120 const char kTagCellularSimLockType[] = "cellularSimLockType"; | 119 const char kTagCellularSimLockType[] = "cellularSimLockType"; | 
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 283   localized_strings->Set(kNetworkDataKey, network_dictionary); | 282   localized_strings->Set(kNetworkDataKey, network_dictionary); | 
| 284 } | 283 } | 
| 285 | 284 | 
| 286 void InternetOptionsHandler::InitializePage() { | 285 void InternetOptionsHandler::InitializePage() { | 
| 287   UpdateVPNProviders(); | 286   UpdateVPNProviders(); | 
| 288   NetworkHandler::Get()->network_state_handler()->RequestScan(); | 287   NetworkHandler::Get()->network_state_handler()->RequestScan(); | 
| 289   RefreshNetworkData(); | 288   RefreshNetworkData(); | 
| 290 } | 289 } | 
| 291 | 290 | 
| 292 void InternetOptionsHandler::RegisterMessages() { | 291 void InternetOptionsHandler::RegisterMessages() { | 
| 293   web_ui()->RegisterMessageCallback(kAddVPNConnectionMessage, | 292   web_ui()->RegisterMessageCallback(kAddConnectionMessage, | 
| 294       base::Bind(&InternetOptionsHandler::AddVPNConnection, | 293       base::Bind(&InternetOptionsHandler::AddConnection, | 
| 295                  base::Unretained(this))); |  | 
| 296   web_ui()->RegisterMessageCallback(kAddNonVPNConnectionMessage, |  | 
| 297       base::Bind(&InternetOptionsHandler::AddNonVPNConnection, |  | 
| 298                  base::Unretained(this))); | 294                  base::Unretained(this))); | 
| 299   web_ui()->RegisterMessageCallback(kRemoveNetworkMessage, | 295   web_ui()->RegisterMessageCallback(kRemoveNetworkMessage, | 
| 300       base::Bind(&InternetOptionsHandler::RemoveNetwork, | 296       base::Bind(&InternetOptionsHandler::RemoveNetwork, | 
| 301                  base::Unretained(this))); | 297                  base::Unretained(this))); | 
| 302   web_ui()->RegisterMessageCallback(kConfigureNetworkMessage, | 298   web_ui()->RegisterMessageCallback(kConfigureNetworkMessage, | 
| 303       base::Bind(&InternetOptionsHandler::ConfigureNetwork, | 299       base::Bind(&InternetOptionsHandler::ConfigureNetwork, | 
| 304                  base::Unretained(this))); | 300                  base::Unretained(this))); | 
| 305   web_ui()->RegisterMessageCallback(kActivateNetworkMessage, | 301   web_ui()->RegisterMessageCallback(kActivateNetworkMessage, | 
| 306       base::Bind(&InternetOptionsHandler::ActivateNetwork, | 302       base::Bind(&InternetOptionsHandler::ActivateNetwork, | 
| 307                  base::Unretained(this))); | 303                  base::Unretained(this))); | 
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 562 } | 558 } | 
| 563 | 559 | 
| 564 gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const { | 560 gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const { | 
| 565   return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); | 561   return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); | 
| 566 } | 562 } | 
| 567 | 563 | 
| 568 const PrefService* InternetOptionsHandler::GetPrefs() const { | 564 const PrefService* InternetOptionsHandler::GetPrefs() const { | 
| 569   return Profile::FromWebUI(web_ui())->GetPrefs(); | 565   return Profile::FromWebUI(web_ui())->GetPrefs(); | 
| 570 } | 566 } | 
| 571 | 567 | 
| 572 | 568 void InternetOptionsHandler::AddConnection(const base::ListValue* args) { | 
| 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) { |  | 
| 593   std::string onc_type; | 569   std::string onc_type; | 
| 594   if (args->GetSize() != 1 || !args->GetString(0, &onc_type)) { | 570   if (args->GetSize() != 1 || !args->GetString(0, &onc_type)) { | 
| 595     NOTREACHED(); | 571     NOTREACHED(); | 
| 596     return; | 572     return; | 
| 597   } | 573   } | 
| 598   if (onc_type == ::onc::network_type::kWiFi) { | 574   if (onc_type == ::onc::network_type::kWiFi) { | 
| 599     NetworkConfigView::ShowForType(shill::kTypeWifi, GetNativeWindow()); | 575     NetworkConfigView::ShowForType(shill::kTypeWifi, GetNativeWindow()); | 
|  | 576   } else if (onc_type == ::onc::network_type::kVPN) { | 
|  | 577     NetworkConfigView::ShowForType(shill::kTypeVPN, GetNativeWindow()); | 
| 600   } else if (onc_type == ::onc::network_type::kCellular) { | 578   } else if (onc_type == ::onc::network_type::kCellular) { | 
| 601     ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow()); | 579     ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow()); | 
| 602   } else { | 580   } else { | 
| 603     LOG(ERROR) << "Unsupported type for AddConnection"; | 581     LOG(ERROR) << "Unsupported type for AddConnection"; | 
| 604   } | 582   } | 
| 605 } | 583 } | 
| 606 | 584 | 
| 607 void InternetOptionsHandler::ConfigureNetwork(const base::ListValue* args) { | 585 void InternetOptionsHandler::ConfigureNetwork(const base::ListValue* args) { | 
| 608   std::string guid; | 586   std::string guid; | 
| 609   if (args->GetSize() != 1 || !args->GetString(0, &guid)) { | 587   if (args->GetSize() != 1 || !args->GetString(0, &guid)) { | 
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 756   dictionary->SetBoolean( | 734   dictionary->SetBoolean( | 
| 757       kTagWimaxAvailable, | 735       kTagWimaxAvailable, | 
| 758       handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); | 736       handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); | 
| 759   dictionary->SetBoolean( | 737   dictionary->SetBoolean( | 
| 760       kTagWimaxEnabled, | 738       kTagWimaxEnabled, | 
| 761       handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); | 739       handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); | 
| 762 } | 740 } | 
| 763 | 741 | 
| 764 }  // namespace options | 742 }  // namespace options | 
| 765 }  // namespace chromeos | 743 }  // namespace chromeos | 
| OLD | NEW | 
|---|