summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc')
-rw-r--r--chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc79
1 files changed, 34 insertions, 45 deletions
diff --git a/chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc b/chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc
index 2295df2..67305ed 100644
--- a/chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc
+++ b/chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/chromeos/dom_ui/mobile_setup_ui.h"
+#include <algorithm>
#include <map>
#include <string>
@@ -124,10 +125,11 @@ class MobileSetupUIHTMLSource : public ChromeURLDataManager::DataSource {
};
// The handler for Javascript messages related to the "register" view.
-class MobileSetupHandler : public DOMMessageHandler,
- public chromeos::NetworkLibrary::Observer,
- public chromeos::NetworkLibrary::PropertyObserver,
- public base::SupportsWeakPtr<MobileSetupHandler> {
+class MobileSetupHandler
+ : public DOMMessageHandler,
+ public chromeos::NetworkLibrary::NetworkManagerObserver,
+ public chromeos::NetworkLibrary::NetworkObserver,
+ public base::SupportsWeakPtr<MobileSetupHandler> {
public:
explicit MobileSetupHandler(const std::string& service_path);
virtual ~MobileSetupHandler();
@@ -139,12 +141,11 @@ class MobileSetupHandler : public DOMMessageHandler,
virtual DOMMessageHandler* Attach(DOMUI* dom_ui);
virtual void RegisterMessages();
- // NetworkLibrary::Observer implementation.
- virtual void NetworkChanged(chromeos::NetworkLibrary* obj);
- // NetworkLibrary::PropertyObserver implementation.
- virtual void PropertyChanged(const char* service_path,
- const char* key,
- const Value* value);
+ // NetworkLibrary::NetworkManagerObserver implementation.
+ virtual void OnNetworkManagerChanged(chromeos::NetworkLibrary* obj);
+ // NetworkLibrary::NetworkObserver implementation.
+ virtual void OnNetworkChanged(chromeos::NetworkLibrary* obj,
+ const chromeos::Network* network);
private:
typedef enum PlanActivationState {
@@ -355,8 +356,8 @@ MobileSetupHandler::MobileSetupHandler(const std::string& service_path)
MobileSetupHandler::~MobileSetupHandler() {
chromeos::NetworkLibrary* lib =
chromeos::CrosLibrary::Get()->GetNetworkLibrary();
- lib->RemoveObserver(this);
- lib->RemoveProperyObserver(this);
+ lib->RemoveNetworkManagerObserver(this);
+ lib->RemoveObserverForAllNetworks(this);
ReEnableOtherConnections();
}
@@ -379,35 +380,25 @@ void MobileSetupHandler::RegisterMessages() {
NewCallback(this, &MobileSetupHandler::HandleSetTransactionStatus));
}
-void MobileSetupHandler::NetworkChanged(chromeos::NetworkLibrary* lib) {
+void MobileSetupHandler::OnNetworkManagerChanged(
+ chromeos::NetworkLibrary* cros) {
if (state_ == PLAN_ACTIVATION_PAGE_LOADING)
return;
+ // Note that even though we get here when the service has
+ // reappeared after disappearing earlier in the activation
+ // process, there's no need to re-establish the NetworkObserver,
+ // because the service path remains the same.
EvaluateCellularNetwork(GetCellularNetwork(service_path_));
}
-void MobileSetupHandler::PropertyChanged(const char* service_path,
- const char* key,
- const Value* value) {
-
+void MobileSetupHandler::OnNetworkChanged(chromeos::NetworkLibrary* cros,
+ const chromeos::Network* network) {
if (state_ == PLAN_ACTIVATION_PAGE_LOADING)
return;
- // TODO(zelidrag, ers): Remove this once we flip the notification machanism.
- chromeos::CrosLibrary::Get()->GetNetworkLibrary()->UpdateSystemInfo();
-
- chromeos::CellularNetwork* network = GetCellularNetwork(service_path_);
- if (!network) {
- EvaluateCellularNetwork(NULL);
- return;
- }
- if (network->service_path() != service_path) {
- NOTREACHED();
- return;
- }
- std::string value_string;
- LOG(INFO) << "Cellular property change: " << key << " = " <<
- value_string.c_str();
-
- EvaluateCellularNetwork(network);
+ DCHECK(network && network->type() == chromeos::TYPE_CELLULAR);
+ EvaluateCellularNetwork(
+ static_cast<chromeos::CellularNetwork*>(
+ const_cast<chromeos::Network*>(network)));
}
void MobileSetupHandler::HandleCloseTab(const ListValue* args) {
@@ -445,14 +436,12 @@ void MobileSetupHandler::StartActivation() {
ChangeState(NULL, PLAN_ACTIVATION_ERROR, std::string());
return;
}
- chromeos::NetworkLibrary* lib = chromeos::CrosLibrary::Get()->
- GetNetworkLibrary();
- lib->RemoveObserver(this);
- lib->RemoveProperyObserver(this);
- // Start monitoring network and service property changes.
- lib->AddObserver(this);
- lib->AddProperyObserver(network->service_path().c_str(),
- this);
+ // Start monitoring network property changes.
+ chromeos::NetworkLibrary* lib =
+ chromeos::CrosLibrary::Get()->GetNetworkLibrary();
+ lib->AddNetworkManagerObserver(this);
+ lib->RemoveObserverForAllNetworks(this);
+ lib->AddNetworkObserver(network->service_path(), this);
state_ = PLAN_ACTIVATION_START;
EvaluateCellularNetwork(network);
}
@@ -629,8 +618,8 @@ void MobileSetupHandler::CompleteActivation(
network->set_auto_connect(true);
lib->SaveCellularNetwork(network);
}
- lib->RemoveObserver(this);
- lib->RemoveProperyObserver(this);
+ lib->RemoveNetworkManagerObserver(this);
+ lib->RemoveObserverForAllNetworks(this);
// Reactivate other types of connections if we have
// shut them down previously.
ReEnableOtherConnections();
@@ -839,7 +828,7 @@ void MobileSetupHandler::LoadCellularConfig() {
//
////////////////////////////////////////////////////////////////////////////////
-MobileSetupUI::MobileSetupUI(TabContents* contents) : DOMUI(contents){
+MobileSetupUI::MobileSetupUI(TabContents* contents) : DOMUI(contents) {
const chromeos::CellularNetwork* network = GetCellularNetwork();
std::string service_path = network ? network->service_path() : std::string();
MobileSetupHandler* handler = new MobileSetupHandler(service_path);