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

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: Fixed a typo 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 "ash/system/tray/system_tray_delegate.h" 9 #include "ash/system/tray/system_tray_delegate.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 namespace chromeos { 53 namespace chromeos {
54 54
55 OfflineLoadPage::OfflineLoadPage(WebContents* web_contents, 55 OfflineLoadPage::OfflineLoadPage(WebContents* web_contents,
56 const GURL& url, 56 const GURL& url,
57 const CompletionCallback& callback) 57 const CompletionCallback& callback)
58 : callback_(callback), 58 : callback_(callback),
59 proceeded_(false), 59 proceeded_(false),
60 web_contents_(web_contents), 60 web_contents_(web_contents),
61 url_(url) { 61 url_(url) {
62 net::NetworkChangeNotifier::AddOnlineStateObserver(this); 62 net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
63 interstitial_page_ = InterstitialPage::Create(web_contents, true, url, this); 63 interstitial_page_ = InterstitialPage::Create(web_contents, true, url, this);
64 } 64 }
65 65
66 OfflineLoadPage::~OfflineLoadPage() { 66 OfflineLoadPage::~OfflineLoadPage() {
67 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 67 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
68 net::NetworkChangeNotifier::RemoveOnlineStateObserver(this); 68 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
69 } 69 }
70 70
71 void OfflineLoadPage::Show() { 71 void OfflineLoadPage::Show() {
72 interstitial_page_->Show(); 72 interstitial_page_->Show();
73 } 73 }
74 74
75 std::string OfflineLoadPage::GetHTMLContents() { 75 std::string OfflineLoadPage::GetHTMLContents() {
76 DictionaryValue strings; 76 DictionaryValue strings;
77 int64 time_to_wait = kMaxBlankPeriod; 77 int64 time_to_wait = kMaxBlankPeriod;
78 // Set the timeout to show the page. 78 // Set the timeout to show the page.
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } else { 192 } else {
193 LOG(WARNING) << "Unknown command:" << cmd; 193 LOG(WARNING) << "Unknown command:" << cmd;
194 } 194 }
195 } 195 }
196 196
197 void OfflineLoadPage::NotifyBlockingPageComplete(bool proceed) { 197 void OfflineLoadPage::NotifyBlockingPageComplete(bool proceed) {
198 BrowserThread::PostTask( 198 BrowserThread::PostTask(
199 BrowserThread::IO, FROM_HERE, base::Bind(callback_, proceed)); 199 BrowserThread::IO, FROM_HERE, base::Bind(callback_, proceed));
200 } 200 }
201 201
202 void OfflineLoadPage::OnOnlineStateChanged(bool online) { 202 void OfflineLoadPage::OnConnectionTypeChanged(
203 net::NetworkChangeNotifier::ConnectionType type) {
203 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 204 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
204 DVLOG(1) << "OnlineStateObserver notification received: state=" 205 const bool online = type != net::NetworkChangeNotifier::CONNECTION_NONE;
206 DVLOG(1) << "ConnectionTypeObserver notification received: state="
205 << (online ? "online" : "offline"); 207 << (online ? "online" : "offline");
206 if (online) { 208 if (online) {
207 net::NetworkChangeNotifier::RemoveOnlineStateObserver(this); 209 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
208 interstitial_page_->Proceed(); 210 interstitial_page_->Proceed();
209 } 211 }
210 } 212 }
211 213
212 bool OfflineLoadPage::ShowActivationMessage() { 214 bool OfflineLoadPage::ShowActivationMessage() {
213 CrosLibrary* cros = CrosLibrary::Get(); 215 CrosLibrary* cros = CrosLibrary::Get();
214 if (!cros || !cros->GetNetworkLibrary()->cellular_available()) 216 if (!cros || !cros->GetNetworkLibrary()->cellular_available())
215 return false; 217 return false;
216 218
217 const CellularNetworkVector& cell_networks = 219 const CellularNetworkVector& cell_networks =
218 cros->GetNetworkLibrary()->cellular_networks(); 220 cros->GetNetworkLibrary()->cellular_networks();
219 for (size_t i = 0; i < cell_networks.size(); ++i) { 221 for (size_t i = 0; i < cell_networks.size(); ++i) {
220 chromeos::ActivationState activation_state = 222 chromeos::ActivationState activation_state =
221 cell_networks[i]->activation_state(); 223 cell_networks[i]->activation_state();
222 if (activation_state == ACTIVATION_STATE_ACTIVATED) 224 if (activation_state == ACTIVATION_STATE_ACTIVATED)
223 return false; 225 return false;
224 } 226 }
225 return true; 227 return true;
226 } 228 }
227 229
228 } // namespace chromeos 230 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/offline/offline_load_page.h ('k') | chrome/browser/chromeos/web_socket_proxy_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698