Chromium Code Reviews| 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 "ash/system/chromeos/network/network_connect.h" |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/bind.h" | 15 #include "base/bind.h" |
| 16 #include "base/bind_helpers.h" | 16 #include "base/bind_helpers.h" |
| 17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/values.h" | 19 #include "base/values.h" |
| 20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/chrome_notification_types.h" | |
| 22 #include "chrome/browser/chromeos/mobile_config.h" | 21 #include "chrome/browser/chromeos/mobile_config.h" |
| 23 #include "chrome/browser/chromeos/net/onc_utils.h" | 22 #include "chrome/browser/chromeos/net/onc_utils.h" |
| 24 #include "chrome/browser/chromeos/options/network_config_view.h" | 23 #include "chrome/browser/chromeos/options/network_config_view.h" |
| 25 #include "chrome/browser/chromeos/options/network_property_ui_data.h" | 24 #include "chrome/browser/chromeos/options/network_property_ui_data.h" |
| 26 #include "chrome/browser/chromeos/settings/cros_settings.h" | 25 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 27 #include "chrome/browser/chromeos/sim_dialog_delegate.h" | 26 #include "chrome/browser/chromeos/sim_dialog_delegate.h" |
| 28 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" | 27 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" |
| 29 #include "chrome/browser/chromeos/ui/mobile_config_ui.h" | 28 #include "chrome/browser/chromeos/ui/mobile_config_ui.h" |
| 30 #include "chrome/browser/chromeos/ui_proxy_config_service.h" | 29 #include "chrome/browser/chromeos/ui_proxy_config_service.h" |
| 31 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
| 32 #include "chrome/browser/ui/webui/options/chromeos/internet_options_handler_stri ngs.h" | 31 #include "chrome/browser/ui/webui/options/chromeos/internet_options_handler_stri ngs.h" |
| 33 #include "chromeos/chromeos_switches.h" | 32 #include "chromeos/chromeos_switches.h" |
| 34 #include "chromeos/network/device_state.h" | 33 #include "chromeos/network/device_state.h" |
| 35 #include "chromeos/network/managed_network_configuration_handler.h" | 34 #include "chromeos/network/managed_network_configuration_handler.h" |
| 36 #include "chromeos/network/network_configuration_handler.h" | 35 #include "chromeos/network/network_configuration_handler.h" |
| 37 #include "chromeos/network/network_connection_handler.h" | 36 #include "chromeos/network/network_connection_handler.h" |
| 38 #include "chromeos/network/network_device_handler.h" | 37 #include "chromeos/network/network_device_handler.h" |
| 39 #include "chromeos/network/network_event_log.h" | 38 #include "chromeos/network/network_event_log.h" |
| 40 #include "chromeos/network/network_ip_config.h" | 39 #include "chromeos/network/network_ip_config.h" |
| 41 #include "chromeos/network/network_profile.h" | 40 #include "chromeos/network/network_profile.h" |
| 42 #include "chromeos/network/network_profile_handler.h" | 41 #include "chromeos/network/network_profile_handler.h" |
| 43 #include "chromeos/network/network_state.h" | 42 #include "chromeos/network/network_state.h" |
| 44 #include "chromeos/network/network_state_handler.h" | 43 #include "chromeos/network/network_state_handler.h" |
| 45 #include "chromeos/network/network_util.h" | 44 #include "chromeos/network/network_util.h" |
| 46 #include "chromeos/network/onc/onc_signature.h" | 45 #include "chromeos/network/onc/onc_signature.h" |
| 47 #include "chromeos/network/onc/onc_translator.h" | 46 #include "chromeos/network/onc/onc_translator.h" |
| 48 #include "components/onc/onc_constants.h" | 47 #include "components/onc/onc_constants.h" |
| 49 #include "content/public/browser/notification_service.h" | |
| 50 #include "content/public/browser/user_metrics.h" | 48 #include "content/public/browser/user_metrics.h" |
| 51 #include "content/public/browser/web_contents.h" | 49 #include "content/public/browser/web_contents.h" |
| 52 #include "content/public/browser/web_ui.h" | 50 #include "content/public/browser/web_ui.h" |
| 53 #include "grit/ash_resources.h" | 51 #include "grit/ash_resources.h" |
| 54 #include "grit/ui_chromeos_resources.h" | 52 #include "grit/ui_chromeos_resources.h" |
| 55 #include "third_party/cros_system_api/dbus/service_constants.h" | 53 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 56 #include "ui/base/resource/resource_bundle.h" | 54 #include "ui/base/resource/resource_bundle.h" |
| 57 #include "ui/base/webui/web_ui_util.h" | 55 #include "ui/base/webui/web_ui_util.h" |
| 58 #include "ui/chromeos/network/network_icon.h" | 56 #include "ui/chromeos/network/network_icon.h" |
| 59 #include "ui/gfx/image/image_skia.h" | 57 #include "ui/gfx/image/image_skia.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 const char kRefreshNetworkDataFunction[] = | 93 const char kRefreshNetworkDataFunction[] = |
| 96 "options.network.NetworkList.refreshNetworkData"; | 94 "options.network.NetworkList.refreshNetworkData"; |
| 97 const char kSetDefaultNetworkIconsFunction[] = | 95 const char kSetDefaultNetworkIconsFunction[] = |
| 98 "options.network.NetworkList.setDefaultNetworkIcons"; | 96 "options.network.NetworkList.setDefaultNetworkIcons"; |
| 99 const char kShowDetailedInfoFunction[] = | 97 const char kShowDetailedInfoFunction[] = |
| 100 "options.internet.DetailsInternetPage.showDetailedInfo"; | 98 "options.internet.DetailsInternetPage.showDetailedInfo"; |
| 101 const char kUpdateConnectionDataFunction[] = | 99 const char kUpdateConnectionDataFunction[] = |
| 102 "options.internet.DetailsInternetPage.updateConnectionData"; | 100 "options.internet.DetailsInternetPage.updateConnectionData"; |
| 103 const char kUpdateCarrierFunction[] = | 101 const char kUpdateCarrierFunction[] = |
| 104 "options.internet.DetailsInternetPage.updateCarrier"; | 102 "options.internet.DetailsInternetPage.updateCarrier"; |
| 105 const char kUpdateSecurityTabFunction[] = | |
| 106 "options.internet.DetailsInternetPage.updateSecurityTab"; | |
| 107 | 103 |
| 108 // These are used to register message handlers with JavaScript. | 104 // These are used to register message handlers with JavaScript. |
| 109 const char kBuyDataPlanMessage[] = "buyDataPlan"; | 105 const char kBuyDataPlanMessage[] = "buyDataPlan"; |
| 110 const char kChangePinMessage[] = "changePin"; | 106 const char kChangePinMessage[] = "changePin"; |
| 111 const char kDisableCellularMessage[] = "disableCellular"; | 107 const char kDisableCellularMessage[] = "disableCellular"; |
| 112 const char kDisableWifiMessage[] = "disableWifi"; | 108 const char kDisableWifiMessage[] = "disableWifi"; |
| 113 const char kDisableWimaxMessage[] = "disableWimax"; | 109 const char kDisableWimaxMessage[] = "disableWimax"; |
| 114 const char kEnableCellularMessage[] = "enableCellular"; | 110 const char kEnableCellularMessage[] = "enableCellular"; |
| 115 const char kEnableWifiMessage[] = "enableWifi"; | 111 const char kEnableWifiMessage[] = "enableWifi"; |
| 116 const char kEnableWimaxMessage[] = "enableWimax"; | 112 const char kEnableWimaxMessage[] = "enableWimax"; |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 const DeviceState* device = | 501 const DeviceState* device = |
| 506 NetworkHandler::Get()->network_state_handler()->GetDeviceState( | 502 NetworkHandler::Get()->network_state_handler()->GetDeviceState( |
| 507 cellular->device_path()); | 503 cellular->device_path()); |
| 508 if (device) { | 504 if (device) { |
| 509 const base::DictionaryValue& device_properties = device->properties(); | 505 const base::DictionaryValue& device_properties = device->properties(); |
| 510 ::onc::ONCSource onc_source; | 506 ::onc::ONCSource onc_source; |
| 511 NetworkHandler::Get()->managed_network_configuration_handler()-> | 507 NetworkHandler::Get()->managed_network_configuration_handler()-> |
| 512 FindPolicyByGUID(LoginState::Get()->primary_user_hash(), | 508 FindPolicyByGUID(LoginState::Get()->primary_user_hash(), |
| 513 cellular->guid(), &onc_source); | 509 cellular->guid(), &onc_source); |
| 514 const NetworkPropertyUIData cellular_property_ui_data(onc_source); | 510 const NetworkPropertyUIData cellular_property_ui_data(onc_source); |
| 511 LOG(ERROR) << "SIM_LOCK_ENABLED: " << device->sim_lock_enabled(); | |
|
stevenjb
2014/07/18 00:29:40
Oops. Removed locally, will update with any other
| |
| 515 SetValueDictionary(dictionary, | 512 SetValueDictionary(dictionary, |
| 516 kTagSimCardLockEnabled, | 513 kTagSimCardLockEnabled, |
| 517 new base::FundamentalValue(device->sim_lock_enabled()), | 514 new base::FundamentalValue(device->sim_lock_enabled()), |
| 518 cellular_property_ui_data); | 515 cellular_property_ui_data); |
| 519 | 516 |
| 520 carrier_id = device->home_provider_id(); | 517 carrier_id = device->home_provider_id(); |
| 521 device_properties.GetStringWithoutPathExpansion(shill::kMdnProperty, &mdn); | 518 device_properties.GetStringWithoutPathExpansion(shill::kMdnProperty, &mdn); |
| 522 | 519 |
| 523 MobileConfig* config = MobileConfig::GetInstance(); | 520 MobileConfig* config = MobileConfig::GetInstance(); |
| 524 if (config->IsReady()) { | 521 if (config->IsReady()) { |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 701 service_path, | 698 service_path, |
| 702 base::Bind(&ash::network_connect::ConnectToNetwork, | 699 base::Bind(&ash::network_connect::ConnectToNetwork, |
| 703 service_path, owning_window), | 700 service_path, owning_window), |
| 704 base::Bind(&ShillError, "RequestReconnect")); | 701 base::Bind(&ShillError, "RequestReconnect")); |
| 705 } | 702 } |
| 706 | 703 |
| 707 } // namespace | 704 } // namespace |
| 708 | 705 |
| 709 InternetOptionsHandler::InternetOptionsHandler() | 706 InternetOptionsHandler::InternetOptionsHandler() |
| 710 : weak_factory_(this) { | 707 : weak_factory_(this) { |
| 711 registrar_.Add(this, chrome::NOTIFICATION_REQUIRE_PIN_SETTING_CHANGE_ENDED, | |
| 712 content::NotificationService::AllSources()); | |
| 713 registrar_.Add(this, chrome::NOTIFICATION_ENTER_PIN_ENDED, | |
| 714 content::NotificationService::AllSources()); | |
| 715 NetworkHandler::Get()->network_state_handler()->AddObserver(this, FROM_HERE); | 708 NetworkHandler::Get()->network_state_handler()->AddObserver(this, FROM_HERE); |
| 716 } | 709 } |
| 717 | 710 |
| 718 InternetOptionsHandler::~InternetOptionsHandler() { | 711 InternetOptionsHandler::~InternetOptionsHandler() { |
| 719 if (NetworkHandler::IsInitialized()) { | 712 if (NetworkHandler::IsInitialized()) { |
| 720 NetworkHandler::Get()->network_state_handler()->RemoveObserver( | 713 NetworkHandler::Get()->network_state_handler()->RemoveObserver( |
| 721 this, FROM_HERE); | 714 this, FROM_HERE); |
| 722 } | 715 } |
| 723 } | 716 } |
| 724 | 717 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 997 const base::ListValue* args) { | 990 const base::ListValue* args) { |
| 998 bool require_pin_new_value; | 991 bool require_pin_new_value; |
| 999 if (!args->GetBoolean(0, &require_pin_new_value)) { | 992 if (!args->GetBoolean(0, &require_pin_new_value)) { |
| 1000 NOTREACHED(); | 993 NOTREACHED(); |
| 1001 return; | 994 return; |
| 1002 } | 995 } |
| 1003 // 1. Bring up SIM unlock dialog, pass new RequirePin setting in URL. | 996 // 1. Bring up SIM unlock dialog, pass new RequirePin setting in URL. |
| 1004 // 2. Dialog will ask for current PIN in any case. | 997 // 2. Dialog will ask for current PIN in any case. |
| 1005 // 3. If card is locked it will first call PIN unlock operation | 998 // 3. If card is locked it will first call PIN unlock operation |
| 1006 // 4. Then it will call Set RequirePin, passing the same PIN. | 999 // 4. Then it will call Set RequirePin, passing the same PIN. |
| 1007 // 5. We'll get notified by REQUIRE_PIN_SETTING_CHANGE_ENDED notification. | 1000 // 5. The dialog may change device properties, in which case |
| 1001 // DevicePropertiesUpdated() will get called which will update the UI. | |
| 1008 SimDialogDelegate::SimDialogMode mode; | 1002 SimDialogDelegate::SimDialogMode mode; |
| 1009 if (require_pin_new_value) | 1003 if (require_pin_new_value) |
| 1010 mode = SimDialogDelegate::SIM_DIALOG_SET_LOCK_ON; | 1004 mode = SimDialogDelegate::SIM_DIALOG_SET_LOCK_ON; |
| 1011 else | 1005 else |
| 1012 mode = SimDialogDelegate::SIM_DIALOG_SET_LOCK_OFF; | 1006 mode = SimDialogDelegate::SIM_DIALOG_SET_LOCK_OFF; |
| 1013 SimDialogDelegate::ShowDialog(GetNativeWindow(), mode); | 1007 SimDialogDelegate::ShowDialog(GetNativeWindow(), mode); |
| 1014 } | 1008 } |
| 1015 | 1009 |
| 1016 void InternetOptionsHandler::ChangePinCallback(const base::ListValue* args) { | 1010 void InternetOptionsHandler::ChangePinCallback(const base::ListValue* args) { |
| 1017 SimDialogDelegate::ShowDialog(GetNativeWindow(), | 1011 SimDialogDelegate::ShowDialog(GetNativeWindow(), |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1084 } | 1078 } |
| 1085 | 1079 |
| 1086 void InternetOptionsHandler::NetworkPropertiesUpdated( | 1080 void InternetOptionsHandler::NetworkPropertiesUpdated( |
| 1087 const NetworkState* network) { | 1081 const NetworkState* network) { |
| 1088 if (!web_ui()) | 1082 if (!web_ui()) |
| 1089 return; | 1083 return; |
| 1090 RefreshNetworkData(); | 1084 RefreshNetworkData(); |
| 1091 UpdateConnectionData(network->path()); | 1085 UpdateConnectionData(network->path()); |
| 1092 } | 1086 } |
| 1093 | 1087 |
| 1094 void InternetOptionsHandler::Observe( | 1088 void InternetOptionsHandler::DevicePropertiesUpdated( |
| 1095 int type, | 1089 const DeviceState* device) { |
| 1096 const content::NotificationSource& source, | 1090 if (!web_ui()) |
| 1097 const content::NotificationDetails& details) { | 1091 return; |
| 1098 if (type == chrome::NOTIFICATION_REQUIRE_PIN_SETTING_CHANGE_ENDED) { | 1092 if (device->type() != shill::kTypeCellular) |
| 1099 base::FundamentalValue require_pin(*content::Details<bool>(details).ptr()); | 1093 return; |
| 1100 web_ui()->CallJavascriptFunction( | 1094 const NetworkState* network = |
| 1101 kUpdateSecurityTabFunction, require_pin); | 1095 NetworkHandler::Get()->network_state_handler()->FirstNetworkByType( |
| 1102 } else if (type == chrome::NOTIFICATION_ENTER_PIN_ENDED) { | 1096 NetworkTypePattern::Cellular()); |
| 1103 // We make an assumption (which is valid for now) that the SIM | 1097 if (network) |
| 1104 // unlock dialog is put up only when the user is trying to enable | 1098 UpdateConnectionData(network->path()); // Update sim lock status. |
| 1105 // mobile data. | |
| 1106 bool cancelled = *content::Details<bool>(details).ptr(); | |
| 1107 if (cancelled) | |
| 1108 RefreshNetworkData(); | |
| 1109 // The case in which the correct PIN was entered and the SIM is | |
| 1110 // now unlocked is handled in NetworkMenuButton. | |
| 1111 } | |
| 1112 } | 1099 } |
| 1113 | 1100 |
| 1114 void InternetOptionsHandler::SetServerHostnameCallback( | 1101 void InternetOptionsHandler::SetServerHostnameCallback( |
| 1115 const base::ListValue* args) { | 1102 const base::ListValue* args) { |
| 1116 std::string service_path, server_hostname; | 1103 std::string service_path, server_hostname; |
| 1117 if (args->GetSize() < 2 || | 1104 if (args->GetSize() < 2 || |
| 1118 !args->GetString(0, &service_path) || | 1105 !args->GetString(0, &service_path) || |
| 1119 !args->GetString(1, &server_hostname)) { | 1106 !args->GetString(1, &server_hostname)) { |
| 1120 NOTREACHED(); | 1107 NOTREACHED(); |
| 1121 return; | 1108 return; |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1567 dictionary->SetBoolean( | 1554 dictionary->SetBoolean( |
| 1568 kTagWimaxAvailable, | 1555 kTagWimaxAvailable, |
| 1569 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); | 1556 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); |
| 1570 dictionary->SetBoolean( | 1557 dictionary->SetBoolean( |
| 1571 kTagWimaxEnabled, | 1558 kTagWimaxEnabled, |
| 1572 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); | 1559 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); |
| 1573 } | 1560 } |
| 1574 | 1561 |
| 1575 } // namespace options | 1562 } // namespace options |
| 1576 } // namespace chromeos | 1563 } // namespace chromeos |
| OLD | NEW |