| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 const char kRefreshNetworkDataFunction[] = | 129 const char kRefreshNetworkDataFunction[] = |
| 130 "options.network.NetworkList.refreshNetworkData"; | 130 "options.network.NetworkList.refreshNetworkData"; |
| 131 const char kSetDefaultNetworkIconsFunction[] = | 131 const char kSetDefaultNetworkIconsFunction[] = |
| 132 "options.network.NetworkList.setDefaultNetworkIcons"; | 132 "options.network.NetworkList.setDefaultNetworkIcons"; |
| 133 const char kShowDetailedInfoFunction[] = | 133 const char kShowDetailedInfoFunction[] = |
| 134 "options.internet.DetailsInternetPage.showDetailedInfo"; | 134 "options.internet.DetailsInternetPage.showDetailedInfo"; |
| 135 const char kUpdateConnectionDataFunction[] = | 135 const char kUpdateConnectionDataFunction[] = |
| 136 "options.internet.DetailsInternetPage.updateConnectionData"; | 136 "options.internet.DetailsInternetPage.updateConnectionData"; |
| 137 const char kUpdateCarrierFunction[] = | 137 const char kUpdateCarrierFunction[] = |
| 138 "options.internet.DetailsInternetPage.updateCarrier"; | 138 "options.internet.DetailsInternetPage.updateCarrier"; |
| 139 const char kUpdateLoggedInUserTypeFunction[] = |
| 140 "options.network.NetworkList.updateLoggedInUserType"; |
| 139 const char kUpdateSecurityTabFunction[] = | 141 const char kUpdateSecurityTabFunction[] = |
| 140 "options.internet.DetailsInternetPage.updateSecurityTab"; | 142 "options.internet.DetailsInternetPage.updateSecurityTab"; |
| 141 | 143 |
| 142 // These are used to register message handlers with JavaScript. | 144 // These are used to register message handlers with JavaScript. |
| 143 const char kBuyDataPlanMessage[] = "buyDataPlan"; | 145 const char kBuyDataPlanMessage[] = "buyDataPlan"; |
| 144 const char kChangePinMessage[] = "changePin"; | 146 const char kChangePinMessage[] = "changePin"; |
| 145 const char kDisableCellularMessage[] = "disableCellular"; | 147 const char kDisableCellularMessage[] = "disableCellular"; |
| 146 const char kDisableWifiMessage[] = "disableWifi"; | 148 const char kDisableWifiMessage[] = "disableWifi"; |
| 147 const char kDisableWimaxMessage[] = "disableWimax"; | 149 const char kDisableWimaxMessage[] = "disableWimax"; |
| 148 const char kEnableCellularMessage[] = "enableCellular"; | 150 const char kEnableCellularMessage[] = "enableCellular"; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 id = IDS_CHROMEOS_NETWORK_STATE_ACTIVATION_FAILURE; | 337 id = IDS_CHROMEOS_NETWORK_STATE_ACTIVATION_FAILURE; |
| 336 else if (state == flimflam::kStatePortal) | 338 else if (state == flimflam::kStatePortal) |
| 337 id = IDS_CHROMEOS_NETWORK_STATE_PORTAL; | 339 id = IDS_CHROMEOS_NETWORK_STATE_PORTAL; |
| 338 else if (state == flimflam::kStateOnline) | 340 else if (state == flimflam::kStateOnline) |
| 339 id = IDS_CHROMEOS_NETWORK_STATE_ONLINE; | 341 id = IDS_CHROMEOS_NETWORK_STATE_ONLINE; |
| 340 else | 342 else |
| 341 id = IDS_CHROMEOS_NETWORK_STATE_UNRECOGNIZED; | 343 id = IDS_CHROMEOS_NETWORK_STATE_UNRECOGNIZED; |
| 342 return l10n_util::GetStringUTF8(id); | 344 return l10n_util::GetStringUTF8(id); |
| 343 } | 345 } |
| 344 | 346 |
| 347 std::string LoggedInUserTypeToString( |
| 348 LoginState::LoggedInUserType type) { |
| 349 switch (type) { |
| 350 case LoginState::LOGGED_IN_USER_NONE: |
| 351 return "none"; |
| 352 case LoginState::LOGGED_IN_USER_REGULAR: |
| 353 return "regular"; |
| 354 case LoginState::LOGGED_IN_USER_OWNER: |
| 355 return "owner"; |
| 356 case LoginState::LOGGED_IN_USER_GUEST: |
| 357 return "guest"; |
| 358 case LoginState::LOGGED_IN_USER_RETAIL_MODE: |
| 359 return "retail-mode"; |
| 360 case LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT: |
| 361 return "public-account"; |
| 362 case LoginState::LOGGED_IN_USER_LOCALLY_MANAGED: |
| 363 return "locally-managed"; |
| 364 case LoginState::LOGGED_IN_USER_KIOSK_APP: |
| 365 return "kiosk-app"; |
| 366 default: |
| 367 return ""; |
| 368 } |
| 369 } |
| 370 |
| 345 std::string EncryptionString(const std::string& security, | 371 std::string EncryptionString(const std::string& security, |
| 346 const std::string& eap_method) { | 372 const std::string& eap_method) { |
| 347 if (security == flimflam::kSecurityNone) | 373 if (security == flimflam::kSecurityNone) |
| 348 return ""; | 374 return ""; |
| 349 if (security == flimflam::kSecurityWpa) | 375 if (security == flimflam::kSecurityWpa) |
| 350 return "WPA"; | 376 return "WPA"; |
| 351 if (security == flimflam::kSecurityWep) | 377 if (security == flimflam::kSecurityWep) |
| 352 return "WEP"; | 378 return "WEP"; |
| 353 if (security == flimflam::kSecurityRsn) | 379 if (security == flimflam::kSecurityRsn) |
| 354 return "RSN"; | 380 return "RSN"; |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 | 791 |
| 766 } // namespace | 792 } // namespace |
| 767 | 793 |
| 768 InternetOptionsHandler::InternetOptionsHandler() | 794 InternetOptionsHandler::InternetOptionsHandler() |
| 769 : weak_factory_(this) { | 795 : weak_factory_(this) { |
| 770 registrar_.Add(this, chrome::NOTIFICATION_REQUIRE_PIN_SETTING_CHANGE_ENDED, | 796 registrar_.Add(this, chrome::NOTIFICATION_REQUIRE_PIN_SETTING_CHANGE_ENDED, |
| 771 content::NotificationService::AllSources()); | 797 content::NotificationService::AllSources()); |
| 772 registrar_.Add(this, chrome::NOTIFICATION_ENTER_PIN_ENDED, | 798 registrar_.Add(this, chrome::NOTIFICATION_ENTER_PIN_ENDED, |
| 773 content::NotificationService::AllSources()); | 799 content::NotificationService::AllSources()); |
| 774 NetworkHandler::Get()->network_state_handler()->AddObserver(this, FROM_HERE); | 800 NetworkHandler::Get()->network_state_handler()->AddObserver(this, FROM_HERE); |
| 801 LoginState::Get()->AddObserver(this); |
| 775 } | 802 } |
| 776 | 803 |
| 777 InternetOptionsHandler::~InternetOptionsHandler() { | 804 InternetOptionsHandler::~InternetOptionsHandler() { |
| 778 if (NetworkHandler::IsInitialized()) { | 805 if (NetworkHandler::IsInitialized()) { |
| 779 NetworkHandler::Get()->network_state_handler()->RemoveObserver( | 806 NetworkHandler::Get()->network_state_handler()->RemoveObserver( |
| 780 this, FROM_HERE); | 807 this, FROM_HERE); |
| 781 } | 808 } |
| 809 if (LoginState::Get()->IsInitialized()) |
| 810 LoginState::Get()->RemoveObserver(this); |
| 782 } | 811 } |
| 783 | 812 |
| 784 void InternetOptionsHandler::GetLocalizedValues( | 813 void InternetOptionsHandler::GetLocalizedValues( |
| 785 base::DictionaryValue* localized_strings) { | 814 base::DictionaryValue* localized_strings) { |
| 786 DCHECK(localized_strings); | 815 DCHECK(localized_strings); |
| 787 | 816 |
| 788 static OptionsStringResource resources[] = { | 817 static OptionsStringResource resources[] = { |
| 789 | 818 |
| 790 // Main settings page. | 819 // Main settings page. |
| 791 | 820 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 dictionary.SetString(kTagCellular, | 984 dictionary.SetString(kTagCellular, |
| 956 GetIconDataUrl(IDR_AURA_UBER_TRAY_NETWORK_BARS_DARK)); | 985 GetIconDataUrl(IDR_AURA_UBER_TRAY_NETWORK_BARS_DARK)); |
| 957 dictionary.SetString(kTagWifi, | 986 dictionary.SetString(kTagWifi, |
| 958 GetIconDataUrl(IDR_AURA_UBER_TRAY_NETWORK_ARCS_DARK)); | 987 GetIconDataUrl(IDR_AURA_UBER_TRAY_NETWORK_ARCS_DARK)); |
| 959 dictionary.SetString(kTagVpn, | 988 dictionary.SetString(kTagVpn, |
| 960 GetIconDataUrl(IDR_AURA_UBER_TRAY_NETWORK_VPN)); | 989 GetIconDataUrl(IDR_AURA_UBER_TRAY_NETWORK_VPN)); |
| 961 web_ui()->CallJavascriptFunction(kSetDefaultNetworkIconsFunction, | 990 web_ui()->CallJavascriptFunction(kSetDefaultNetworkIconsFunction, |
| 962 dictionary); | 991 dictionary); |
| 963 NetworkHandler::Get()->network_state_handler()->RequestScan(); | 992 NetworkHandler::Get()->network_state_handler()->RequestScan(); |
| 964 RefreshNetworkData(); | 993 RefreshNetworkData(); |
| 994 UpdateLoggedInUserType(); |
| 965 } | 995 } |
| 966 | 996 |
| 967 void InternetOptionsHandler::RegisterMessages() { | 997 void InternetOptionsHandler::RegisterMessages() { |
| 968 // Setup handlers specific to this panel. | 998 // Setup handlers specific to this panel. |
| 969 web_ui()->RegisterMessageCallback(kNetworkCommandMessage, | 999 web_ui()->RegisterMessageCallback(kNetworkCommandMessage, |
| 970 base::Bind(&InternetOptionsHandler::NetworkCommandCallback, | 1000 base::Bind(&InternetOptionsHandler::NetworkCommandCallback, |
| 971 base::Unretained(this))); | 1001 base::Unretained(this))); |
| 972 web_ui()->RegisterMessageCallback(kRefreshNetworksMessage, | 1002 web_ui()->RegisterMessageCallback(kRefreshNetworksMessage, |
| 973 base::Bind(&InternetOptionsHandler::RefreshNetworksCallback, | 1003 base::Bind(&InternetOptionsHandler::RefreshNetworksCallback, |
| 974 base::Unretained(this))); | 1004 base::Unretained(this))); |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1293 } | 1323 } |
| 1294 | 1324 |
| 1295 void InternetOptionsHandler::NetworkPropertiesUpdated( | 1325 void InternetOptionsHandler::NetworkPropertiesUpdated( |
| 1296 const NetworkState* network) { | 1326 const NetworkState* network) { |
| 1297 if (!web_ui()) | 1327 if (!web_ui()) |
| 1298 return; | 1328 return; |
| 1299 RefreshNetworkData(); | 1329 RefreshNetworkData(); |
| 1300 UpdateConnectionData(network->path()); | 1330 UpdateConnectionData(network->path()); |
| 1301 } | 1331 } |
| 1302 | 1332 |
| 1333 void InternetOptionsHandler::LoggedInStateChanged( |
| 1334 LoginState::LoggedInState state) { |
| 1335 UpdateLoggedInUserType(); |
| 1336 } |
| 1337 |
| 1338 void InternetOptionsHandler::UpdateLoggedInUserType() { |
| 1339 if (!web_ui()) |
| 1340 return; |
| 1341 base::StringValue login_type( |
| 1342 LoggedInUserTypeToString(LoginState::Get()->GetLoggedInUserType())); |
| 1343 web_ui()->CallJavascriptFunction( |
| 1344 kUpdateLoggedInUserTypeFunction, login_type); |
| 1345 } |
| 1346 |
| 1303 void InternetOptionsHandler::Observe( | 1347 void InternetOptionsHandler::Observe( |
| 1304 int type, | 1348 int type, |
| 1305 const content::NotificationSource& source, | 1349 const content::NotificationSource& source, |
| 1306 const content::NotificationDetails& details) { | 1350 const content::NotificationDetails& details) { |
| 1307 OptionsPageUIHandler::Observe(type, source, details); | 1351 OptionsPageUIHandler::Observe(type, source, details); |
| 1308 if (type == chrome::NOTIFICATION_REQUIRE_PIN_SETTING_CHANGE_ENDED) { | 1352 if (type == chrome::NOTIFICATION_REQUIRE_PIN_SETTING_CHANGE_ENDED) { |
| 1309 base::FundamentalValue require_pin(*content::Details<bool>(details).ptr()); | 1353 base::FundamentalValue require_pin(*content::Details<bool>(details).ptr()); |
| 1310 web_ui()->CallJavascriptFunction( | 1354 web_ui()->CallJavascriptFunction( |
| 1311 kUpdateSecurityTabFunction, require_pin); | 1355 kUpdateSecurityTabFunction, require_pin); |
| 1312 } else if (type == chrome::NOTIFICATION_ENTER_PIN_ENDED) { | 1356 } else if (type == chrome::NOTIFICATION_ENTER_PIN_ENDED) { |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2012 cellular && cellular->support_network_scan()); | 2056 cellular && cellular->support_network_scan()); |
| 2013 | 2057 |
| 2014 dictionary->SetBoolean(kTagWimaxAvailable, | 2058 dictionary->SetBoolean(kTagWimaxAvailable, |
| 2015 handler->IsTechnologyAvailable(flimflam::kTypeWimax)); | 2059 handler->IsTechnologyAvailable(flimflam::kTypeWimax)); |
| 2016 dictionary->SetBoolean(kTagWimaxEnabled, | 2060 dictionary->SetBoolean(kTagWimaxEnabled, |
| 2017 handler->IsTechnologyEnabled(flimflam::kTypeWimax)); | 2061 handler->IsTechnologyEnabled(flimflam::kTypeWimax)); |
| 2018 } | 2062 } |
| 2019 | 2063 |
| 2020 } // namespace options | 2064 } // namespace options |
| 2021 } // namespace chromeos | 2065 } // namespace chromeos |
| OLD | NEW |