| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "ash/system/chromeos/network/network_connect.h" |
| 13 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 14 #include "base/bind.h" | 15 #include "base/bind.h" |
| 15 #include "base/bind_helpers.h" | 16 #include "base/bind_helpers.h" |
| 16 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/values.h" | 19 #include "base/values.h" |
| 19 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/chromeos/mobile_config.h" | 21 #include "chrome/browser/chromeos/mobile_config.h" |
| 21 #include "chrome/browser/chromeos/net/onc_utils.h" | 22 #include "chrome/browser/chromeos/net/onc_utils.h" |
| 22 #include "chrome/browser/chromeos/options/network_config_view.h" | 23 #include "chrome/browser/chromeos/options/network_config_view.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 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" |
| 51 #include "content/public/browser/web_contents.h" | 52 #include "content/public/browser/web_contents.h" |
| 52 #include "content/public/browser/web_ui.h" | 53 #include "content/public/browser/web_ui.h" |
| 53 #include "grit/ui_chromeos_resources.h" | 54 #include "grit/ui_chromeos_resources.h" |
| 54 #include "third_party/cros_system_api/dbus/service_constants.h" | 55 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 55 #include "ui/base/resource/resource_bundle.h" | 56 #include "ui/base/resource/resource_bundle.h" |
| 56 #include "ui/base/webui/web_ui_util.h" | 57 #include "ui/base/webui/web_ui_util.h" |
| 57 #include "ui/chromeos/network/network_connect.h" | |
| 58 #include "ui/chromeos/network/network_icon.h" | 58 #include "ui/chromeos/network/network_icon.h" |
| 59 #include "ui/gfx/image/image_skia.h" | 59 #include "ui/gfx/image/image_skia.h" |
| 60 | 60 |
| 61 namespace chromeos { | 61 namespace chromeos { |
| 62 namespace options { | 62 namespace options { |
| 63 | 63 |
| 64 namespace { | 64 namespace { |
| 65 | 65 |
| 66 // Keys for the initial "localized" dictionary values. | 66 // Keys for the initial "localized" dictionary values. |
| 67 const char kLoggedInAsOwnerKey[] = "loggedInAsOwner"; | 67 const char kLoggedInAsOwnerKey[] = "loggedInAsOwner"; |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 | 388 |
| 389 void InternetOptionsHandler::ShowMorePlanInfoCallback( | 389 void InternetOptionsHandler::ShowMorePlanInfoCallback( |
| 390 const base::ListValue* args) { | 390 const base::ListValue* args) { |
| 391 if (!web_ui()) | 391 if (!web_ui()) |
| 392 return; | 392 return; |
| 393 std::string service_path; | 393 std::string service_path; |
| 394 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { | 394 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { |
| 395 NOTREACHED(); | 395 NOTREACHED(); |
| 396 return; | 396 return; |
| 397 } | 397 } |
| 398 ui::NetworkConnect::Get()->ShowMobileSetup(service_path); | 398 ash::NetworkConnect::Get()->ShowMobileSetup(service_path); |
| 399 } | 399 } |
| 400 | 400 |
| 401 void InternetOptionsHandler::SetApnCallback(const base::ListValue* args) { | 401 void InternetOptionsHandler::SetApnCallback(const base::ListValue* args) { |
| 402 std::string service_path; | 402 std::string service_path; |
| 403 if (!args->GetString(0, &service_path)) { | 403 if (!args->GetString(0, &service_path)) { |
| 404 NOTREACHED(); | 404 NOTREACHED(); |
| 405 return; | 405 return; |
| 406 } | 406 } |
| 407 NetworkHandler::Get()->network_configuration_handler()->GetProperties( | 407 NetworkHandler::Get()->network_configuration_handler()->GetProperties( |
| 408 service_path, | 408 service_path, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 } | 458 } |
| 459 | 459 |
| 460 void InternetOptionsHandler::CarrierStatusCallback() { | 460 void InternetOptionsHandler::CarrierStatusCallback() { |
| 461 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); | 461 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
| 462 const DeviceState* device = | 462 const DeviceState* device = |
| 463 handler->GetDeviceStateByType(NetworkTypePattern::Cellular()); | 463 handler->GetDeviceStateByType(NetworkTypePattern::Cellular()); |
| 464 if (device && (device->carrier() == shill::kCarrierSprint)) { | 464 if (device && (device->carrier() == shill::kCarrierSprint)) { |
| 465 const NetworkState* network = | 465 const NetworkState* network = |
| 466 handler->FirstNetworkByType(NetworkTypePattern::Cellular()); | 466 handler->FirstNetworkByType(NetworkTypePattern::Cellular()); |
| 467 if (network && network->path() == details_path_) { | 467 if (network && network->path() == details_path_) { |
| 468 ui::NetworkConnect::Get()->ActivateCellular(network->path()); | 468 ash::NetworkConnect::Get()->ActivateCellular(network->path()); |
| 469 UpdateConnectionData(network->path()); | 469 UpdateConnectionData(network->path()); |
| 470 } | 470 } |
| 471 } | 471 } |
| 472 UpdateCarrier(); | 472 UpdateCarrier(); |
| 473 } | 473 } |
| 474 | 474 |
| 475 void InternetOptionsHandler::SetCarrierCallback(const base::ListValue* args) { | 475 void InternetOptionsHandler::SetCarrierCallback(const base::ListValue* args) { |
| 476 std::string service_path; | 476 std::string service_path; |
| 477 std::string carrier; | 477 std::string carrier; |
| 478 if (args->GetSize() != 2 || | 478 if (args->GetSize() != 2 || |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 const base::ListValue* args) { | 580 const base::ListValue* args) { |
| 581 NetworkHandler::Get()->network_state_handler()->RequestScan(); | 581 NetworkHandler::Get()->network_state_handler()->RequestScan(); |
| 582 } | 582 } |
| 583 | 583 |
| 584 void InternetOptionsHandler::StartConnectCallback(const base::ListValue* args) { | 584 void InternetOptionsHandler::StartConnectCallback(const base::ListValue* args) { |
| 585 std::string service_path; | 585 std::string service_path; |
| 586 if (!args->GetString(0, &service_path)) { | 586 if (!args->GetString(0, &service_path)) { |
| 587 NOTREACHED(); | 587 NOTREACHED(); |
| 588 return; | 588 return; |
| 589 } | 589 } |
| 590 ui::NetworkConnect::Get()->ConnectToNetwork(service_path); | 590 ash::NetworkConnect::Get()->ConnectToNetwork(service_path); |
| 591 } | 591 } |
| 592 | 592 |
| 593 void InternetOptionsHandler::StartDisconnectCallback( | 593 void InternetOptionsHandler::StartDisconnectCallback( |
| 594 const base::ListValue* args) { | 594 const base::ListValue* args) { |
| 595 std::string service_path; | 595 std::string service_path; |
| 596 if (!args->GetString(0, &service_path)) { | 596 if (!args->GetString(0, &service_path)) { |
| 597 NOTREACHED(); | 597 NOTREACHED(); |
| 598 return; | 598 return; |
| 599 } | 599 } |
| 600 NetworkHandler::Get()->network_connection_handler()->DisconnectNetwork( | 600 NetworkHandler::Get()->network_connection_handler()->DisconnectNetwork( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 scoped_ptr<base::DictionaryValue> dictionary(onc_properties.DeepCopy()); | 637 scoped_ptr<base::DictionaryValue> dictionary(onc_properties.DeepCopy()); |
| 638 // Add service path for now. | 638 // Add service path for now. |
| 639 dictionary->SetString(kNetworkInfoKeyServicePath, service_path); | 639 dictionary->SetString(kNetworkInfoKeyServicePath, service_path); |
| 640 | 640 |
| 641 const NetworkState* network = GetNetworkState(service_path); | 641 const NetworkState* network = GetNetworkState(service_path); |
| 642 if (network) { | 642 if (network) { |
| 643 // Add a Chrome specific translated error message. TODO(stevenjb): Figure | 643 // Add a Chrome specific translated error message. TODO(stevenjb): Figure |
| 644 // out a more robust way to track errors. Service.Error is transient so we | 644 // out a more robust way to track errors. Service.Error is transient so we |
| 645 // use NetworkState.error() which accurately tracks the "last" error. | 645 // use NetworkState.error() which accurately tracks the "last" error. |
| 646 dictionary->SetString(kTagErrorMessage, | 646 dictionary->SetString(kTagErrorMessage, |
| 647 ui::NetworkConnect::Get()->GetErrorString( | 647 ash::NetworkConnect::Get()->GetErrorString( |
| 648 network->error(), service_path)); | 648 network->error(), service_path)); |
| 649 // Add additional non-ONC cellular properties to inform the UI. | 649 // Add additional non-ONC cellular properties to inform the UI. |
| 650 if (network->type() == shill::kTypeCellular) { | 650 if (network->type() == shill::kTypeCellular) { |
| 651 dictionary->SetBoolean(kTagShowViewAccountButton, | 651 dictionary->SetBoolean(kTagShowViewAccountButton, |
| 652 ShowViewAccountButton(network)); | 652 ShowViewAccountButton(network)); |
| 653 } | 653 } |
| 654 } | 654 } |
| 655 web_ui()->CallJavascriptFunction(js_callback_function, *dictionary); | 655 web_ui()->CallJavascriptFunction(js_callback_function, *dictionary); |
| 656 } | 656 } |
| 657 | 657 |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 } | 885 } |
| 886 NetworkConfigView::Show(service_path, GetNativeWindow()); | 886 NetworkConfigView::Show(service_path, GetNativeWindow()); |
| 887 } | 887 } |
| 888 | 888 |
| 889 void InternetOptionsHandler::ActivateNetwork(const base::ListValue* args) { | 889 void InternetOptionsHandler::ActivateNetwork(const base::ListValue* args) { |
| 890 std::string service_path; | 890 std::string service_path; |
| 891 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { | 891 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { |
| 892 NOTREACHED(); | 892 NOTREACHED(); |
| 893 return; | 893 return; |
| 894 } | 894 } |
| 895 ui::NetworkConnect::Get()->ActivateCellular(service_path); | 895 ash::NetworkConnect::Get()->ActivateCellular(service_path); |
| 896 } | 896 } |
| 897 | 897 |
| 898 void InternetOptionsHandler::RemoveNetwork(const base::ListValue* args) { | 898 void InternetOptionsHandler::RemoveNetwork(const base::ListValue* args) { |
| 899 std::string service_path; | 899 std::string service_path; |
| 900 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { | 900 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { |
| 901 NOTREACHED(); | 901 NOTREACHED(); |
| 902 return; | 902 return; |
| 903 } | 903 } |
| 904 NetworkHandler::Get() | 904 NetworkHandler::Get() |
| 905 ->managed_network_configuration_handler() | 905 ->managed_network_configuration_handler() |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 dictionary->SetBoolean( | 1003 dictionary->SetBoolean( |
| 1004 kTagWimaxAvailable, | 1004 kTagWimaxAvailable, |
| 1005 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); | 1005 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); |
| 1006 dictionary->SetBoolean( | 1006 dictionary->SetBoolean( |
| 1007 kTagWimaxEnabled, | 1007 kTagWimaxEnabled, |
| 1008 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); | 1008 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); |
| 1009 } | 1009 } |
| 1010 | 1010 |
| 1011 } // namespace options | 1011 } // namespace options |
| 1012 } // namespace chromeos | 1012 } // namespace chromeos |
| OLD | NEW |