Commit 891f17cd authored by dgozman@chromium.org's avatar dgozman@chromium.org

[DevTools] Move DispatchOnDevToolsFrontend to embedder.

We already have a way to send message via ExecuteJavaScript,
no need for another mechanism.

BUG=398046
TBR=jam

Review URL: https://codereview.chromium.org/418243003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288027 0039d316-1c4b-4281-b951-d872f2087c98
parent 749e71fe
......@@ -412,8 +412,9 @@ void DevToolsUIBindings::HandleMessageFromDevToolsFrontendToBackend(
// content::DevToolsClientHost implementation ---------------------------------
void DevToolsUIBindings::DispatchOnInspectorFrontend(
const std::string& message) {
if (frontend_host_)
frontend_host_->DispatchOnDevToolsFrontend(message);
base::StringValue message_value(message);
CallClientFunction("InspectorFrontendAPI.dispatchMessage",
&message_value, NULL, NULL);
}
void DevToolsUIBindings::InspectedContentsClosing() {
......@@ -804,8 +805,9 @@ void DevToolsUIBindings::CallClientFunction(const std::string& function_name,
}
}
}
base::string16 javascript =
base::UTF8ToUTF16(function_name + "(" + params + ");");
base::string16 javascript = base::UTF8ToUTF16(
function_name + "(" + params + ");");
web_contents_->GetMainFrame()->ExecuteJavaScript(javascript);
}
......
......@@ -30,16 +30,6 @@ DevToolsFrontendHostImpl::DevToolsFrontendHostImpl(
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;
......
......@@ -17,9 +17,6 @@ class DevToolsFrontendHostImpl : public DevToolsFrontendHost,
DevToolsFrontendHost::Delegate* delegate);
virtual ~DevToolsFrontendHostImpl();
// DevToolsFrontendHost implementation.
virtual void DispatchOnDevToolsFrontend(const std::string& message) OVERRIDE;
private:
// WebContentsObserver overrides.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
......
......@@ -41,11 +41,6 @@ class DevToolsFrontendHost {
RenderViewHost* frontend_rvh, Delegate* delegate);
CONTENT_EXPORT virtual ~DevToolsFrontendHost() {}
// Dispatches message from embedder/backend to frontend.
// TODO(dgozman): remove and make embedder to take care of this.
CONTENT_EXPORT virtual void DispatchOnDevToolsFrontend(
const std::string& message) = 0;
};
} // namespace content
......
......@@ -36,19 +36,6 @@ DevToolsClient::DevToolsClient(RenderViewImpl* render_view)
DevToolsClient::~DevToolsClient() {
}
bool DevToolsClient::OnMessageReceived(const IPC::Message& message) {
DCHECK(RenderThreadImpl::current());
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(DevToolsClient, message)
IPC_MESSAGE_HANDLER(DevToolsClientMsg_DispatchOnInspectorFrontend,
OnDispatchOnInspectorFrontend)
IPC_MESSAGE_UNHANDLED(handled = false);
IPC_END_MESSAGE_MAP()
return handled;
}
void DevToolsClient::sendMessageToBackend(const WebString& message) {
Send(new DevToolsAgentMsg_DispatchOnInspectorBackend(routing_id(),
message.utf8()));
......@@ -63,9 +50,4 @@ bool DevToolsClient::isUnderTest() {
return RenderThreadImpl::current()->layout_test_mode();
}
void DevToolsClient::OnDispatchOnInspectorFrontend(const std::string& message) {
web_tools_frontend_->dispatchOnInspectorFrontend(
WebString::fromUTF8(message));
}
} // namespace content
......@@ -35,9 +35,6 @@ class CONTENT_EXPORT DevToolsClient
virtual ~DevToolsClient();
private:
// RenderView::Observer implementation.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
// WebDevToolsFrontendClient implementation.
virtual void sendMessageToBackend(const blink::WebString&) OVERRIDE;
virtual void sendMessageToEmbedder(const blink::WebString&) OVERRIDE;
......
......@@ -179,8 +179,9 @@ void ShellDevToolsFrontend::HandleMessageFromDevToolsFrontendToBackend(
void ShellDevToolsFrontend::DispatchOnInspectorFrontend(
const std::string& message) {
if (frontend_host_)
frontend_host_->DispatchOnDevToolsFrontend(message);
std::string code = "InspectorFrontendAPI.dispatchMessage(" + message + ");";
base::string16 javascript = base::UTF8ToUTF16(code);
web_contents()->GetMainFrame()->ExecuteJavaScript(javascript);
}
void ShellDevToolsFrontend::InspectedContentsClosing() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment