| OLD | NEW |
| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 namespace chromeos { | 55 namespace chromeos { |
| 56 | 56 |
| 57 OfflineLoadPage::OfflineLoadPage(WebContents* web_contents, | 57 OfflineLoadPage::OfflineLoadPage(WebContents* web_contents, |
| 58 const GURL& url, | 58 const GURL& url, |
| 59 const CompletionCallback& callback) | 59 const CompletionCallback& callback) |
| 60 : callback_(callback), | 60 : callback_(callback), |
| 61 proceeded_(false), | 61 proceeded_(false), |
| 62 web_contents_(web_contents), | 62 web_contents_(web_contents), |
| 63 url_(url) { | 63 url_(url) { |
| 64 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); | 64 net::NetworkChangeNotifier::AddNetworkChangeObserver(this); |
| 65 interstitial_page_ = InterstitialPage::Create(web_contents, true, url, this); | 65 interstitial_page_ = InterstitialPage::Create(web_contents, true, url, this); |
| 66 } | 66 } |
| 67 | 67 |
| 68 OfflineLoadPage::~OfflineLoadPage() { | 68 OfflineLoadPage::~OfflineLoadPage() { |
| 69 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 69 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 70 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); | 70 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void OfflineLoadPage::Show() { | 73 void OfflineLoadPage::Show() { |
| 74 interstitial_page_->Show(); | 74 interstitial_page_->Show(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 std::string OfflineLoadPage::GetHTMLContents() { | 77 std::string OfflineLoadPage::GetHTMLContents() { |
| 78 DictionaryValue strings; | 78 DictionaryValue strings; |
| 79 int64 time_to_wait = kMaxBlankPeriod; | 79 int64 time_to_wait = kMaxBlankPeriod; |
| 80 // Set the timeout to show the page. | 80 // Set the timeout to show the page. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 } else { | 193 } else { |
| 194 LOG(WARNING) << "Unknown command:" << cmd; | 194 LOG(WARNING) << "Unknown command:" << cmd; |
| 195 } | 195 } |
| 196 } | 196 } |
| 197 | 197 |
| 198 void OfflineLoadPage::NotifyBlockingPageComplete(bool proceed) { | 198 void OfflineLoadPage::NotifyBlockingPageComplete(bool proceed) { |
| 199 BrowserThread::PostTask( | 199 BrowserThread::PostTask( |
| 200 BrowserThread::IO, FROM_HERE, base::Bind(callback_, proceed)); | 200 BrowserThread::IO, FROM_HERE, base::Bind(callback_, proceed)); |
| 201 } | 201 } |
| 202 | 202 |
| 203 void OfflineLoadPage::OnConnectionTypeChanged( | 203 void OfflineLoadPage::OnNetworkChanged( |
| 204 net::NetworkChangeNotifier::ConnectionType type) { | 204 net::NetworkChangeNotifier::ConnectionType type) { |
| 205 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 205 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 206 const bool online = type != net::NetworkChangeNotifier::CONNECTION_NONE; | 206 const bool online = type != net::NetworkChangeNotifier::CONNECTION_NONE; |
| 207 DVLOG(1) << "ConnectionTypeObserver notification received: state=" | 207 DVLOG(1) << "ConnectionTypeObserver notification received: state=" |
| 208 << (online ? "online" : "offline"); | 208 << (online ? "online" : "offline"); |
| 209 if (online) { | 209 if (online) { |
| 210 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); | 210 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); |
| 211 interstitial_page_->Proceed(); | 211 interstitial_page_->Proceed(); |
| 212 } | 212 } |
| 213 } | 213 } |
| 214 | 214 |
| 215 bool OfflineLoadPage::ShowActivationMessage() { | 215 bool OfflineLoadPage::ShowActivationMessage() { |
| 216 CrosLibrary* cros = CrosLibrary::Get(); | 216 CrosLibrary* cros = CrosLibrary::Get(); |
| 217 if (!cros || !cros->GetNetworkLibrary()->cellular_available()) | 217 if (!cros || !cros->GetNetworkLibrary()->cellular_available()) |
| 218 return false; | 218 return false; |
| 219 | 219 |
| 220 const CellularNetworkVector& cell_networks = | 220 const CellularNetworkVector& cell_networks = |
| 221 cros->GetNetworkLibrary()->cellular_networks(); | 221 cros->GetNetworkLibrary()->cellular_networks(); |
| 222 for (size_t i = 0; i < cell_networks.size(); ++i) { | 222 for (size_t i = 0; i < cell_networks.size(); ++i) { |
| 223 chromeos::ActivationState activation_state = | 223 chromeos::ActivationState activation_state = |
| 224 cell_networks[i]->activation_state(); | 224 cell_networks[i]->activation_state(); |
| 225 if (activation_state == ACTIVATION_STATE_ACTIVATED) | 225 if (activation_state == ACTIVATION_STATE_ACTIVATED) |
| 226 return false; | 226 return false; |
| 227 } | 227 } |
| 228 return true; | 228 return true; |
| 229 } | 229 } |
| 230 | 230 |
| 231 } // namespace chromeos | 231 } // namespace chromeos |
| OLD | NEW |