Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc

Issue 399303003: Eliminate use of sim unlock UI notifications (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 service_path, 697 service_path,
702 base::Bind(&ash::network_connect::ConnectToNetwork, 698 base::Bind(&ash::network_connect::ConnectToNetwork,
703 service_path, owning_window), 699 service_path, owning_window),
704 base::Bind(&ShillError, "RequestReconnect")); 700 base::Bind(&ShillError, "RequestReconnect"));
705 } 701 }
706 702
707 } // namespace 703 } // namespace
708 704
709 InternetOptionsHandler::InternetOptionsHandler() 705 InternetOptionsHandler::InternetOptionsHandler()
710 : weak_factory_(this) { 706 : 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); 707 NetworkHandler::Get()->network_state_handler()->AddObserver(this, FROM_HERE);
716 } 708 }
717 709
718 InternetOptionsHandler::~InternetOptionsHandler() { 710 InternetOptionsHandler::~InternetOptionsHandler() {
719 if (NetworkHandler::IsInitialized()) { 711 if (NetworkHandler::IsInitialized()) {
720 NetworkHandler::Get()->network_state_handler()->RemoveObserver( 712 NetworkHandler::Get()->network_state_handler()->RemoveObserver(
721 this, FROM_HERE); 713 this, FROM_HERE);
722 } 714 }
723 } 715 }
724 716
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 const base::ListValue* args) { 989 const base::ListValue* args) {
998 bool require_pin_new_value; 990 bool require_pin_new_value;
999 if (!args->GetBoolean(0, &require_pin_new_value)) { 991 if (!args->GetBoolean(0, &require_pin_new_value)) {
1000 NOTREACHED(); 992 NOTREACHED();
1001 return; 993 return;
1002 } 994 }
1003 // 1. Bring up SIM unlock dialog, pass new RequirePin setting in URL. 995 // 1. Bring up SIM unlock dialog, pass new RequirePin setting in URL.
1004 // 2. Dialog will ask for current PIN in any case. 996 // 2. Dialog will ask for current PIN in any case.
1005 // 3. If card is locked it will first call PIN unlock operation 997 // 3. If card is locked it will first call PIN unlock operation
1006 // 4. Then it will call Set RequirePin, passing the same PIN. 998 // 4. Then it will call Set RequirePin, passing the same PIN.
1007 // 5. We'll get notified by REQUIRE_PIN_SETTING_CHANGE_ENDED notification. 999 // 5. The dialog may change device properties, in which case
1000 // DevicePropertiesUpdated() will get called which will update the UI.
1008 SimDialogDelegate::SimDialogMode mode; 1001 SimDialogDelegate::SimDialogMode mode;
1009 if (require_pin_new_value) 1002 if (require_pin_new_value)
1010 mode = SimDialogDelegate::SIM_DIALOG_SET_LOCK_ON; 1003 mode = SimDialogDelegate::SIM_DIALOG_SET_LOCK_ON;
1011 else 1004 else
1012 mode = SimDialogDelegate::SIM_DIALOG_SET_LOCK_OFF; 1005 mode = SimDialogDelegate::SIM_DIALOG_SET_LOCK_OFF;
1013 SimDialogDelegate::ShowDialog(GetNativeWindow(), mode); 1006 SimDialogDelegate::ShowDialog(GetNativeWindow(), mode);
1014 } 1007 }
1015 1008
1016 void InternetOptionsHandler::ChangePinCallback(const base::ListValue* args) { 1009 void InternetOptionsHandler::ChangePinCallback(const base::ListValue* args) {
1017 SimDialogDelegate::ShowDialog(GetNativeWindow(), 1010 SimDialogDelegate::ShowDialog(GetNativeWindow(),
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 } 1077 }
1085 1078
1086 void InternetOptionsHandler::NetworkPropertiesUpdated( 1079 void InternetOptionsHandler::NetworkPropertiesUpdated(
1087 const NetworkState* network) { 1080 const NetworkState* network) {
1088 if (!web_ui()) 1081 if (!web_ui())
1089 return; 1082 return;
1090 RefreshNetworkData(); 1083 RefreshNetworkData();
1091 UpdateConnectionData(network->path()); 1084 UpdateConnectionData(network->path());
1092 } 1085 }
1093 1086
1094 void InternetOptionsHandler::Observe( 1087 void InternetOptionsHandler::DevicePropertiesUpdated(
1095 int type, 1088 const DeviceState* device) {
1096 const content::NotificationSource& source, 1089 if (!web_ui())
1097 const content::NotificationDetails& details) { 1090 return;
1098 if (type == chrome::NOTIFICATION_REQUIRE_PIN_SETTING_CHANGE_ENDED) { 1091 if (device->type() != shill::kTypeCellular)
1099 base::FundamentalValue require_pin(*content::Details<bool>(details).ptr()); 1092 return;
1100 web_ui()->CallJavascriptFunction( 1093 const NetworkState* network =
1101 kUpdateSecurityTabFunction, require_pin); 1094 NetworkHandler::Get()->network_state_handler()->FirstNetworkByType(
1102 } else if (type == chrome::NOTIFICATION_ENTER_PIN_ENDED) { 1095 NetworkTypePattern::Cellular());
1103 // We make an assumption (which is valid for now) that the SIM 1096 if (network)
1104 // unlock dialog is put up only when the user is trying to enable 1097 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 } 1098 }
1113 1099
1114 void InternetOptionsHandler::SetServerHostnameCallback( 1100 void InternetOptionsHandler::SetServerHostnameCallback(
1115 const base::ListValue* args) { 1101 const base::ListValue* args) {
1116 std::string service_path, server_hostname; 1102 std::string service_path, server_hostname;
1117 if (args->GetSize() < 2 || 1103 if (args->GetSize() < 2 ||
1118 !args->GetString(0, &service_path) || 1104 !args->GetString(0, &service_path) ||
1119 !args->GetString(1, &server_hostname)) { 1105 !args->GetString(1, &server_hostname)) {
1120 NOTREACHED(); 1106 NOTREACHED();
1121 return; 1107 return;
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 dictionary->SetBoolean( 1554 dictionary->SetBoolean(
1569 kTagWimaxAvailable, 1555 kTagWimaxAvailable,
1570 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); 1556 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax()));
1571 dictionary->SetBoolean( 1557 dictionary->SetBoolean(
1572 kTagWimaxEnabled, 1558 kTagWimaxEnabled,
1573 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); 1559 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax()));
1574 } 1560 }
1575 1561
1576 } // namespace options 1562 } // namespace options
1577 } // namespace chromeos 1563 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698