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> |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 const char kRefreshNetworkDataFunction[] = | 128 const char kRefreshNetworkDataFunction[] = |
| 129 "options.network.NetworkList.refreshNetworkData"; | 129 "options.network.NetworkList.refreshNetworkData"; |
| 130 const char kSetDefaultNetworkIconsFunction[] = | 130 const char kSetDefaultNetworkIconsFunction[] = |
| 131 "options.network.NetworkList.setDefaultNetworkIcons"; | 131 "options.network.NetworkList.setDefaultNetworkIcons"; |
| 132 const char kShowDetailedInfoFunction[] = | 132 const char kShowDetailedInfoFunction[] = |
| 133 "options.internet.DetailsInternetPage.showDetailedInfo"; | 133 "options.internet.DetailsInternetPage.showDetailedInfo"; |
| 134 const char kUpdateConnectionDataFunction[] = | 134 const char kUpdateConnectionDataFunction[] = |
| 135 "options.internet.DetailsInternetPage.updateConnectionData"; | 135 "options.internet.DetailsInternetPage.updateConnectionData"; |
| 136 const char kUpdateCarrierFunction[] = | 136 const char kUpdateCarrierFunction[] = |
| 137 "options.internet.DetailsInternetPage.updateCarrier"; | 137 "options.internet.DetailsInternetPage.updateCarrier"; |
| 138 const char kUpdateLoggedInUserTypeFunction[] = | |
| 139 "options.network.NetworkList.updateLoggedInUserType"; | |
| 138 const char kUpdateSecurityTabFunction[] = | 140 const char kUpdateSecurityTabFunction[] = |
| 139 "options.internet.DetailsInternetPage.updateSecurityTab"; | 141 "options.internet.DetailsInternetPage.updateSecurityTab"; |
| 140 | 142 |
| 141 // These are used to register message handlers with JavaScript. | 143 // These are used to register message handlers with JavaScript. |
| 142 const char kBuyDataPlanMessage[] = "buyDataPlan"; | 144 const char kBuyDataPlanMessage[] = "buyDataPlan"; |
| 143 const char kChangePinMessage[] = "changePin"; | 145 const char kChangePinMessage[] = "changePin"; |
| 144 const char kDisableCellularMessage[] = "disableCellular"; | 146 const char kDisableCellularMessage[] = "disableCellular"; |
| 145 const char kDisableWifiMessage[] = "disableWifi"; | 147 const char kDisableWifiMessage[] = "disableWifi"; |
| 146 const char kDisableWimaxMessage[] = "disableWimax"; | 148 const char kDisableWimaxMessage[] = "disableWimax"; |
| 147 const char kEnableCellularMessage[] = "enableCellular"; | 149 const char kEnableCellularMessage[] = "enableCellular"; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 id = IDS_CHROMEOS_NETWORK_STATE_ACTIVATION_FAILURE; | 336 id = IDS_CHROMEOS_NETWORK_STATE_ACTIVATION_FAILURE; |
| 335 else if (state == flimflam::kStatePortal) | 337 else if (state == flimflam::kStatePortal) |
| 336 id = IDS_CHROMEOS_NETWORK_STATE_PORTAL; | 338 id = IDS_CHROMEOS_NETWORK_STATE_PORTAL; |
| 337 else if (state == flimflam::kStateOnline) | 339 else if (state == flimflam::kStateOnline) |
| 338 id = IDS_CHROMEOS_NETWORK_STATE_ONLINE; | 340 id = IDS_CHROMEOS_NETWORK_STATE_ONLINE; |
| 339 else | 341 else |
| 340 id = IDS_CHROMEOS_NETWORK_STATE_UNRECOGNIZED; | 342 id = IDS_CHROMEOS_NETWORK_STATE_UNRECOGNIZED; |
| 341 return l10n_util::GetStringUTF8(id); | 343 return l10n_util::GetStringUTF8(id); |
| 342 } | 344 } |
| 343 | 345 |
| 346 std::string LoggedInUserTypeToString( | |
| 347 LoginState::LoggedInUserType type) { | |
| 348 switch (type) { | |
| 349 case LoginState::LOGGED_IN_USER_NONE: | |
| 350 return "none"; | |
| 351 case LoginState::LOGGED_IN_USER_REGULAR: | |
| 352 return "regular"; | |
| 353 case LoginState::LOGGED_IN_USER_OWNER: | |
| 354 return "owner"; | |
| 355 case LoginState::LOGGED_IN_USER_GUEST: | |
| 356 return "guest"; | |
| 357 case LoginState::LOGGED_IN_USER_RETAIL_MODE: | |
| 358 return "retail-mode"; | |
| 359 case LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT: | |
| 360 return "public-account"; | |
| 361 case LoginState::LOGGED_IN_USER_LOCALLY_MANAGED: | |
| 362 return "locally-managed"; | |
| 363 case LoginState::LOGGED_IN_USER_KIOSK_APP: | |
| 364 return "kiosk-app"; | |
| 365 default: | |
| 366 return ""; | |
| 367 } | |
| 368 } | |
| 369 | |
| 344 std::string EncryptionString(const std::string& security, | 370 std::string EncryptionString(const std::string& security, |
| 345 const std::string& eap_method) { | 371 const std::string& eap_method) { |
| 346 if (security == flimflam::kSecurityNone) | 372 if (security == flimflam::kSecurityNone) |
| 347 return ""; | 373 return ""; |
| 348 if (security == flimflam::kSecurityWpa) | 374 if (security == flimflam::kSecurityWpa) |
| 349 return "WPA"; | 375 return "WPA"; |
| 350 if (security == flimflam::kSecurityWep) | 376 if (security == flimflam::kSecurityWep) |
| 351 return "WEP"; | 377 return "WEP"; |
| 352 if (security == flimflam::kSecurityRsn) | 378 if (security == flimflam::kSecurityRsn) |
| 353 return "RSN"; | 379 return "RSN"; |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 770 | 796 |
| 771 } // namespace | 797 } // namespace |
| 772 | 798 |
| 773 InternetOptionsHandler::InternetOptionsHandler() | 799 InternetOptionsHandler::InternetOptionsHandler() |
| 774 : weak_factory_(this) { | 800 : weak_factory_(this) { |
| 775 registrar_.Add(this, chrome::NOTIFICATION_REQUIRE_PIN_SETTING_CHANGE_ENDED, | 801 registrar_.Add(this, chrome::NOTIFICATION_REQUIRE_PIN_SETTING_CHANGE_ENDED, |
| 776 content::NotificationService::AllSources()); | 802 content::NotificationService::AllSources()); |
| 777 registrar_.Add(this, chrome::NOTIFICATION_ENTER_PIN_ENDED, | 803 registrar_.Add(this, chrome::NOTIFICATION_ENTER_PIN_ENDED, |
| 778 content::NotificationService::AllSources()); | 804 content::NotificationService::AllSources()); |
| 779 NetworkHandler::Get()->network_state_handler()->AddObserver(this, FROM_HERE); | 805 NetworkHandler::Get()->network_state_handler()->AddObserver(this, FROM_HERE); |
| 806 LoginState::Get()->AddObserver(this); | |
| 780 } | 807 } |
| 781 | 808 |
| 782 InternetOptionsHandler::~InternetOptionsHandler() { | 809 InternetOptionsHandler::~InternetOptionsHandler() { |
| 783 if (NetworkHandler::IsInitialized()) { | 810 if (NetworkHandler::IsInitialized()) { |
| 784 NetworkHandler::Get()->network_state_handler()->RemoveObserver( | 811 NetworkHandler::Get()->network_state_handler()->RemoveObserver( |
| 785 this, FROM_HERE); | 812 this, FROM_HERE); |
| 786 } | 813 } |
| 814 if (LoginState::Get()->IsInitialized()) | |
| 815 LoginState::Get()->RemoveObserver(this); | |
| 787 } | 816 } |
| 788 | 817 |
| 789 void InternetOptionsHandler::GetLocalizedValues( | 818 void InternetOptionsHandler::GetLocalizedValues( |
| 790 base::DictionaryValue* localized_strings) { | 819 base::DictionaryValue* localized_strings) { |
| 791 DCHECK(localized_strings); | 820 DCHECK(localized_strings); |
| 792 | 821 |
| 793 static OptionsStringResource resources[] = { | 822 static OptionsStringResource resources[] = { |
| 794 | 823 |
| 795 // Main settings page. | 824 // Main settings page. |
| 796 | 825 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 960 dictionary.SetString(kTagCellular, | 989 dictionary.SetString(kTagCellular, |
| 961 GetIconDataUrl(IDR_AURA_UBER_TRAY_NETWORK_BARS_DARK)); | 990 GetIconDataUrl(IDR_AURA_UBER_TRAY_NETWORK_BARS_DARK)); |
| 962 dictionary.SetString(kTagWifi, | 991 dictionary.SetString(kTagWifi, |
| 963 GetIconDataUrl(IDR_AURA_UBER_TRAY_NETWORK_ARCS_DARK)); | 992 GetIconDataUrl(IDR_AURA_UBER_TRAY_NETWORK_ARCS_DARK)); |
| 964 dictionary.SetString(kTagVpn, | 993 dictionary.SetString(kTagVpn, |
| 965 GetIconDataUrl(IDR_AURA_UBER_TRAY_NETWORK_VPN)); | 994 GetIconDataUrl(IDR_AURA_UBER_TRAY_NETWORK_VPN)); |
| 966 web_ui()->CallJavascriptFunction(kSetDefaultNetworkIconsFunction, | 995 web_ui()->CallJavascriptFunction(kSetDefaultNetworkIconsFunction, |
| 967 dictionary); | 996 dictionary); |
| 968 NetworkHandler::Get()->network_state_handler()->RequestScan(); | 997 NetworkHandler::Get()->network_state_handler()->RequestScan(); |
| 969 RefreshNetworkData(); | 998 RefreshNetworkData(); |
| 999 UpdateLoggedInUserType(); | |
| 970 } | 1000 } |
| 971 | 1001 |
| 972 void InternetOptionsHandler::RegisterMessages() { | 1002 void InternetOptionsHandler::RegisterMessages() { |
| 973 // Setup handlers specific to this panel. | 1003 // Setup handlers specific to this panel. |
| 974 web_ui()->RegisterMessageCallback(kNetworkCommandMessage, | 1004 web_ui()->RegisterMessageCallback(kNetworkCommandMessage, |
| 975 base::Bind(&InternetOptionsHandler::NetworkCommandCallback, | 1005 base::Bind(&InternetOptionsHandler::NetworkCommandCallback, |
| 976 base::Unretained(this))); | 1006 base::Unretained(this))); |
| 977 web_ui()->RegisterMessageCallback(kRefreshNetworksMessage, | 1007 web_ui()->RegisterMessageCallback(kRefreshNetworksMessage, |
| 978 base::Bind(&InternetOptionsHandler::RefreshNetworksCallback, | 1008 base::Bind(&InternetOptionsHandler::RefreshNetworksCallback, |
| 979 base::Unretained(this))); | 1009 base::Unretained(this))); |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1308 } | 1338 } |
| 1309 | 1339 |
| 1310 void InternetOptionsHandler::NetworkPropertiesUpdated( | 1340 void InternetOptionsHandler::NetworkPropertiesUpdated( |
| 1311 const NetworkState* network) { | 1341 const NetworkState* network) { |
| 1312 if (!web_ui()) | 1342 if (!web_ui()) |
| 1313 return; | 1343 return; |
| 1314 RefreshNetworkData(); | 1344 RefreshNetworkData(); |
| 1315 UpdateConnectionData(network->path()); | 1345 UpdateConnectionData(network->path()); |
| 1316 } | 1346 } |
| 1317 | 1347 |
| 1348 void InternetOptionsHandler::LoggedInStateChanged( | |
| 1349 LoginState::LoggedInState state) { | |
| 1350 UpdateLoggedInUserType(); | |
| 1351 } | |
| 1352 | |
| 1353 void InternetOptionsHandler::UpdateLoggedInUserType() { | |
| 1354 if (web_ui()) { | |
|
stevenjb
2013/09/10 16:58:05
nit: if (!web_ui()) return;
armansito
2013/09/10 21:55:19
Done.
| |
| 1355 base::StringValue login_type( | |
| 1356 LoggedInUserTypeToString(LoginState::Get()->GetLoggedInUserType())); | |
| 1357 web_ui()->CallJavascriptFunction( | |
| 1358 kUpdateLoggedInUserTypeFunction, login_type); | |
| 1359 } | |
| 1360 } | |
| 1361 | |
| 1318 void InternetOptionsHandler::Observe( | 1362 void InternetOptionsHandler::Observe( |
| 1319 int type, | 1363 int type, |
| 1320 const content::NotificationSource& source, | 1364 const content::NotificationSource& source, |
| 1321 const content::NotificationDetails& details) { | 1365 const content::NotificationDetails& details) { |
| 1322 OptionsPageUIHandler::Observe(type, source, details); | 1366 OptionsPageUIHandler::Observe(type, source, details); |
| 1323 if (type == chrome::NOTIFICATION_REQUIRE_PIN_SETTING_CHANGE_ENDED) { | 1367 if (type == chrome::NOTIFICATION_REQUIRE_PIN_SETTING_CHANGE_ENDED) { |
| 1324 base::FundamentalValue require_pin(*content::Details<bool>(details).ptr()); | 1368 base::FundamentalValue require_pin(*content::Details<bool>(details).ptr()); |
| 1325 web_ui()->CallJavascriptFunction( | 1369 web_ui()->CallJavascriptFunction( |
| 1326 kUpdateSecurityTabFunction, require_pin); | 1370 kUpdateSecurityTabFunction, require_pin); |
| 1327 } else if (type == chrome::NOTIFICATION_ENTER_PIN_ENDED) { | 1371 } else if (type == chrome::NOTIFICATION_ENTER_PIN_ENDED) { |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2035 cellular && cellular->support_network_scan()); | 2079 cellular && cellular->support_network_scan()); |
| 2036 | 2080 |
| 2037 dictionary->SetBoolean(kTagWimaxAvailable, | 2081 dictionary->SetBoolean(kTagWimaxAvailable, |
| 2038 handler->IsTechnologyAvailable(flimflam::kTypeWimax)); | 2082 handler->IsTechnologyAvailable(flimflam::kTypeWimax)); |
| 2039 dictionary->SetBoolean(kTagWimaxEnabled, | 2083 dictionary->SetBoolean(kTagWimaxEnabled, |
| 2040 handler->IsTechnologyEnabled(flimflam::kTypeWimax)); | 2084 handler->IsTechnologyEnabled(flimflam::kTypeWimax)); |
| 2041 } | 2085 } |
| 2042 | 2086 |
| 2043 } // namespace options | 2087 } // namespace options |
| 2044 } // namespace chromeos | 2088 } // namespace chromeos |
| OLD | NEW |