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

Unified Diff: content/browser/devtools/devtools_frontend_host_impl.cc

Issue 427143003: [DevTools] Move DevToolsClientHost functionality out of DevToolsFrontendHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
Index: content/browser/devtools/devtools_frontend_host_impl.cc
diff --git a/content/browser/devtools/devtools_frontend_host_impl.cc b/content/browser/devtools/devtools_frontend_host_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..201e19602a03c67ed2f76e587d061dd21a3cd356
--- /dev/null
+++ b/content/browser/devtools/devtools_frontend_host_impl.cc
@@ -0,0 +1,81 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/devtools/devtools_frontend_host_impl.h"
+
+#include "content/common/devtools_messages.h"
+#include "content/public/browser/navigation_entry.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/web_contents.h"
+
+namespace content {
+
+// static
+DevToolsFrontendHost* DevToolsFrontendHost::Create(
+ WebContents* frontend_web_contents,
+ DevToolsFrontendHost::Delegate* delegate) {
+ return new DevToolsFrontendHostImpl(frontend_web_contents, delegate);
+}
+
+DevToolsFrontendHostImpl::DevToolsFrontendHostImpl(
+ WebContents* web_contents,
+ DevToolsFrontendHost::Delegate* delegate)
+ : WebContentsObserver(web_contents),
+ delegate_(delegate) {
+ if (web_contents->GetController().GetVisibleEntry()) {
+ GURL url = web_contents->GetController().GetVisibleEntry()->GetURL();
+ if (delegate_->ShouldSetupDevToolsFrontendForUrl(url)) {
pfeldman 2014/07/31 11:47:25 Why would you do that here? You already do this un
dgozman 2014/07/31 13:05:31 As discussed offline, this check is left in embedd
+ RenderViewHost* rvh = web_contents->GetRenderViewHost();
+ rvh->Send(new DevToolsMsg_SetupDevToolsClient(
+ rvh->GetRoutingID()));
+ }
+ }
+}
+
+DevToolsFrontendHostImpl::~DevToolsFrontendHostImpl() {
+}
+
+void DevToolsFrontendHostImpl::DispatchOnDevToolsFrontend(
+ const std::string& message) {
+ if (!web_contents())
+ return;
+ RenderViewHost* target_host = web_contents()->GetRenderViewHost();
+ target_host->Send(new DevToolsClientMsg_DispatchOnInspectorFrontend(
+ target_host->GetRoutingID(),
+ message));
+}
+
+bool DevToolsFrontendHostImpl::OnMessageReceived(
+ const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(DevToolsFrontendHostImpl, message)
+ IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend,
+ OnDispatchOnInspectorBackend)
+ IPC_MESSAGE_HANDLER(DevToolsHostMsg_DispatchOnEmbedder,
+ OnDispatchOnEmbedder)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void DevToolsFrontendHostImpl::AboutToNavigateRenderView(
+ RenderViewHost* render_view_host) {
+ if (delegate_->ShouldSetupDevToolsFrontendForUrl(
+ web_contents()->GetController().GetVisibleEntry()->GetURL())) {
+ render_view_host->Send(new DevToolsMsg_SetupDevToolsClient(
+ render_view_host->GetRoutingID()));
+ }
+}
+
+void DevToolsFrontendHostImpl::OnDispatchOnInspectorBackend(
+ const std::string& message) {
+ delegate_->HandleMessageFromDevToolsFrontendToBackend(message);
+}
+
+void DevToolsFrontendHostImpl::OnDispatchOnEmbedder(
+ const std::string& message) {
+ delegate_->HandleMessageFromDevToolsFrontend(message);
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698