| Index: chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc
|
| ===================================================================
|
| --- chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc (revision 64886)
|
| +++ chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc (working copy)
|
| @@ -124,10 +124,12 @@
|
| };
|
|
|
| // 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 @@
|
| 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 {
|
| @@ -328,8 +329,8 @@
|
| MobileSetupHandler::~MobileSetupHandler() {
|
| chromeos::NetworkLibrary* lib =
|
| chromeos::CrosLibrary::Get()->GetNetworkLibrary();
|
| - lib->RemoveObserver(this);
|
| - lib->RemoveProperyObserver(this);
|
| + lib->RemoveNetworkManagerObserver(this);
|
| + lib->RemoveObserverForAllNetworks(this);
|
| ReEnableOtherConnections();
|
| }
|
|
|
| @@ -352,34 +353,25 @@
|
| 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;
|
| - 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();
|
| -
|
| - // TODO(zelidrag, ers): Remove this once we flip the notification machanism.
|
| - chromeos::CrosLibrary::Get()->GetNetworkLibrary()->UpdateSystemInfo();
|
| - 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) {
|
| @@ -397,14 +389,12 @@
|
| 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);
|
| ChangeState(network, PLAN_ACTIVATION_START, std::string());
|
| EvaluateCellularNetwork(network);
|
| }
|
| @@ -581,8 +571,8 @@
|
| 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();
|
|
|