| 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 "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/io_thread.h" | 11 #include "chrome/browser/io_thread.h" |
| 12 #include "chrome/browser/net/dns_probe_service.h" | 12 #include "chrome/browser/net/dns_probe_service.h" |
| 13 #include "chrome/browser/net/net_error_diagnostics_dialog.h" | 13 #include "chrome/browser/net/net_error_diagnostics_dialog.h" |
| 14 #include "chrome/browser/platform_util.h" | 14 #include "chrome/browser/platform_util.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 17 #include "chrome/common/render_messages.h" | 17 #include "chrome/common/render_messages.h" |
| 18 #include "components/error_page/common/net_error_info.h" | 18 #include "components/error_page/common/net_error_info.h" |
| 19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/render_frame_host.h" | 20 #include "content/public/browser/render_frame_host.h" |
| 21 #include "content/public/browser/render_view_host.h" | 21 #include "content/public/browser/render_view_host.h" |
| 22 #include "ipc/ipc_message_macros.h" | 22 #include "ipc/ipc_message_macros.h" |
| 23 #include "net/base/net_errors.h" | 23 #include "net/base/net_errors.h" |
| 24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 25 | 25 |
| 26 using chrome_common_net::DnsProbeStatus; | 26 using chrome_common_net::DnsProbeStatus; |
| 27 using chrome_common_net::DnsProbeStatusToString; | |
| 28 using content::BrowserContext; | 27 using content::BrowserContext; |
| 29 using content::BrowserThread; | 28 using content::BrowserThread; |
| 30 using ui::PageTransition; | |
| 31 using content::RenderViewHost; | 29 using content::RenderViewHost; |
| 32 using content::WebContents; | 30 using content::WebContents; |
| 33 using content::WebContentsObserver; | 31 using content::WebContentsObserver; |
| 32 using error_page::DnsProbeStatusToString; |
| 33 using ui::PageTransition; |
| 34 | 34 |
| 35 DEFINE_WEB_CONTENTS_USER_DATA_KEY(chrome_browser_net::NetErrorTabHelper); | 35 DEFINE_WEB_CONTENTS_USER_DATA_KEY(chrome_browser_net::NetErrorTabHelper); |
| 36 | 36 |
| 37 namespace chrome_browser_net { | 37 namespace chrome_browser_net { |
| 38 | 38 |
| 39 namespace { | 39 namespace { |
| 40 | 40 |
| 41 static NetErrorTabHelper::TestingState testing_state_ = | 41 static NetErrorTabHelper::TestingState testing_state_ = |
| 42 NetErrorTabHelper::TESTING_DEFAULT; | 42 NetErrorTabHelper::TESTING_DEFAULT; |
| 43 | 43 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 FROM_HERE, | 210 FROM_HERE, |
| 211 base::Bind(&StartDnsProbeOnIOThread, | 211 base::Bind(&StartDnsProbeOnIOThread, |
| 212 base::Bind(&NetErrorTabHelper::OnDnsProbeFinished, | 212 base::Bind(&NetErrorTabHelper::OnDnsProbeFinished, |
| 213 weak_factory_.GetWeakPtr()), | 213 weak_factory_.GetWeakPtr()), |
| 214 g_browser_process->io_thread())); | 214 g_browser_process->io_thread())); |
| 215 } | 215 } |
| 216 | 216 |
| 217 void NetErrorTabHelper::OnDnsProbeFinished(DnsProbeStatus result) { | 217 void NetErrorTabHelper::OnDnsProbeFinished(DnsProbeStatus result) { |
| 218 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 218 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 219 DCHECK_EQ(chrome_common_net::DNS_PROBE_STARTED, dns_probe_status_); | 219 DCHECK_EQ(chrome_common_net::DNS_PROBE_STARTED, dns_probe_status_); |
| 220 DCHECK(chrome_common_net::DnsProbeStatusIsFinished(result)); | 220 DCHECK(error_page::DnsProbeStatusIsFinished(result)); |
| 221 | 221 |
| 222 DVLOG(1) << "Finished DNS probe with result " | 222 DVLOG(1) << "Finished DNS probe with result " |
| 223 << DnsProbeStatusToString(result) << "."; | 223 << DnsProbeStatusToString(result) << "."; |
| 224 | 224 |
| 225 dns_probe_status_ = result; | 225 dns_probe_status_ = result; |
| 226 | 226 |
| 227 if (dns_error_page_committed_) | 227 if (dns_error_page_committed_) |
| 228 SendInfo(); | 228 SendInfo(); |
| 229 } | 229 } |
| 230 | 230 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 // Sanitize URL prior to running diagnostics on it. | 267 // Sanitize URL prior to running diagnostics on it. |
| 268 RunNetworkDiagnosticsHelper(url.GetOrigin()); | 268 RunNetworkDiagnosticsHelper(url.GetOrigin()); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void NetErrorTabHelper::RunNetworkDiagnosticsHelper( | 271 void NetErrorTabHelper::RunNetworkDiagnosticsHelper( |
| 272 const GURL& sanitized_url) { | 272 const GURL& sanitized_url) { |
| 273 ShowNetworkDiagnosticsDialog(web_contents(), sanitized_url); | 273 ShowNetworkDiagnosticsDialog(web_contents(), sanitized_url); |
| 274 } | 274 } |
| 275 | 275 |
| 276 } // namespace chrome_browser_net | 276 } // namespace chrome_browser_net |
| OLD | NEW |