Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1015)

Unified Diff: chrome/renderer/net/net_error_helper.cc

Issue 2310583002: Convert some NetError[Tab]Helper messages to mojom (Closed)
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/net/net_error_helper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/net/net_error_helper.cc
diff --git a/chrome/renderer/net/net_error_helper.cc b/chrome/renderer/net/net_error_helper.cc
index d2d98fb1490641947c46eb7c63f41830d585c905..c41b55ad29fe0c4ba4f98e75082985bad2a50bec 100644
--- a/chrome/renderer/net/net_error_helper.cc
+++ b/chrome/renderer/net/net_error_helper.cc
@@ -21,6 +21,8 @@
#include "components/error_page/common/localized_error.h"
#include "components/error_page/common/net_error_info.h"
#include "components/grit/components_resources.h"
+#include "content/public/common/associated_interface_provider.h"
+#include "content/public/common/associated_interface_registry.h"
#include "content/public/common/content_client.h"
#include "content/public/common/url_constants.h"
#include "content/public/renderer/content_renderer_client.h"
@@ -82,6 +84,7 @@ NetErrorHelperCore::FrameType GetFrameType(RenderFrame* render_frame) {
NetErrorHelper::NetErrorHelper(RenderFrame* render_frame)
: RenderFrameObserver(render_frame),
content::RenderFrameObserverTracker<NetErrorHelper>(render_frame),
+ network_diagnostics_client_binding_(this),
weak_controller_delegate_factory_(this) {
RenderThread::Get()->AddObserver(this);
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
@@ -95,6 +98,10 @@ NetErrorHelper::NetErrorHelper(RenderFrame* render_frame)
auto_reload_enabled,
auto_reload_visible_only,
!render_frame->IsHidden()));
+
+ render_frame->GetAssociatedInterfaceRegistry()->AddInterface(
+ base::Bind(&NetErrorHelper::OnNetworkDiagnosticsClientRequest,
+ base::Unretained(this)));
}
NetErrorHelper::~NetErrorHelper() {
@@ -152,8 +159,6 @@ bool NetErrorHelper::OnMessageReceived(const IPC::Message& message) {
IPC_BEGIN_MESSAGE_MAP(NetErrorHelper, message)
IPC_MESSAGE_HANDLER(ChromeViewMsg_NetErrorInfo, OnNetErrorInfo)
- IPC_MESSAGE_HANDLER(ChromeViewMsg_SetCanShowNetworkDiagnosticsDialog,
- OnSetCanShowNetworkDiagnosticsDialog);
IPC_MESSAGE_HANDLER(ChromeViewMsg_SetNavigationCorrectionInfo,
OnSetNavigationCorrectionInfo);
#if defined(OS_ANDROID)
@@ -185,6 +190,14 @@ bool NetErrorHelper::ShouldSuppressErrorPage(const GURL& url) {
return core_->ShouldSuppressErrorPage(GetFrameType(render_frame()), url);
}
+mojom::NetworkDiagnostics* NetErrorHelper::GetRemoteNetworkDiagnostics() {
+ if (!remote_network_diagnostics_) {
+ render_frame()->GetRemoteAssociatedInterfaces()
+ ->GetInterface(&remote_network_diagnostics_);
+ }
+ return remote_network_diagnostics_.get();
+}
+
void NetErrorHelper::GenerateLocalizedErrorPage(
const blink::WebURLError& error,
bool is_failed_post,
@@ -322,8 +335,7 @@ void NetErrorHelper::LoadPageFromCache(const GURL& page_url) {
}
void NetErrorHelper::DiagnoseError(const GURL& page_url) {
- render_frame()->Send(new ChromeViewHostMsg_RunNetworkDiagnostics(
- render_frame()->GetRoutingID(), page_url));
+ GetRemoteNetworkDiagnostics()->RunNetworkDiagnostics(page_url);
}
void NetErrorHelper::ShowOfflinePages() {
@@ -341,12 +353,6 @@ void NetErrorHelper::OnNetErrorInfo(int status_num) {
core_->OnNetErrorInfo(static_cast<DnsProbeStatus>(status_num));
}
-void NetErrorHelper::OnSetCanShowNetworkDiagnosticsDialog(
- bool can_use_local_diagnostics_service) {
- core_->OnSetCanShowNetworkDiagnosticsDialog(
- can_use_local_diagnostics_service);
-}
-
void NetErrorHelper::OnSetNavigationCorrectionInfo(
const GURL& navigation_correction_url,
const std::string& language,
@@ -375,6 +381,16 @@ void NetErrorHelper::OnTrackingRequestComplete(
tracking_fetcher_.reset();
}
+void NetErrorHelper::OnNetworkDiagnosticsClientRequest(
+ mojom::NetworkDiagnosticsClientAssociatedRequest request) {
+ DCHECK(!network_diagnostics_client_binding_.is_bound());
+ network_diagnostics_client_binding_.Bind(std::move(request));
+}
+
+void NetErrorHelper::SetCanShowNetworkDiagnosticsDialog(bool can_show) {
+ core_->OnSetCanShowNetworkDiagnosticsDialog(can_show);
+}
+
#if defined(OS_ANDROID)
void NetErrorHelper::OnSetHasOfflinePages(bool has_offline_pages) {
core_->OnSetHasOfflinePages(has_offline_pages);
« no previous file with comments | « chrome/renderer/net/net_error_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698