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 "apps/launcher.h" | 7 #include "apps/launcher.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_delegate.h" | 9 #include "ash/shell_delegate.h" |
10 #include "ash/system/tray/system_tray_delegate.h" | 10 #include "ash/system/tray/system_tray_delegate.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 const CompletionCallback& callback) | 53 const CompletionCallback& callback) |
54 : callback_(callback), | 54 : callback_(callback), |
55 proceeded_(false), | 55 proceeded_(false), |
56 web_contents_(web_contents), | 56 web_contents_(web_contents), |
57 url_(url) { | 57 url_(url) { |
58 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); | 58 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); |
59 interstitial_page_ = InterstitialPage::Create(web_contents, true, url, this); | 59 interstitial_page_ = InterstitialPage::Create(web_contents, true, url, this); |
60 } | 60 } |
61 | 61 |
62 OfflineLoadPage::~OfflineLoadPage() { | 62 OfflineLoadPage::~OfflineLoadPage() { |
63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 63 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
64 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); | 64 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); |
65 } | 65 } |
66 | 66 |
67 void OfflineLoadPage::Show() { | 67 void OfflineLoadPage::Show() { |
68 interstitial_page_->Show(); | 68 interstitial_page_->Show(); |
69 } | 69 } |
70 | 70 |
71 std::string OfflineLoadPage::GetHTMLContents() { | 71 std::string OfflineLoadPage::GetHTMLContents() { |
72 // Use a local error page. | 72 // Use a local error page. |
73 int resource_id; | 73 int resource_id; |
(...skipping 30 matching lines...) Expand all Loading... |
104 | 104 |
105 void OfflineLoadPage::OverrideRendererPrefs( | 105 void OfflineLoadPage::OverrideRendererPrefs( |
106 content::RendererPreferences* prefs) { | 106 content::RendererPreferences* prefs) { |
107 Profile* profile = Profile::FromBrowserContext( | 107 Profile* profile = Profile::FromBrowserContext( |
108 web_contents_->GetBrowserContext()); | 108 web_contents_->GetBrowserContext()); |
109 renderer_preferences_util::UpdateFromSystemSettings( | 109 renderer_preferences_util::UpdateFromSystemSettings( |
110 prefs, profile, web_contents_); | 110 prefs, profile, web_contents_); |
111 } | 111 } |
112 | 112 |
113 void OfflineLoadPage::OnProceed() { | 113 void OfflineLoadPage::OnProceed() { |
114 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 114 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
115 proceeded_ = true; | 115 proceeded_ = true; |
116 NotifyBlockingPageComplete(true); | 116 NotifyBlockingPageComplete(true); |
117 } | 117 } |
118 | 118 |
119 void OfflineLoadPage::OnDontProceed() { | 119 void OfflineLoadPage::OnDontProceed() { |
120 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 120 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
121 // Ignore if it's already proceeded. | 121 // Ignore if it's already proceeded. |
122 if (proceeded_) | 122 if (proceeded_) |
123 return; | 123 return; |
124 NotifyBlockingPageComplete(false); | 124 NotifyBlockingPageComplete(false); |
125 } | 125 } |
126 | 126 |
127 void OfflineLoadPage::CommandReceived(const std::string& cmd) { | 127 void OfflineLoadPage::CommandReceived(const std::string& cmd) { |
128 std::string command(cmd); | 128 std::string command(cmd); |
129 // The Jasonified response has quotes, remove them. | 129 // The Jasonified response has quotes, remove them. |
130 if (command.length() > 1 && command[0] == '"') { | 130 if (command.length() > 1 && command[0] == '"') { |
(...skipping 19 matching lines...) Expand all Loading... |
150 } | 150 } |
151 } | 151 } |
152 | 152 |
153 void OfflineLoadPage::NotifyBlockingPageComplete(bool proceed) { | 153 void OfflineLoadPage::NotifyBlockingPageComplete(bool proceed) { |
154 BrowserThread::PostTask( | 154 BrowserThread::PostTask( |
155 BrowserThread::IO, FROM_HERE, base::Bind(callback_, proceed)); | 155 BrowserThread::IO, FROM_HERE, base::Bind(callback_, proceed)); |
156 } | 156 } |
157 | 157 |
158 void OfflineLoadPage::OnConnectionTypeChanged( | 158 void OfflineLoadPage::OnConnectionTypeChanged( |
159 net::NetworkChangeNotifier::ConnectionType type) { | 159 net::NetworkChangeNotifier::ConnectionType type) { |
160 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 160 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
161 const bool online = type != net::NetworkChangeNotifier::CONNECTION_NONE; | 161 const bool online = type != net::NetworkChangeNotifier::CONNECTION_NONE; |
162 DVLOG(1) << "ConnectionTypeObserver notification received: state=" | 162 DVLOG(1) << "ConnectionTypeObserver notification received: state=" |
163 << (online ? "online" : "offline"); | 163 << (online ? "online" : "offline"); |
164 if (online) { | 164 if (online) { |
165 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); | 165 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); |
166 interstitial_page_->Proceed(); | 166 interstitial_page_->Proceed(); |
167 } | 167 } |
168 } | 168 } |
169 | 169 |
170 } // namespace chromeos | 170 } // namespace chromeos |
OLD | NEW |