Chromium Code Reviews| Index: chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc |
| =================================================================== |
| --- chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc (revision 71648) |
| +++ chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc (working copy) |
| @@ -62,6 +62,7 @@ |
| const char kErrorNoDevice[] = "no_device"; |
| const char kFailedPaymentError[] = "failed_payment"; |
| const char kFailedConnectivity[] = "connectivity"; |
| +const char kErrorAlreadyRunning[] = "already_running"; |
| // Cellular configuration file path. |
| const char kCellularConfigPath[] = |
| @@ -309,6 +310,8 @@ |
| bool reenable_ethernet_; |
| bool reenable_cert_check_; |
| bool evaluating_; |
| + // True if we think that another tab is already running activation. |
| + bool already_running_; |
| // Connection retry counter. |
| int connection_retry_count_; |
| // Post payment reconnect wait counters. |
| @@ -438,6 +441,7 @@ |
| reenable_ethernet_(false), |
| reenable_cert_check_(false), |
| evaluating_(false), |
| + already_running_(false), |
| connection_retry_count_(0), |
| reconnect_wait_count_(0), |
| activation_attempt_(0) { |
| @@ -447,6 +451,8 @@ |
| reconnect_timer_.Stop(); |
| chromeos::NetworkLibrary* lib = |
| chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| + if (lib->IsLocked()) |
|
Charlie Lee
2011/01/20 20:05:43
probably want to remove network manager observer b
zel
2011/01/20 22:06:14
Done.
|
| + lib->Unlock(); |
| lib->RemoveNetworkManagerObserver(this); |
| lib->RemoveObserverForAllNetworks(this); |
| ReEnableOtherConnections(); |
| @@ -459,7 +465,10 @@ |
| void MobileSetupHandler::Init(TabContents* contents) { |
| tab_contents_ = contents; |
| LoadCellularConfig(); |
| - SetupActivationProcess(GetCellularNetwork(service_path_)); |
| + if (!chromeos::CrosLibrary::Get()->GetNetworkLibrary()->IsLocked()) |
|
Charlie Lee
2011/01/20 20:05:43
if we are using locked only for network activation
zel
2011/01/20 22:06:14
Actually, I wanted to keep this generic at least f
|
| + SetupActivationProcess(GetCellularNetwork(service_path_)); |
| + else |
| + already_running_ = true; |
| } |
| void MobileSetupHandler::RegisterMessages() { |
| @@ -518,15 +527,18 @@ |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| chromeos::NetworkLibrary* lib = |
| chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| - |
| chromeos::CellularNetwork* network = GetCellularNetwork(service_path_); |
| // Check if we can start activation process. |
| - if (!network) { |
| - std::string error(kErrorNoService); |
| - if (!lib->cellular_available()) |
| + if (!network || already_running_) { |
| + std::string error; |
| + if (already_running_) |
| + error = kErrorAlreadyRunning; |
| + else if (!lib->cellular_available()) |
| error = kErrorNoDevice; |
| else if (!lib->cellular_enabled()) |
| error = kErrorDisabled; |
| + else |
| + error = kErrorNoService; |
| ChangeState(NULL, PLAN_ACTIVATION_ERROR, GetErrorMessage(error)); |
| return; |
| } |
| @@ -1008,6 +1020,7 @@ |
| // Remove observers, we are done with this page. |
| chromeos::NetworkLibrary* lib = chromeos::CrosLibrary::Get()-> |
| GetNetworkLibrary(); |
| + lib->Unlock(); |
|
Charlie Lee
2011/01/20 20:05:43
same here. move this below remove network manager
zel
2011/01/20 22:06:14
Done.
|
| // If we have successfully activated the connection, set autoconnect flag. |
| if (network) { |
| network->set_auto_connect(true); |
| @@ -1163,7 +1176,9 @@ |
| network->set_auto_connect(false); |
| lib->SaveCellularNetwork(network); |
| + // Prevent any other network interference. |
| DisableOtherNetworks(); |
| + lib->Lock(); |
| } |
| void MobileSetupHandler::DisableOtherNetworks() { |