Index: chrome/browser/net/net_error_tab_helper.cc |
diff --git a/chrome/browser/net/net_error_tab_helper.cc b/chrome/browser/net/net_error_tab_helper.cc |
index 416251a5238533810dd8935d5032a467f1c9f654..8196b35d6e8bd12a1aa8643fb480fcf005e41f5c 100644 |
--- a/chrome/browser/net/net_error_tab_helper.cc |
+++ b/chrome/browser/net/net_error_tab_helper.cc |
@@ -21,6 +21,7 @@ |
#include "content/public/browser/navigation_entry.h" |
#include "content/public/browser/navigation_handle.h" |
#include "content/public/browser/render_frame_host.h" |
+#include "content/public/browser/web_contents_interface_registry.h" |
#include "ipc/ipc_message_macros.h" |
#include "net/base/net_errors.h" |
#include "url/gurl.h" |
@@ -98,10 +99,9 @@ void NetErrorTabHelper::RenderFrameCreated( |
// platform's network diagnostics dialog. |
if (render_frame_host->GetParent()) |
return; |
- render_frame_host->Send( |
- new ChromeViewMsg_SetCanShowNetworkDiagnosticsDialog( |
- render_frame_host->GetRoutingID(), |
- CanShowNetworkDiagnosticsDialog())); |
+ |
+ remote_network_diagnostics_client_.ForFrame(render_frame_host) |
+ ->SetCanShowNetworkDiagnosticsDialog(CanShowNetworkDiagnosticsDialog()); |
} |
void NetErrorTabHelper::DidStartNavigationToPendingEntry( |
@@ -183,10 +183,11 @@ bool NetErrorTabHelper::OnMessageReceived( |
return false; |
bool handled = true; |
IPC_BEGIN_MESSAGE_MAP(NetErrorTabHelper, message) |
- IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RunNetworkDiagnostics, |
- RunNetworkDiagnostics) |
#if BUILDFLAG(ANDROID_JAVA_UI) |
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowOfflinePages, ShowOfflinePages) |
+#else |
+ case 0: // MSVC complains if we have a switch with only a default caluse. |
tibell
2016/09/05 00:47:33
Typo: caluse
Ken Rockot(use gerrit already)
2016/09/07 00:47:11
Done
|
+ return false; |
#endif // BUILDFLAG(ANDROID_JAVA_UI) |
IPC_MESSAGE_UNHANDLED(handled = false) |
IPC_END_MESSAGE_MAP() |
@@ -196,6 +197,7 @@ bool NetErrorTabHelper::OnMessageReceived( |
NetErrorTabHelper::NetErrorTabHelper(WebContents* contents) |
: WebContentsObserver(contents), |
+ interfaces_(content::WebContentsInterfaceRegistry::Create(contents)), |
tibell
2016/09/05 00:47:33
Shouldn't there just be one WebContentsInterfaceRe
Ken Rockot(use gerrit already)
2016/09/07 00:47:11
You're right, because (I'm pretty sure) we don't w
|
is_error_page_(false), |
dns_error_active_(false), |
dns_error_page_committed_(false), |
@@ -203,6 +205,8 @@ NetErrorTabHelper::NetErrorTabHelper(WebContents* contents) |
weak_factory_(this) { |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |
+ interfaces_->AddFrameInterface<mojom::NetworkDiagnostics>(this); |
+ |
// If this helper is under test, it won't have a WebContents. |
if (contents) |
InitializePref(contents); |
@@ -286,12 +290,15 @@ void NetErrorTabHelper::RunNetworkDiagnostics(const GURL& url) { |
// any other schemes, but the renderer is not trusted. |
if (!url.is_valid() || !url.SchemeIsHTTPOrHTTPS()) |
return; |
+ |
// Sanitize URL prior to running diagnostics on it. |
RunNetworkDiagnosticsHelper(url.GetOrigin().spec()); |
} |
void NetErrorTabHelper::RunNetworkDiagnosticsHelper( |
const std::string& sanitized_url) { |
+ if (interfaces_->GetCurrentTargetFrame() != web_contents()->GetMainFrame()) |
+ return; |
ShowNetworkDiagnosticsDialog(web_contents(), sanitized_url); |
} |