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

Side by Side Diff: chrome/browser/chromeos/offline/offline_load_page.cc

Issue 9147026: API for connection type (Ethernet/WIFI/WWAN ...) in NetworkChangeNotifier. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Review comments Created 8 years, 7 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
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/chromeos/offline/offline_load_page.h" 5 #include "chrome/browser/chromeos/offline/offline_load_page.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_delegate.h" 8 #include "ash/shell_delegate.h"
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 namespace chromeos { 54 namespace chromeos {
55 55
56 OfflineLoadPage::OfflineLoadPage(WebContents* web_contents, 56 OfflineLoadPage::OfflineLoadPage(WebContents* web_contents,
57 const GURL& url, 57 const GURL& url,
58 const CompletionCallback& callback) 58 const CompletionCallback& callback)
59 : callback_(callback), 59 : callback_(callback),
60 proceeded_(false), 60 proceeded_(false),
61 web_contents_(web_contents), 61 web_contents_(web_contents),
62 url_(url) { 62 url_(url) {
63 net::NetworkChangeNotifier::AddOnlineStateObserver(this); 63 net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
64 interstitial_page_ = InterstitialPage::Create(web_contents, true, url, this); 64 interstitial_page_ = InterstitialPage::Create(web_contents, true, url, this);
65 } 65 }
66 66
67 OfflineLoadPage::~OfflineLoadPage() { 67 OfflineLoadPage::~OfflineLoadPage() {
68 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 68 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
69 net::NetworkChangeNotifier::RemoveOnlineStateObserver(this); 69 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
70 } 70 }
71 71
72 void OfflineLoadPage::Show() { 72 void OfflineLoadPage::Show() {
73 interstitial_page_->Show(); 73 interstitial_page_->Show();
74 } 74 }
75 75
76 std::string OfflineLoadPage::GetHTMLContents() { 76 std::string OfflineLoadPage::GetHTMLContents() {
77 DictionaryValue strings; 77 DictionaryValue strings;
78 int64 time_to_wait = kMaxBlankPeriod; 78 int64 time_to_wait = kMaxBlankPeriod;
79 // Set the timeout to show the page. 79 // Set the timeout to show the page.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } else { 195 } else {
196 LOG(WARNING) << "Unknown command:" << cmd; 196 LOG(WARNING) << "Unknown command:" << cmd;
197 } 197 }
198 } 198 }
199 199
200 void OfflineLoadPage::NotifyBlockingPageComplete(bool proceed) { 200 void OfflineLoadPage::NotifyBlockingPageComplete(bool proceed) {
201 BrowserThread::PostTask( 201 BrowserThread::PostTask(
202 BrowserThread::IO, FROM_HERE, base::Bind(callback_, proceed)); 202 BrowserThread::IO, FROM_HERE, base::Bind(callback_, proceed));
203 } 203 }
204 204
205 void OfflineLoadPage::OnOnlineStateChanged(bool online) { 205 void OfflineLoadPage::OnConnectionTypeChanged(
206 net::NetworkChangeNotifier::ConnectionType type) {
206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 207 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
207 DVLOG(1) << "OnlineStateObserver notification received: state=" 208 const bool online = type != net::NetworkChangeNotifier::CONNECTION_NONE;
209 DVLOG(1) << "ConnectionTypeObserver notification received: state="
208 << (online ? "online" : "offline"); 210 << (online ? "online" : "offline");
209 if (online) { 211 if (online) {
210 net::NetworkChangeNotifier::RemoveOnlineStateObserver(this); 212 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
211 interstitial_page_->Proceed(); 213 interstitial_page_->Proceed();
212 } 214 }
213 } 215 }
214 216
215 bool OfflineLoadPage::ShowActivationMessage() { 217 bool OfflineLoadPage::ShowActivationMessage() {
216 CrosLibrary* cros = CrosLibrary::Get(); 218 CrosLibrary* cros = CrosLibrary::Get();
217 if (!cros || !cros->GetNetworkLibrary()->cellular_available()) 219 if (!cros || !cros->GetNetworkLibrary()->cellular_available())
218 return false; 220 return false;
219 221
220 const CellularNetworkVector& cell_networks = 222 const CellularNetworkVector& cell_networks =
221 cros->GetNetworkLibrary()->cellular_networks(); 223 cros->GetNetworkLibrary()->cellular_networks();
222 for (size_t i = 0; i < cell_networks.size(); ++i) { 224 for (size_t i = 0; i < cell_networks.size(); ++i) {
223 chromeos::ActivationState activation_state = 225 chromeos::ActivationState activation_state =
224 cell_networks[i]->activation_state(); 226 cell_networks[i]->activation_state();
225 if (activation_state == ACTIVATION_STATE_ACTIVATED) 227 if (activation_state == ACTIVATION_STATE_ACTIVATED)
226 return false; 228 return false;
227 } 229 }
228 return true; 230 return true;
229 } 231 }
230 232
231 } // namespace chromeos 233 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698