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 "ash/system/chromeos/network/network_icon.h" | 14 #include "ash/system/chromeos/network/network_icon.h" |
| 15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/bind.h" | 16 #include "base/bind.h" |
| 17 #include "base/bind_helpers.h" | 17 #include "base/bind_helpers.h" |
| 18 #include "base/command_line.h" | 18 #include "base/command_line.h" |
| 19 #include "base/strings/string_number_conversions.h" | |
| 20 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/values.h" | 20 #include "base/values.h" |
| 22 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 23 #include "chrome/browser/chrome_notification_types.h" | 22 #include "chrome/browser/chrome_notification_types.h" |
| 24 #include "chrome/browser/chromeos/mobile_config.h" | 23 #include "chrome/browser/chromeos/mobile_config.h" |
| 25 #include "chrome/browser/chromeos/net/onc_utils.h" | 24 #include "chrome/browser/chromeos/net/onc_utils.h" |
| 26 #include "chrome/browser/chromeos/options/network_config_view.h" | 25 #include "chrome/browser/chromeos/options/network_config_view.h" |
| 27 #include "chrome/browser/chromeos/options/network_property_ui_data.h" | 26 #include "chrome/browser/chromeos/options/network_property_ui_data.h" |
| 28 #include "chrome/browser/chromeos/settings/cros_settings.h" | 27 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 29 #include "chrome/browser/chromeos/sim_dialog_delegate.h" | 28 #include "chrome/browser/chromeos/sim_dialog_delegate.h" |
| 30 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" | 29 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" |
| 31 #include "chrome/browser/chromeos/ui/mobile_config_ui.h" | 30 #include "chrome/browser/chromeos/ui/mobile_config_ui.h" |
| 32 #include "chrome/browser/chromeos/ui_proxy_config_service.h" | 31 #include "chrome/browser/chromeos/ui_proxy_config_service.h" |
| 33 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
| 34 #include "chrome/browser/ui/webui/options/chromeos/internet_options_handler_stri ngs.h" | 33 #include "chrome/browser/ui/webui/options/chromeos/internet_options_handler_stri ngs.h" |
| 35 #include "chromeos/chromeos_switches.h" | 34 #include "chromeos/chromeos_switches.h" |
| 36 #include "chromeos/network/device_state.h" | 35 #include "chromeos/network/device_state.h" |
| 37 #include "chromeos/network/managed_network_configuration_handler.h" | 36 #include "chromeos/network/managed_network_configuration_handler.h" |
| 38 #include "chromeos/network/network_configuration_handler.h" | 37 #include "chromeos/network/network_configuration_handler.h" |
| 39 #include "chromeos/network/network_connection_handler.h" | 38 #include "chromeos/network/network_connection_handler.h" |
| 40 #include "chromeos/network/network_device_handler.h" | 39 #include "chromeos/network/network_device_handler.h" |
| 41 #include "chromeos/network/network_event_log.h" | 40 #include "chromeos/network/network_event_log.h" |
| 42 #include "chromeos/network/network_ip_config.h" | 41 #include "chromeos/network/network_ip_config.h" |
| 43 #include "chromeos/network/network_profile.h" | 42 #include "chromeos/network/network_profile.h" |
| 44 #include "chromeos/network/network_profile_handler.h" | 43 #include "chromeos/network/network_profile_handler.h" |
| 45 #include "chromeos/network/network_state.h" | 44 #include "chromeos/network/network_state.h" |
| 46 #include "chromeos/network/network_state_handler.h" | 45 #include "chromeos/network/network_state_handler.h" |
| 47 #include "chromeos/network/network_ui_data.h" | |
| 48 #include "chromeos/network/network_util.h" | 46 #include "chromeos/network/network_util.h" |
| 49 #include "chromeos/network/onc/onc_signature.h" | 47 #include "chromeos/network/onc/onc_signature.h" |
| 50 #include "chromeos/network/onc/onc_translator.h" | 48 #include "chromeos/network/onc/onc_translator.h" |
| 51 #include "components/onc/onc_constants.h" | 49 #include "components/onc/onc_constants.h" |
| 52 #include "content/public/browser/notification_service.h" | 50 #include "content/public/browser/notification_service.h" |
| 53 #include "content/public/browser/user_metrics.h" | 51 #include "content/public/browser/user_metrics.h" |
| 54 #include "content/public/browser/web_contents.h" | 52 #include "content/public/browser/web_contents.h" |
| 55 #include "content/public/browser/web_ui.h" | 53 #include "content/public/browser/web_ui.h" |
| 56 #include "grit/ash_resources.h" | 54 #include "grit/ash_resources.h" |
| 57 #include "third_party/cros_system_api/dbus/service_constants.h" | 55 #include "third_party/cros_system_api/dbus/service_constants.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 const char kRefreshNetworkDataFunction[] = | 94 const char kRefreshNetworkDataFunction[] = |
| 97 "options.network.NetworkList.refreshNetworkData"; | 95 "options.network.NetworkList.refreshNetworkData"; |
| 98 const char kSetDefaultNetworkIconsFunction[] = | 96 const char kSetDefaultNetworkIconsFunction[] = |
| 99 "options.network.NetworkList.setDefaultNetworkIcons"; | 97 "options.network.NetworkList.setDefaultNetworkIcons"; |
| 100 const char kShowDetailedInfoFunction[] = | 98 const char kShowDetailedInfoFunction[] = |
| 101 "options.internet.DetailsInternetPage.showDetailedInfo"; | 99 "options.internet.DetailsInternetPage.showDetailedInfo"; |
| 102 const char kUpdateConnectionDataFunction[] = | 100 const char kUpdateConnectionDataFunction[] = |
| 103 "options.internet.DetailsInternetPage.updateConnectionData"; | 101 "options.internet.DetailsInternetPage.updateConnectionData"; |
| 104 const char kUpdateCarrierFunction[] = | 102 const char kUpdateCarrierFunction[] = |
| 105 "options.internet.DetailsInternetPage.updateCarrier"; | 103 "options.internet.DetailsInternetPage.updateCarrier"; |
| 106 const char kUpdateLoggedInUserTypeFunction[] = | |
| 107 "options.network.NetworkList.updateLoggedInUserType"; | |
| 108 const char kUpdateSecurityTabFunction[] = | 104 const char kUpdateSecurityTabFunction[] = |
| 109 "options.internet.DetailsInternetPage.updateSecurityTab"; | 105 "options.internet.DetailsInternetPage.updateSecurityTab"; |
| 110 | 106 |
| 111 // These are used to register message handlers with JavaScript. | 107 // These are used to register message handlers with JavaScript. |
| 112 const char kBuyDataPlanMessage[] = "buyDataPlan"; | 108 const char kBuyDataPlanMessage[] = "buyDataPlan"; |
| 113 const char kChangePinMessage[] = "changePin"; | 109 const char kChangePinMessage[] = "changePin"; |
| 114 const char kDisableCellularMessage[] = "disableCellular"; | 110 const char kDisableCellularMessage[] = "disableCellular"; |
| 115 const char kDisableWifiMessage[] = "disableWifi"; | 111 const char kDisableWifiMessage[] = "disableWifi"; |
| 116 const char kDisableWimaxMessage[] = "disableWimax"; | 112 const char kDisableWimaxMessage[] = "disableWimax"; |
| 117 const char kEnableCellularMessage[] = "enableCellular"; | 113 const char kEnableCellularMessage[] = "enableCellular"; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 const char kTagTrue[] = "true"; | 174 const char kTagTrue[] = "true"; |
| 179 const char kTagUsername[] = "username"; | 175 const char kTagUsername[] = "username"; |
| 180 const char kTagValue[] = "value"; | 176 const char kTagValue[] = "value"; |
| 181 const char kTagVpnList[] = "vpnList"; | 177 const char kTagVpnList[] = "vpnList"; |
| 182 const char kTagWifiAvailable[] = "wifiAvailable"; | 178 const char kTagWifiAvailable[] = "wifiAvailable"; |
| 183 const char kTagWifiEnabled[] = "wifiEnabled"; | 179 const char kTagWifiEnabled[] = "wifiEnabled"; |
| 184 const char kTagWimaxAvailable[] = "wimaxAvailable"; | 180 const char kTagWimaxAvailable[] = "wimaxAvailable"; |
| 185 const char kTagWimaxEnabled[] = "wimaxEnabled"; | 181 const char kTagWimaxEnabled[] = "wimaxEnabled"; |
| 186 const char kTagWiredList[] = "wiredList"; | 182 const char kTagWiredList[] = "wiredList"; |
| 187 const char kTagWirelessList[] = "wirelessList"; | 183 const char kTagWirelessList[] = "wirelessList"; |
| 188 const char kTagLoggedInUserNone[] = "none"; | |
| 189 const char kTagLoggedInUserRegular[] = "regular"; | |
| 190 const char kTagLoggedInUserOwner[] = "owner"; | |
| 191 const char kTagLoggedInUserGuest[] = "guest"; | |
| 192 const char kTagLoggedInUserRetailMode[] = "retail-mode"; | |
| 193 const char kTagLoggedInUserPublicAccount[] = "public-account"; | |
| 194 const char kTagLoggedInUserLocallyManaged[] = "locally-managed"; | |
| 195 const char kTagLoggedInUserKioskApp[] = "kiosk-app"; | |
| 196 | 184 |
| 197 const int kPreferredPriority = 1; | 185 const int kPreferredPriority = 1; |
| 198 | 186 |
| 199 void ShillError(const std::string& function, | 187 void ShillError(const std::string& function, |
| 200 const std::string& error_name, | 188 const std::string& error_name, |
| 201 scoped_ptr<base::DictionaryValue> error_data) { | 189 scoped_ptr<base::DictionaryValue> error_data) { |
| 202 // UpdateConnectionData may send requests for stale services; ignore | 190 // UpdateConnectionData may send requests for stale services; ignore |
| 203 // these errors. | 191 // these errors. |
| 204 if (function == "UpdateConnectionData" && | 192 if (function == "UpdateConnectionData" && |
| 205 error_name == network_handler::kDBusFailedError) | 193 error_name == network_handler::kDBusFailedError) |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 218 base::Value* value) { | 206 base::Value* value) { |
| 219 NET_LOG_EVENT("SetNetworkProperty: " + property, service_path); | 207 NET_LOG_EVENT("SetNetworkProperty: " + property, service_path); |
| 220 base::DictionaryValue properties; | 208 base::DictionaryValue properties; |
| 221 properties.SetWithoutPathExpansion(property, value); | 209 properties.SetWithoutPathExpansion(property, value); |
| 222 NetworkHandler::Get()->network_configuration_handler()->SetProperties( | 210 NetworkHandler::Get()->network_configuration_handler()->SetProperties( |
| 223 service_path, properties, | 211 service_path, properties, |
| 224 base::Bind(&base::DoNothing), | 212 base::Bind(&base::DoNothing), |
| 225 base::Bind(&ShillError, "SetNetworkProperty")); | 213 base::Bind(&ShillError, "SetNetworkProperty")); |
| 226 } | 214 } |
| 227 | 215 |
| 228 std::string LoggedInUserTypeToJSString(LoginState::LoggedInUserType type) { | |
| 229 switch (type) { | |
| 230 case LoginState::LOGGED_IN_USER_NONE: | |
| 231 return kTagLoggedInUserNone; | |
| 232 case LoginState::LOGGED_IN_USER_REGULAR: | |
| 233 return kTagLoggedInUserRegular; | |
| 234 case LoginState::LOGGED_IN_USER_OWNER: | |
| 235 return kTagLoggedInUserOwner; | |
| 236 case LoginState::LOGGED_IN_USER_GUEST: | |
| 237 return kTagLoggedInUserGuest; | |
| 238 case LoginState::LOGGED_IN_USER_RETAIL_MODE: | |
| 239 return kTagLoggedInUserRetailMode; | |
| 240 case LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT: | |
| 241 return kTagLoggedInUserPublicAccount; | |
| 242 case LoginState::LOGGED_IN_USER_LOCALLY_MANAGED: | |
| 243 return kTagLoggedInUserLocallyManaged; | |
| 244 case LoginState::LOGGED_IN_USER_KIOSK_APP: | |
| 245 return kTagLoggedInUserKioskApp; | |
| 246 } | |
| 247 NOTREACHED(); | |
| 248 return std::string(); | |
| 249 } | |
| 250 | |
| 251 // Builds a dictionary with network information and an icon used for the | 216 // Builds a dictionary with network information and an icon used for the |
| 252 // NetworkList on the settings page. Ownership of the returned pointer is | 217 // NetworkList on the settings page. Ownership of the returned pointer is |
| 253 // transferred to the caller. | 218 // transferred to the caller. |
| 254 base::DictionaryValue* BuildNetworkDictionary( | 219 base::DictionaryValue* BuildNetworkDictionary( |
| 255 const NetworkState* network, | 220 const NetworkState* network, |
| 256 float icon_scale_factor, | 221 float icon_scale_factor, |
| 257 const PrefService* profile_prefs) { | 222 const PrefService* profile_prefs) { |
| 258 scoped_ptr<base::DictionaryValue> network_info = | 223 scoped_ptr<base::DictionaryValue> network_info = |
| 259 network_util::TranslateNetworkStateToONC(network); | 224 network_util::TranslateNetworkStateToONC(network); |
| 260 | 225 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 534 // These default to empty and are only set if device != NULL. | 499 // These default to empty and are only set if device != NULL. |
| 535 std::string carrier_id; | 500 std::string carrier_id; |
| 536 std::string mdn; | 501 std::string mdn; |
| 537 | 502 |
| 538 // Device settings. | 503 // Device settings. |
| 539 const DeviceState* device = | 504 const DeviceState* device = |
| 540 NetworkHandler::Get()->network_state_handler()->GetDeviceState( | 505 NetworkHandler::Get()->network_state_handler()->GetDeviceState( |
| 541 cellular->device_path()); | 506 cellular->device_path()); |
| 542 if (device) { | 507 if (device) { |
| 543 const base::DictionaryValue& device_properties = device->properties(); | 508 const base::DictionaryValue& device_properties = device->properties(); |
| 544 const NetworkPropertyUIData cellular_property_ui_data( | 509 ::onc::ONCSource onc_source; |
| 545 cellular->ui_data().onc_source()); | 510 NetworkHandler::Get()->managed_network_configuration_handler()-> |
| 511 FindPolicyByGUID(LoginState::Get()->primary_user_hash(), | |
|
pneubeck (no reviews)
2014/07/11 20:35:06
once we refer to the 'right user' more than once,
stevenjb
2014/07/11 21:26:10
That's kind of what LoginState::Get()->primary_use
| |
| 512 cellular->guid(), &onc_source); | |
| 513 const NetworkPropertyUIData cellular_property_ui_data(onc_source); | |
| 546 SetValueDictionary(dictionary, | 514 SetValueDictionary(dictionary, |
| 547 kTagSimCardLockEnabled, | 515 kTagSimCardLockEnabled, |
| 548 new base::FundamentalValue(device->sim_lock_enabled()), | 516 new base::FundamentalValue(device->sim_lock_enabled()), |
| 549 cellular_property_ui_data); | 517 cellular_property_ui_data); |
| 550 | 518 |
| 551 carrier_id = device->home_provider_id(); | 519 carrier_id = device->home_provider_id(); |
| 552 device_properties.GetStringWithoutPathExpansion(shill::kMdnProperty, &mdn); | 520 device_properties.GetStringWithoutPathExpansion(shill::kMdnProperty, &mdn); |
| 553 | 521 |
| 554 MobileConfig* config = MobileConfig::GetInstance(); | 522 MobileConfig* config = MobileConfig::GetInstance(); |
| 555 if (config->IsReady()) { | 523 if (config->IsReady()) { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 570 base::DictionaryValue* apn = new base::DictionaryValue; | 538 base::DictionaryValue* apn = new base::DictionaryValue; |
| 571 CreateDictionaryFromCellularApn(dict, apn); | 539 CreateDictionaryFromCellularApn(dict, apn); |
| 572 apn_list_value->Append(apn); | 540 apn_list_value->Append(apn); |
| 573 } | 541 } |
| 574 } | 542 } |
| 575 } | 543 } |
| 576 SetValueDictionary(dictionary, | 544 SetValueDictionary(dictionary, |
| 577 kTagProviderApnList, | 545 kTagProviderApnList, |
| 578 apn_list_value, | 546 apn_list_value, |
| 579 cellular_property_ui_data); | 547 cellular_property_ui_data); |
| 580 if (CommandLine::ForCurrentProcess()->HasSwitch( | 548 const base::ListValue* supported_carriers; |
| 581 chromeos::switches::kEnableCarrierSwitching)) { | 549 if (device_properties.GetListWithoutPathExpansion( |
| 582 const base::ListValue* supported_carriers; | 550 shill::kSupportedCarriersProperty, &supported_carriers)) { |
| 583 if (device_properties.GetListWithoutPathExpansion( | 551 dictionary->Set(kTagCarriers, supported_carriers->DeepCopy()); |
| 584 shill::kSupportedCarriersProperty, &supported_carriers)) { | 552 dictionary->SetInteger( |
| 585 dictionary->Set(kTagCarriers, supported_carriers->DeepCopy()); | 553 kTagCurrentCarrierIndex, |
| 586 dictionary->SetInteger( | 554 FindCurrentCarrierIndex(supported_carriers, device)); |
| 587 kTagCurrentCarrierIndex, | 555 } else { |
| 588 FindCurrentCarrierIndex(supported_carriers, device)); | 556 // In case of any error, set the current carrier tag to -1 indicating |
| 589 } else { | 557 // to the JS code to fallback to a single carrier. |
| 590 // In case of any error, set the current carrier tag to -1 indicating | 558 dictionary->SetInteger(kTagCurrentCarrierIndex, -1); |
| 591 // to the JS code to fallback to a single carrier. | |
| 592 dictionary->SetInteger(kTagCurrentCarrierIndex, -1); | |
| 593 } | |
| 594 } | 559 } |
| 595 } | 560 } |
| 596 | 561 |
| 597 // Don't show any account management related buttons if the activation | 562 // Don't show any account management related buttons if the activation |
| 598 // state is unknown or no payment portal URL is available. | 563 // state is unknown or no payment portal URL is available. |
| 599 std::string support_url; | 564 std::string support_url; |
| 600 if (cellular->activation_state() == shill::kActivationStateUnknown || | 565 if (cellular->activation_state() == shill::kActivationStateUnknown || |
| 601 !dictionary->GetString(kTagSupportUrl, &support_url) || | 566 !dictionary->GetString(kTagSupportUrl, &support_url) || |
| 602 support_url.empty()) { | 567 support_url.empty()) { |
| 603 VLOG(2) << "No support URL is available. Don't display buttons."; | 568 VLOG(2) << "No support URL is available. Don't display buttons."; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 740 | 705 |
| 741 } // namespace | 706 } // namespace |
| 742 | 707 |
| 743 InternetOptionsHandler::InternetOptionsHandler() | 708 InternetOptionsHandler::InternetOptionsHandler() |
| 744 : weak_factory_(this) { | 709 : weak_factory_(this) { |
| 745 registrar_.Add(this, chrome::NOTIFICATION_REQUIRE_PIN_SETTING_CHANGE_ENDED, | 710 registrar_.Add(this, chrome::NOTIFICATION_REQUIRE_PIN_SETTING_CHANGE_ENDED, |
| 746 content::NotificationService::AllSources()); | 711 content::NotificationService::AllSources()); |
| 747 registrar_.Add(this, chrome::NOTIFICATION_ENTER_PIN_ENDED, | 712 registrar_.Add(this, chrome::NOTIFICATION_ENTER_PIN_ENDED, |
| 748 content::NotificationService::AllSources()); | 713 content::NotificationService::AllSources()); |
| 749 NetworkHandler::Get()->network_state_handler()->AddObserver(this, FROM_HERE); | 714 NetworkHandler::Get()->network_state_handler()->AddObserver(this, FROM_HERE); |
| 750 LoginState::Get()->AddObserver(this); | |
| 751 } | 715 } |
| 752 | 716 |
| 753 InternetOptionsHandler::~InternetOptionsHandler() { | 717 InternetOptionsHandler::~InternetOptionsHandler() { |
| 754 if (NetworkHandler::IsInitialized()) { | 718 if (NetworkHandler::IsInitialized()) { |
| 755 NetworkHandler::Get()->network_state_handler()->RemoveObserver( | 719 NetworkHandler::Get()->network_state_handler()->RemoveObserver( |
| 756 this, FROM_HERE); | 720 this, FROM_HERE); |
| 757 } | 721 } |
| 758 if (LoginState::Get()->IsInitialized()) | |
| 759 LoginState::Get()->RemoveObserver(this); | |
| 760 } | 722 } |
| 761 | 723 |
| 762 void InternetOptionsHandler::GetLocalizedValues( | 724 void InternetOptionsHandler::GetLocalizedValues( |
| 763 base::DictionaryValue* localized_strings) { | 725 base::DictionaryValue* localized_strings) { |
| 764 DCHECK(localized_strings); | 726 DCHECK(localized_strings); |
| 765 internet_options_strings::RegisterLocalizedStrings(localized_strings); | 727 internet_options_strings::RegisterLocalizedStrings(localized_strings); |
| 766 | 728 |
| 729 // TODO(stevenjb): Find a better way to populate initial data before | |
|
pneubeck (no reviews)
2014/07/11 20:35:07
i think, other WebUIs have a kind of handshake:
1
stevenjb
2014/07/11 21:26:09
This is being done so that the initial layout does
| |
| 730 // InitializePage() gets called. | |
| 767 std::string owner; | 731 std::string owner; |
| 768 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); | 732 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); |
| 769 localized_strings->SetString("ownerUserId", base::UTF8ToUTF16(owner)); | 733 localized_strings->SetString("ownerUserId", base::UTF8ToUTF16(owner)); |
| 734 bool logged_in_as_owner = LoginState::Get()->GetLoggedInUserType() == | |
| 735 LoginState::LOGGED_IN_USER_OWNER; | |
| 736 localized_strings->SetBoolean("loggedInAsOwner", logged_in_as_owner); | |
| 770 | 737 |
| 771 base::DictionaryValue* network_dictionary = new base::DictionaryValue; | 738 base::DictionaryValue* network_dictionary = new base::DictionaryValue; |
| 772 FillNetworkInfo(network_dictionary); | 739 FillNetworkInfo(network_dictionary); |
| 773 localized_strings->Set("networkData", network_dictionary); | 740 localized_strings->Set("networkData", network_dictionary); |
| 774 } | 741 } |
| 775 | 742 |
| 776 void InternetOptionsHandler::InitializePage() { | 743 void InternetOptionsHandler::InitializePage() { |
| 777 base::DictionaryValue dictionary; | 744 base::DictionaryValue dictionary; |
| 778 dictionary.SetString(::onc::network_type::kCellular, | 745 dictionary.SetString(::onc::network_type::kCellular, |
| 779 GetIconDataUrl(IDR_AURA_UBER_TRAY_NETWORK_BARS_DARK)); | 746 GetIconDataUrl(IDR_AURA_UBER_TRAY_NETWORK_BARS_DARK)); |
| 780 dictionary.SetString(::onc::network_type::kWiFi, | 747 dictionary.SetString(::onc::network_type::kWiFi, |
| 781 GetIconDataUrl(IDR_AURA_UBER_TRAY_NETWORK_ARCS_DARK)); | 748 GetIconDataUrl(IDR_AURA_UBER_TRAY_NETWORK_ARCS_DARK)); |
| 782 dictionary.SetString(::onc::network_type::kVPN, | 749 dictionary.SetString(::onc::network_type::kVPN, |
| 783 GetIconDataUrl(IDR_AURA_UBER_TRAY_NETWORK_VPN)); | 750 GetIconDataUrl(IDR_AURA_UBER_TRAY_NETWORK_VPN)); |
| 784 web_ui()->CallJavascriptFunction(kSetDefaultNetworkIconsFunction, | 751 web_ui()->CallJavascriptFunction(kSetDefaultNetworkIconsFunction, |
| 785 dictionary); | 752 dictionary); |
| 786 NetworkHandler::Get()->network_state_handler()->RequestScan(); | 753 NetworkHandler::Get()->network_state_handler()->RequestScan(); |
| 787 RefreshNetworkData(); | 754 RefreshNetworkData(); |
| 788 UpdateLoggedInUserType(); | |
| 789 } | 755 } |
| 790 | 756 |
| 791 void InternetOptionsHandler::RegisterMessages() { | 757 void InternetOptionsHandler::RegisterMessages() { |
| 792 // Setup handlers specific to this panel. | 758 // Setup handlers specific to this panel. |
| 793 web_ui()->RegisterMessageCallback(kNetworkCommandMessage, | 759 web_ui()->RegisterMessageCallback(kNetworkCommandMessage, |
| 794 base::Bind(&InternetOptionsHandler::NetworkCommandCallback, | 760 base::Bind(&InternetOptionsHandler::NetworkCommandCallback, |
| 795 base::Unretained(this))); | 761 base::Unretained(this))); |
| 796 web_ui()->RegisterMessageCallback(kRefreshNetworksMessage, | 762 web_ui()->RegisterMessageCallback(kRefreshNetworksMessage, |
| 797 base::Bind(&InternetOptionsHandler::RefreshNetworksCallback, | 763 base::Bind(&InternetOptionsHandler::RefreshNetworksCallback, |
| 798 base::Unretained(this))); | 764 base::Unretained(this))); |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1117 } | 1083 } |
| 1118 | 1084 |
| 1119 void InternetOptionsHandler::NetworkPropertiesUpdated( | 1085 void InternetOptionsHandler::NetworkPropertiesUpdated( |
| 1120 const NetworkState* network) { | 1086 const NetworkState* network) { |
| 1121 if (!web_ui()) | 1087 if (!web_ui()) |
| 1122 return; | 1088 return; |
| 1123 RefreshNetworkData(); | 1089 RefreshNetworkData(); |
| 1124 UpdateConnectionData(network->path()); | 1090 UpdateConnectionData(network->path()); |
| 1125 } | 1091 } |
| 1126 | 1092 |
| 1127 void InternetOptionsHandler::LoggedInStateChanged() { | |
| 1128 UpdateLoggedInUserType(); | |
| 1129 } | |
| 1130 | |
| 1131 void InternetOptionsHandler::UpdateLoggedInUserType() { | |
| 1132 if (!web_ui()) | |
| 1133 return; | |
| 1134 base::StringValue login_type( | |
| 1135 LoggedInUserTypeToJSString(LoginState::Get()->GetLoggedInUserType())); | |
| 1136 web_ui()->CallJavascriptFunction(kUpdateLoggedInUserTypeFunction, login_type); | |
| 1137 } | |
| 1138 | |
| 1139 void InternetOptionsHandler::Observe( | 1093 void InternetOptionsHandler::Observe( |
| 1140 int type, | 1094 int type, |
| 1141 const content::NotificationSource& source, | 1095 const content::NotificationSource& source, |
| 1142 const content::NotificationDetails& details) { | 1096 const content::NotificationDetails& details) { |
| 1143 if (type == chrome::NOTIFICATION_REQUIRE_PIN_SETTING_CHANGE_ENDED) { | 1097 if (type == chrome::NOTIFICATION_REQUIRE_PIN_SETTING_CHANGE_ENDED) { |
| 1144 base::FundamentalValue require_pin(*content::Details<bool>(details).ptr()); | 1098 base::FundamentalValue require_pin(*content::Details<bool>(details).ptr()); |
| 1145 web_ui()->CallJavascriptFunction( | 1099 web_ui()->CallJavascriptFunction( |
| 1146 kUpdateSecurityTabFunction, require_pin); | 1100 kUpdateSecurityTabFunction, require_pin); |
| 1147 } else if (type == chrome::NOTIFICATION_ENTER_PIN_ENDED) { | 1101 } else if (type == chrome::NOTIFICATION_ENTER_PIN_ENDED) { |
| 1148 // We make an assumption (which is valid for now) that the SIM | 1102 // We make an assumption (which is valid for now) that the SIM |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1611 dictionary->SetBoolean( | 1565 dictionary->SetBoolean( |
| 1612 kTagWimaxAvailable, | 1566 kTagWimaxAvailable, |
| 1613 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); | 1567 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); |
| 1614 dictionary->SetBoolean( | 1568 dictionary->SetBoolean( |
| 1615 kTagWimaxEnabled, | 1569 kTagWimaxEnabled, |
| 1616 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); | 1570 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); |
| 1617 } | 1571 } |
| 1618 | 1572 |
| 1619 } // namespace options | 1573 } // namespace options |
| 1620 } // namespace chromeos | 1574 } // namespace chromeos |
| OLD | NEW |