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

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

Issue 23684042: Eliminate NetworkManagerChanged (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 3 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/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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 const std::string& error_name, 261 const std::string& error_name,
262 scoped_ptr<base::DictionaryValue> error_data); 262 scoped_ptr<base::DictionaryValue> error_data);
263 263
264 // Handlers for JS WebUI messages. 264 // Handlers for JS WebUI messages.
265 void HandleSetTransactionStatus(const ListValue* args); 265 void HandleSetTransactionStatus(const ListValue* args);
266 void HandleStartActivation(const ListValue* args); 266 void HandleStartActivation(const ListValue* args);
267 void HandlePaymentPortalLoad(const ListValue* args); 267 void HandlePaymentPortalLoad(const ListValue* args);
268 void HandleGetDeviceInfo(const ListValue* args); 268 void HandleGetDeviceInfo(const ListValue* args);
269 269
270 // NetworkStateHandlerObserver implementation. 270 // NetworkStateHandlerObserver implementation.
271 virtual void NetworkManagerChanged() OVERRIDE; 271 virtual void NetworkConnectionStateChanged(
272 const NetworkState* network) OVERRIDE;
272 virtual void DefaultNetworkChanged( 273 virtual void DefaultNetworkChanged(
273 const NetworkState* default_network) OVERRIDE; 274 const NetworkState* default_network) OVERRIDE;
274 275
275 // Updates |lte_portal_reachable_| for lte network |network| and notifies 276 // Updates |lte_portal_reachable_| for lte network |network| and notifies
276 // webui of the new state if the reachability changed or |force_notification| 277 // webui of the new state if the reachability changed or |force_notification|
277 // is set. 278 // is set.
278 void UpdatePortalReachability(const NetworkState* network, 279 void UpdatePortalReachability(const NetworkState* network,
279 bool force_notification); 280 bool force_notification);
280 281
281 // Sends message to host registration page with system/user info data. 282 // Sends message to host registration page with system/user info data.
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 const std::string& callback_name, 588 const std::string& callback_name,
588 const std::string& error_name, 589 const std::string& error_name,
589 scoped_ptr<base::DictionaryValue> error_data) { 590 scoped_ptr<base::DictionaryValue> error_data) {
590 NET_LOG_ERROR("MobileActivator GetProperties Failed: " + error_name, 591 NET_LOG_ERROR("MobileActivator GetProperties Failed: " + error_name,
591 service_path); 592 service_path);
592 // Invoke |callback_name| with an empty dictionary. 593 // Invoke |callback_name| with an empty dictionary.
593 DictionaryValue device_dict; 594 DictionaryValue device_dict;
594 web_ui()->CallJavascriptFunction(callback_name, device_dict); 595 web_ui()->CallJavascriptFunction(callback_name, device_dict);
595 } 596 }
596 597
597 void MobileSetupHandler::NetworkManagerChanged() { 598 void MobileSetupHandler::DefaultNetworkChanged(
599 const NetworkState* default_network) {
598 if (!web_ui()) 600 if (!web_ui())
599 return; 601 return;
600 602
601 std::string path = web_ui()->GetWebContents()->GetURL().path(); 603 std::string path = web_ui()->GetWebContents()->GetURL().path().substr(1);
602 if (path.empty()) 604 if (path.empty())
603 return; 605 return;
604 606
605 const NetworkState* network = 607 const NetworkState* network =
606 NetworkHandler::Get()->network_state_handler()->GetNetworkState( 608 NetworkHandler::Get()->network_state_handler()->GetNetworkState(path);
607 path.substr(1));
608 if (!network) { 609 if (!network) {
609 LOG(ERROR) << "Service path lost"; 610 LOG(ERROR) << "Service path lost";
610 web_ui()->GetWebContents()->Close(); 611 web_ui()->GetWebContents()->Close();
611 return; 612 return;
612 } 613 }
613 614
614 UpdatePortalReachability(network, 615 UpdatePortalReachability(network, false /* do not force notification */);
615 false /* do not force notification */);
616 } 616 }
617 617
618 void MobileSetupHandler::DefaultNetworkChanged( 618 void MobileSetupHandler::NetworkConnectionStateChanged(
619 const NetworkState* default_network) { 619 const NetworkState* network) {
620 NetworkManagerChanged(); 620 if (!web_ui())
621 return;
622
623 std::string path = web_ui()->GetWebContents()->GetURL().path().substr(1);
624 if (path.empty() || path != network->path())
625 return;
626
627 UpdatePortalReachability(network, false /* do not force notification */);
621 } 628 }
622 629
623 void MobileSetupHandler::UpdatePortalReachability( 630 void MobileSetupHandler::UpdatePortalReachability(
624 const NetworkState* network, 631 const NetworkState* network,
625 bool force_notification) { 632 bool force_notification) {
626 DCHECK(web_ui()); 633 DCHECK(web_ui());
627 634
628 DCHECK_EQ(type_, TYPE_PORTAL_LTE); 635 DCHECK_EQ(type_, TYPE_PORTAL_LTE);
629 636
630 chromeos::NetworkStateHandler* nsh = 637 chromeos::NetworkStateHandler* nsh =
(...skipping 24 matching lines...) Expand all
655 662
656 // Set up the chrome://mobilesetup/ source. 663 // Set up the chrome://mobilesetup/ source.
657 Profile* profile = Profile::FromWebUI(web_ui); 664 Profile* profile = Profile::FromWebUI(web_ui);
658 content::URLDataSource::Add(profile, html_source); 665 content::URLDataSource::Add(profile, html_source);
659 } 666 }
660 667
661 void MobileSetupUI::RenderViewCreated(RenderViewHost* host) { 668 void MobileSetupUI::RenderViewCreated(RenderViewHost* host) {
662 // Destroyed by the corresponding RenderViewHost 669 // Destroyed by the corresponding RenderViewHost
663 new PortalFrameLoadObserver(AsWeakPtr(), host); 670 new PortalFrameLoadObserver(AsWeakPtr(), host);
664 } 671 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698