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

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

Issue 7330009: Removed logic that was disabling other types of network connections during mobile activation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/chromeos/mobile_setup_ui.h" 5 #include "chrome/browser/ui/webui/chromeos/mobile_setup_ui.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 std::string* error); 289 std::string* error);
290 // Sends status updates to WebUI page. 290 // Sends status updates to WebUI page.
291 void UpdatePage(chromeos::CellularNetwork* network, 291 void UpdatePage(chromeos::CellularNetwork* network,
292 const std::string& error_description); 292 const std::string& error_description);
293 // Changes internal state. 293 // Changes internal state.
294 void ChangeState(chromeos::CellularNetwork* network, 294 void ChangeState(chromeos::CellularNetwork* network,
295 PlanActivationState new_state, 295 PlanActivationState new_state,
296 const std::string& error_description); 296 const std::string& error_description);
297 // Prepares network devices for cellular activation process. 297 // Prepares network devices for cellular activation process.
298 void SetupActivationProcess(chromeos::CellularNetwork* network); 298 void SetupActivationProcess(chromeos::CellularNetwork* network);
299 // Disables ethernet and wifi newtorks since they interefere with
300 // detection of restricted pool on cellular side.
301 void DisableOtherNetworks();
302 // Resets network devices after cellular activation process. 299 // Resets network devices after cellular activation process.
303 // |network| should be NULL if the activation process failed. 300 // |network| should be NULL if the activation process failed.
304 void CompleteActivation(chromeos::CellularNetwork* network); 301 void CompleteActivation(chromeos::CellularNetwork* network);
305 // Control routines for handling other types of connections during 302 // Disables SSL certificate revocation checking mechanism. In the case
306 // cellular activation. 303 // where captive portal connection is the only one present, such revocation
307 void ReEnableOtherConnections(); 304 // checks could prevent payment portal page from loading.
305 void DisableCertRevocationChecking();
306 // Reenables SSL certificate revocation checking mechanism.
307 void ReEnableCertRevocationChecking();
308 // Return error message for a given code. 308 // Return error message for a given code.
309 std::string GetErrorMessage(const std::string& code); 309 std::string GetErrorMessage(const std::string& code);
310 310
311 // Converts the currently active CellularNetwork device into a JS object. 311 // Converts the currently active CellularNetwork device into a JS object.
312 static void GetDeviceInfo(chromeos::CellularNetwork* network, 312 static void GetDeviceInfo(chromeos::CellularNetwork* network,
313 DictionaryValue* value); 313 DictionaryValue* value);
314 static bool ShouldReportDeviceState(std::string* state, std::string* error); 314 static bool ShouldReportDeviceState(std::string* state, std::string* error);
315 315
316 // Performs activation state cellular device evaluation. 316 // Performs activation state cellular device evaluation.
317 // Returns false if device activation failed. In this case |error| 317 // Returns false if device activation failed. In this case |error|
318 // will contain error message to be reported to Web UI. 318 // will contain error message to be reported to Web UI.
319 static bool EvaluateCellularDeviceState(bool* report_status, 319 static bool EvaluateCellularDeviceState(bool* report_status,
320 std::string* state, 320 std::string* state,
321 std::string* error); 321 std::string* error);
322 322
323 // Returns next reconnection state based on the current activation phase. 323 // Returns next reconnection state based on the current activation phase.
324 static PlanActivationState GetNextReconnectState(PlanActivationState state); 324 static PlanActivationState GetNextReconnectState(PlanActivationState state);
325 static const char* GetStateDescription(PlanActivationState state); 325 static const char* GetStateDescription(PlanActivationState state);
326 326
327 scoped_refptr<CellularConfigDocument> cellular_config_; 327 scoped_refptr<CellularConfigDocument> cellular_config_;
328 TabContents* tab_contents_; 328 TabContents* tab_contents_;
329 // Internal handler state. 329 // Internal handler state.
330 PlanActivationState state_; 330 PlanActivationState state_;
331 std::string service_path_; 331 std::string service_path_;
332 // Flags that control if wifi and ethernet connection needs to be restored 332 // Flags that controls if cert_checks needs to be restored
333 // after the activation of cellular network. 333 // after the activation of cellular network.
334 bool reenable_wifi_;
335 bool reenable_ethernet_;
336 bool reenable_cert_check_; 334 bool reenable_cert_check_;
337 bool evaluating_; 335 bool evaluating_;
338 // True if we think that another tab is already running activation. 336 // True if we think that another tab is already running activation.
339 bool already_running_; 337 bool already_running_;
340 // Connection retry counter. 338 // Connection retry counter.
341 int connection_retry_count_; 339 int connection_retry_count_;
342 // Post payment reconnect wait counters. 340 // Post payment reconnect wait counters.
343 int reconnect_wait_count_; 341 int reconnect_wait_count_;
344 // Payment portal reload/reconnect attempt count. 342 // Payment portal reload/reconnect attempt count.
345 int payment_reconnect_count_; 343 int payment_reconnect_count_;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 //////////////////////////////////////////////////////////////////////////////// 483 ////////////////////////////////////////////////////////////////////////////////
486 // 484 //
487 // MobileSetupHandler 485 // MobileSetupHandler
488 // 486 //
489 //////////////////////////////////////////////////////////////////////////////// 487 ////////////////////////////////////////////////////////////////////////////////
490 MobileSetupHandler::MobileSetupHandler(const std::string& service_path) 488 MobileSetupHandler::MobileSetupHandler(const std::string& service_path)
491 : cellular_config_(new CellularConfigDocument()), 489 : cellular_config_(new CellularConfigDocument()),
492 tab_contents_(NULL), 490 tab_contents_(NULL),
493 state_(PLAN_ACTIVATION_PAGE_LOADING), 491 state_(PLAN_ACTIVATION_PAGE_LOADING),
494 service_path_(service_path), 492 service_path_(service_path),
495 reenable_wifi_(false),
496 reenable_ethernet_(false),
497 reenable_cert_check_(false), 493 reenable_cert_check_(false),
498 evaluating_(false), 494 evaluating_(false),
499 already_running_(false), 495 already_running_(false),
500 connection_retry_count_(0), 496 connection_retry_count_(0),
501 reconnect_wait_count_(0), 497 reconnect_wait_count_(0),
502 payment_reconnect_count_(0), 498 payment_reconnect_count_(0),
503 activation_attempt_(0) { 499 activation_attempt_(0) {
504 } 500 }
505 501
506 MobileSetupHandler::~MobileSetupHandler() { 502 MobileSetupHandler::~MobileSetupHandler() {
507 reconnect_timer_.Stop(); 503 reconnect_timer_.Stop();
508 chromeos::NetworkLibrary* lib = 504 chromeos::NetworkLibrary* lib =
509 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); 505 chromeos::CrosLibrary::Get()->GetNetworkLibrary();
510 lib->RemoveNetworkManagerObserver(this); 506 lib->RemoveNetworkManagerObserver(this);
511 lib->RemoveObserverForAllNetworks(this); 507 lib->RemoveObserverForAllNetworks(this);
512 if (lib->IsLocked()) 508 if (lib->IsLocked())
513 lib->Unlock(); 509 lib->Unlock();
514 ReEnableOtherConnections(); 510 ReEnableCertRevocationChecking();
515 } 511 }
516 512
517 WebUIMessageHandler* MobileSetupHandler::Attach(WebUI* web_ui) { 513 WebUIMessageHandler* MobileSetupHandler::Attach(WebUI* web_ui) {
518 return WebUIMessageHandler::Attach(web_ui); 514 return WebUIMessageHandler::Attach(web_ui);
519 } 515 }
520 516
521 void MobileSetupHandler::Init(TabContents* contents) { 517 void MobileSetupHandler::Init(TabContents* contents) {
522 tab_contents_ = contents; 518 tab_contents_ = contents;
523 } 519 }
524 520
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 break; 904 break;
909 default: 905 default:
910 break; 906 break;
911 } 907 }
912 break; 908 break;
913 } 909 }
914 case PLAN_ACTIVATION_RECONNECTING_OTASP_TRY: 910 case PLAN_ACTIVATION_RECONNECTING_OTASP_TRY:
915 case PLAN_ACTIVATION_RECONNECTING_PAYMENT: 911 case PLAN_ACTIVATION_RECONNECTING_PAYMENT:
916 case PLAN_ACTIVATION_RECONNECTING: { 912 case PLAN_ACTIVATION_RECONNECTING: {
917 if (network->connected()) { 913 if (network->connected()) {
918 // Make sure other networks are not interfering with our detection of
919 // restricted pool.
920 DisableOtherNetworks();
921 // Wait until the service shows up and gets activated. 914 // Wait until the service shows up and gets activated.
922 switch (network->activation_state()) { 915 switch (network->activation_state()) {
923 case chromeos::ACTIVATION_STATE_PARTIALLY_ACTIVATED: 916 case chromeos::ACTIVATION_STATE_PARTIALLY_ACTIVATED:
924 case chromeos::ACTIVATION_STATE_ACTIVATED: 917 case chromeos::ACTIVATION_STATE_ACTIVATED:
925 if (network->restricted_pool()) { 918 if (network->restricted_pool()) {
926 if (network->error() == chromeos::ERROR_DNS_LOOKUP_FAILED) { 919 if (network->error() == chromeos::ERROR_DNS_LOOKUP_FAILED) {
927 LOG(WARNING) << "No connectivity for device " 920 LOG(WARNING) << "No connectivity for device "
928 << network->service_path().c_str(); 921 << network->service_path().c_str();
929 // If we are connected but there is no connectivity at all, 922 // If we are connected but there is no connectivity at all,
930 // restart the whole process again. 923 // restart the whole process again.
(...skipping 24 matching lines...) Expand all
955 break; 948 break;
956 } 949 }
957 } else if (NeedsReconnecting(network, &new_state, &error_description)) { 950 } else if (NeedsReconnecting(network, &new_state, &error_description)) {
958 evaluating_ = false; 951 evaluating_ = false;
959 return; 952 return;
960 } 953 }
961 break; 954 break;
962 } 955 }
963 case PLAN_ACTIVATION_RECONNECTING_OTASP: { 956 case PLAN_ACTIVATION_RECONNECTING_OTASP: {
964 if (network->connected()) { 957 if (network->connected()) {
965 // Make sure other networks are not interfering with our detection of
966 // restricted pool.
967 DisableOtherNetworks();
968 // Wait until the service shows up and gets activated. 958 // Wait until the service shows up and gets activated.
969 switch (network->activation_state()) { 959 switch (network->activation_state()) {
970 case chromeos::ACTIVATION_STATE_PARTIALLY_ACTIVATED: 960 case chromeos::ACTIVATION_STATE_PARTIALLY_ACTIVATED:
971 case chromeos::ACTIVATION_STATE_ACTIVATED: 961 case chromeos::ACTIVATION_STATE_ACTIVATED:
972 if (network->restricted_pool()) { 962 if (network->restricted_pool()) {
973 LOG(WARNING) << "Still no connectivity after OTASP for device " 963 LOG(WARNING) << "Still no connectivity after OTASP for device "
974 << network->service_path().c_str(); 964 << network->service_path().c_str();
975 // If we have already received payment, don't show the payment 965 // If we have already received payment, don't show the payment
976 // page again. We should try to reconnect after some time instead. 966 // page again. We should try to reconnect after some time instead.
977 if (reconnect_wait_count_ < kMaxReconnectAttemptOTASP) { 967 if (reconnect_wait_count_ < kMaxReconnectAttemptOTASP) {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 GetNetworkLibrary(); 1117 GetNetworkLibrary();
1128 lib->RemoveNetworkManagerObserver(this); 1118 lib->RemoveNetworkManagerObserver(this);
1129 lib->RemoveObserverForAllNetworks(this); 1119 lib->RemoveObserverForAllNetworks(this);
1130 if (lib->IsLocked()) 1120 if (lib->IsLocked())
1131 lib->Unlock(); 1121 lib->Unlock();
1132 // If we have successfully activated the connection, set autoconnect flag. 1122 // If we have successfully activated the connection, set autoconnect flag.
1133 if (network) 1123 if (network)
1134 network->SetAutoConnect(true); 1124 network->SetAutoConnect(true);
1135 // Reactivate other types of connections if we have 1125 // Reactivate other types of connections if we have
1136 // shut them down previously. 1126 // shut them down previously.
1137 ReEnableOtherConnections(); 1127 ReEnableCertRevocationChecking();
1138 } 1128 }
1139 1129
1140 void MobileSetupHandler::UpdatePage( 1130 void MobileSetupHandler::UpdatePage(
1141 chromeos::CellularNetwork* network, 1131 chromeos::CellularNetwork* network,
1142 const std::string& error_description) { 1132 const std::string& error_description) {
1143 DictionaryValue device_dict; 1133 DictionaryValue device_dict;
1144 if (network) 1134 if (network)
1145 GetDeviceInfo(network, &device_dict); 1135 GetDeviceInfo(network, &device_dict);
1146 device_dict.SetInteger("state", state_); 1136 device_dict.SetInteger("state", state_);
1147 if (error_description.length()) 1137 if (error_description.length())
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 break; 1229 break;
1240 case PLAN_ACTIVATION_ERROR: 1230 case PLAN_ACTIVATION_ERROR:
1241 CompleteActivation(NULL); 1231 CompleteActivation(NULL);
1242 UMA_HISTOGRAM_COUNTS("Cellular.PlanFailed", 1); 1232 UMA_HISTOGRAM_COUNTS("Cellular.PlanFailed", 1);
1243 break; 1233 break;
1244 default: 1234 default:
1245 break; 1235 break;
1246 } 1236 }
1247 } 1237 }
1248 1238
1249 void MobileSetupHandler::ReEnableOtherConnections() { 1239 void MobileSetupHandler::ReEnableCertRevocationChecking() {
1250 chromeos::NetworkLibrary* lib = chromeos::CrosLibrary::Get()->
1251 GetNetworkLibrary();
1252 if (reenable_ethernet_) {
1253 reenable_ethernet_ = false;
1254 lib->EnableEthernetNetworkDevice(true);
1255 }
1256 if (reenable_wifi_) {
1257 reenable_wifi_ = false;
1258 lib->EnableWifiNetworkDevice(true);
1259 }
1260
1261 PrefService* prefs = g_browser_process->local_state(); 1240 PrefService* prefs = g_browser_process->local_state();
1262 if (reenable_cert_check_) { 1241 if (reenable_cert_check_) {
1263 prefs->SetBoolean(prefs::kCertRevocationCheckingEnabled, 1242 prefs->SetBoolean(prefs::kCertRevocationCheckingEnabled,
1264 true); 1243 true);
1265 reenable_cert_check_ = false; 1244 reenable_cert_check_ = false;
1266 } 1245 }
1267 } 1246 }
1268 1247
1269 void MobileSetupHandler::SetupActivationProcess( 1248 void MobileSetupHandler::DisableCertRevocationChecking() {
1270 chromeos::CellularNetwork* network) { 1249 // Disable SSL cert checks since we might be performin activation in the
1271 if (!network)
1272 return;
1273
1274 // Disable SSL cert checks since we will be doing this in
1275 // restricted pool. 1250 // restricted pool.
1276 PrefService* prefs = g_browser_process->local_state(); 1251 PrefService* prefs = g_browser_process->local_state();
1277 if (!reenable_cert_check_ && 1252 if (!reenable_cert_check_ &&
1278 prefs->GetBoolean( 1253 prefs->GetBoolean(
1279 prefs::kCertRevocationCheckingEnabled)) { 1254 prefs::kCertRevocationCheckingEnabled)) {
1280 reenable_cert_check_ = true; 1255 reenable_cert_check_ = true;
1281 prefs->SetBoolean(prefs::kCertRevocationCheckingEnabled, false); 1256 prefs->SetBoolean(prefs::kCertRevocationCheckingEnabled, false);
1282 } 1257 }
1258 }
1283 1259
1260 void MobileSetupHandler::SetupActivationProcess(
1261 chromeos::CellularNetwork* network) {
1262 if (!network)
1263 return;
1264
1265 DisableCertRevocationChecking();
1284 chromeos::NetworkLibrary* lib = chromeos::CrosLibrary::Get()-> 1266 chromeos::NetworkLibrary* lib = chromeos::CrosLibrary::Get()->
1285 GetNetworkLibrary(); 1267 GetNetworkLibrary();
1286 // Disable autoconnect to cellular network. 1268 // Disable autoconnect to cellular network.
1287 network->SetAutoConnect(false); 1269 network->SetAutoConnect(false);
1288 1270
1289 // Prevent any other network interference.
1290 DisableOtherNetworks();
1291 lib->Lock(); 1271 lib->Lock();
1292 } 1272 }
1293 1273
1294 void MobileSetupHandler::DisableOtherNetworks() {
1295 chromeos::NetworkLibrary* lib = chromeos::CrosLibrary::Get()->
1296 GetNetworkLibrary();
1297 // Disable ethernet and wifi.
1298 if (lib->ethernet_enabled()) {
1299 reenable_ethernet_ = true;
1300 lib->EnableEthernetNetworkDevice(false);
1301 }
1302 if (lib->wifi_enabled()) {
1303 reenable_wifi_ = true;
1304 lib->EnableWifiNetworkDevice(false);
1305 }
1306 }
1307
1308 bool MobileSetupHandler::GotActivationError( 1274 bool MobileSetupHandler::GotActivationError(
1309 chromeos::CellularNetwork* network, std::string* error) { 1275 chromeos::CellularNetwork* network, std::string* error) {
1310 DCHECK(network); 1276 DCHECK(network);
1311 bool got_error = false; 1277 bool got_error = false;
1312 const char* error_code = kErrorDefault; 1278 const char* error_code = kErrorDefault;
1313 1279
1314 // This is the magic for detection of errors in during activation process. 1280 // This is the magic for detection of errors in during activation process.
1315 if (network->state() == chromeos::STATE_FAILURE && 1281 if (network->state() == chromeos::STATE_FAILURE &&
1316 network->error() == chromeos::ERROR_AAA_FAILED) { 1282 network->error() == chromeos::ERROR_AAA_FAILED) {
1317 if (network->activation_state() == 1283 if (network->activation_state() ==
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 // Set up the chrome://mobilesetup/ source. 1372 // Set up the chrome://mobilesetup/ source.
1407 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); 1373 Profile* profile = Profile::FromBrowserContext(contents->browser_context());
1408 profile->GetChromeURLDataManager()->AddDataSource(html_source); 1374 profile->GetChromeURLDataManager()->AddDataSource(html_source);
1409 } 1375 }
1410 1376
1411 void MobileSetupUI::RenderViewCreated(RenderViewHost* host) { 1377 void MobileSetupUI::RenderViewCreated(RenderViewHost* host) {
1412 ChromeWebUI::RenderViewCreated(host); 1378 ChromeWebUI::RenderViewCreated(host);
1413 // Destroyed by the corresponding RenderViewHost. 1379 // Destroyed by the corresponding RenderViewHost.
1414 new PortalFrameLoadObserver(host, tab_contents()->web_ui()); 1380 new PortalFrameLoadObserver(host, tab_contents()->web_ui());
1415 } 1381 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698