Chromium Code Reviews| 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/net/net_error_tab_helper.h" | 5 #include "chrome/browser/net/net_error_tab_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/io_thread.h" | 10 #include "chrome/browser/io_thread.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 | 136 |
| 137 bool NetErrorTabHelper::OnMessageReceived( | 137 bool NetErrorTabHelper::OnMessageReceived( |
| 138 const IPC::Message& message, | 138 const IPC::Message& message, |
| 139 content::RenderFrameHost* render_frame_host) { | 139 content::RenderFrameHost* render_frame_host) { |
| 140 if (render_frame_host != web_contents()->GetMainFrame()) | 140 if (render_frame_host != web_contents()->GetMainFrame()) |
| 141 return false; | 141 return false; |
| 142 #if BUILDFLAG(ANDROID_JAVA_UI) | 142 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 143 bool handled = true; | 143 bool handled = true; |
| 144 IPC_BEGIN_MESSAGE_MAP(NetErrorTabHelper, message) | 144 IPC_BEGIN_MESSAGE_MAP(NetErrorTabHelper, message) |
| 145 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DownloadPageLater, DownloadPageLater) | 145 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DownloadPageLater, DownloadPageLater) |
| 146 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetIsShowingDownloadButtonInErrorPage, | |
| 147 SetIsShowingDownloadButtonInErrorPage) | |
|
mmenke
2017/01/03 16:20:10
How can the browser process have a better idea of
nasko
2017/01/04 18:22:20
nit: Usually IPC handlers have an On prefix.
jianli
2017/01/06 23:46:37
Done.
jianli
2017/01/06 23:46:37
I am not sure I fully understand this comment. The
mmenke
2017/01/09 20:02:25
Sorry, I was getting net_error_tab_helper confused
| |
| 146 IPC_MESSAGE_UNHANDLED(handled = false) | 148 IPC_MESSAGE_UNHANDLED(handled = false) |
| 147 IPC_END_MESSAGE_MAP() | 149 IPC_END_MESSAGE_MAP() |
| 148 | 150 |
| 149 return handled; | 151 return handled; |
| 150 #else | 152 #else |
| 151 return false; | 153 return false; |
| 152 #endif // BUILDFLAG(ANDROID_JAVA_UI) | 154 #endif // BUILDFLAG(ANDROID_JAVA_UI) |
| 153 } | 155 } |
| 154 | 156 |
| 155 NetErrorTabHelper::NetErrorTabHelper(WebContents* contents) | 157 NetErrorTabHelper::NetErrorTabHelper(WebContents* contents) |
| 156 : WebContentsObserver(contents), | 158 : WebContentsObserver(contents), |
| 157 network_diagnostics_bindings_(contents, this), | 159 network_diagnostics_bindings_(contents, this), |
| 158 is_error_page_(false), | 160 is_error_page_(false), |
| 159 dns_error_active_(false), | 161 dns_error_active_(false), |
| 160 dns_error_page_committed_(false), | 162 dns_error_page_committed_(false), |
| 163 #if BUILDFLAG(ANDROID_JAVA_UI) | |
| 164 is_showing_download_button_in_error_page_(false), | |
| 165 #endif // BUILDFLAG(ANDROID_JAVA_UI | |
|
nasko
2017/01/04 18:22:20
nit: Missing closing parenthesis.
jianli
2017/01/06 23:46:37
Done.
| |
| 161 dns_probe_status_(error_page::DNS_PROBE_POSSIBLE), | 166 dns_probe_status_(error_page::DNS_PROBE_POSSIBLE), |
| 162 weak_factory_(this) { | 167 weak_factory_(this) { |
| 163 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 168 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 164 | 169 |
| 165 // If this helper is under test, it won't have a WebContents. | 170 // If this helper is under test, it won't have a WebContents. |
| 166 if (contents) | 171 if (contents) |
| 167 InitializePref(contents); | 172 InitializePref(contents); |
| 168 } | 173 } |
| 169 | 174 |
| 170 void NetErrorTabHelper::OnMainFrameDnsError() { | 175 void NetErrorTabHelper::OnMainFrameDnsError() { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 if (!entry || entry->GetPageType() != content::PAGE_TYPE_ERROR) | 222 if (!entry || entry->GetPageType() != content::PAGE_TYPE_ERROR) |
| 218 return; | 223 return; |
| 219 | 224 |
| 220 // Only download the page for HTTP/HTTPS URLs. | 225 // Only download the page for HTTP/HTTPS URLs. |
| 221 GURL url(entry->GetVirtualURL()); | 226 GURL url(entry->GetVirtualURL()); |
| 222 if (!url.SchemeIsHTTPOrHTTPS()) | 227 if (!url.SchemeIsHTTPOrHTTPS()) |
| 223 return; | 228 return; |
| 224 | 229 |
| 225 DownloadPageLaterHelper(url); | 230 DownloadPageLaterHelper(url); |
| 226 } | 231 } |
| 232 | |
| 233 void NetErrorTabHelper::SetIsShowingDownloadButtonInErrorPage(bool show) { | |
| 234 is_showing_download_button_in_error_page_ = show; | |
| 235 } | |
| 227 #endif // BUILDFLAG(ANDROID_JAVA_UI) | 236 #endif // BUILDFLAG(ANDROID_JAVA_UI) |
| 228 | 237 |
| 229 void NetErrorTabHelper::InitializePref(WebContents* contents) { | 238 void NetErrorTabHelper::InitializePref(WebContents* contents) { |
| 230 DCHECK(contents); | 239 DCHECK(contents); |
| 231 | 240 |
| 232 BrowserContext* browser_context = contents->GetBrowserContext(); | 241 BrowserContext* browser_context = contents->GetBrowserContext(); |
| 233 Profile* profile = Profile::FromBrowserContext(browser_context); | 242 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 234 resolve_errors_with_web_service_.Init( | 243 resolve_errors_with_web_service_.Init( |
| 235 prefs::kAlternateErrorPagesEnabled, | 244 prefs::kAlternateErrorPagesEnabled, |
| 236 profile->GetPrefs()); | 245 profile->GetPrefs()); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 offline_pages::ClientId client_id( | 295 offline_pages::ClientId client_id( |
| 287 offline_pages::kAsyncNamespace, base::GenerateGUID()); | 296 offline_pages::kAsyncNamespace, base::GenerateGUID()); |
| 288 request_coordinator->SavePageLater( | 297 request_coordinator->SavePageLater( |
| 289 page_url, client_id, true /*user_requested*/, | 298 page_url, client_id, true /*user_requested*/, |
| 290 offline_pages::RequestCoordinator::RequestAvailability:: | 299 offline_pages::RequestCoordinator::RequestAvailability:: |
| 291 ENABLED_FOR_OFFLINER); | 300 ENABLED_FOR_OFFLINER); |
| 292 } | 301 } |
| 293 #endif // BUILDFLAG(ANDROID_JAVA_UI) | 302 #endif // BUILDFLAG(ANDROID_JAVA_UI) |
| 294 | 303 |
| 295 } // namespace chrome_browser_net | 304 } // namespace chrome_browser_net |
| OLD | NEW |