Commit 0cc6d636 authored by kouhei@chromium.org's avatar kouhei@chromium.org

Revert of [DevTools] Move DispatchOnDevToolsFrontend to embedder....

Revert of [DevTools] Move DispatchOnDevToolsFrontend to embedder. (https://codereview.chromium.org/418243003/)

Reason for revert:
I think this CL broke inspector/ layout tests:
http://build.chromium.org/p/chromium.webkit/builders/WebKit%20Linux/builds/35062

Original issue's description:
> [DevTools] Move DispatchOnDevToolsFrontend to embedder.
> 
> We already have a way to send message via ExecuteJavaScript,
> no need for another mechanism.
> 
> BUG=398046
> TBR=jam
> 
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=287514

TBR=pfeldman@chromium.org,jam@chromium.org,dgozman@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=398046

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287558 0039d316-1c4b-4281-b951-d872f2087c98
parent fa072c0a
...@@ -412,9 +412,8 @@ void DevToolsUIBindings::HandleMessageFromDevToolsFrontendToBackend( ...@@ -412,9 +412,8 @@ void DevToolsUIBindings::HandleMessageFromDevToolsFrontendToBackend(
// content::DevToolsClientHost implementation --------------------------------- // content::DevToolsClientHost implementation ---------------------------------
void DevToolsUIBindings::DispatchOnInspectorFrontend( void DevToolsUIBindings::DispatchOnInspectorFrontend(
const std::string& message) { const std::string& message) {
base::StringValue message_value(message); if (frontend_host_)
CallClientFunction("InspectorFrontendAPI.dispatchMessage", frontend_host_->DispatchOnDevToolsFrontend(message);
&message_value, NULL, NULL);
} }
void DevToolsUIBindings::InspectedContentsClosing() { void DevToolsUIBindings::InspectedContentsClosing() {
...@@ -805,9 +804,8 @@ void DevToolsUIBindings::CallClientFunction(const std::string& function_name, ...@@ -805,9 +804,8 @@ void DevToolsUIBindings::CallClientFunction(const std::string& function_name,
} }
} }
} }
base::string16 javascript =
base::string16 javascript = base::UTF8ToUTF16( base::UTF8ToUTF16(function_name + "(" + params + ");");
function_name + "(" + params + ");");
web_contents_->GetMainFrame()->ExecuteJavaScript(javascript); web_contents_->GetMainFrame()->ExecuteJavaScript(javascript);
} }
......
...@@ -30,6 +30,16 @@ DevToolsFrontendHostImpl::DevToolsFrontendHostImpl( ...@@ -30,6 +30,16 @@ DevToolsFrontendHostImpl::DevToolsFrontendHostImpl(
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( bool DevToolsFrontendHostImpl::OnMessageReceived(
const IPC::Message& message) { const IPC::Message& message) {
bool handled = true; bool handled = true;
......
...@@ -17,6 +17,9 @@ class DevToolsFrontendHostImpl : public DevToolsFrontendHost, ...@@ -17,6 +17,9 @@ class DevToolsFrontendHostImpl : public DevToolsFrontendHost,
DevToolsFrontendHost::Delegate* delegate); DevToolsFrontendHost::Delegate* delegate);
virtual ~DevToolsFrontendHostImpl(); virtual ~DevToolsFrontendHostImpl();
// DevToolsFrontendHost implementation.
virtual void DispatchOnDevToolsFrontend(const std::string& message) OVERRIDE;
private: private:
// WebContentsObserver overrides. // WebContentsObserver overrides.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
......
...@@ -41,6 +41,11 @@ class DevToolsFrontendHost { ...@@ -41,6 +41,11 @@ class DevToolsFrontendHost {
RenderViewHost* frontend_rvh, Delegate* delegate); RenderViewHost* frontend_rvh, Delegate* delegate);
CONTENT_EXPORT virtual ~DevToolsFrontendHost() {} 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 } // namespace content
......
...@@ -36,6 +36,19 @@ DevToolsClient::DevToolsClient(RenderViewImpl* render_view) ...@@ -36,6 +36,19 @@ DevToolsClient::DevToolsClient(RenderViewImpl* render_view)
DevToolsClient::~DevToolsClient() { 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) { void DevToolsClient::sendMessageToBackend(const WebString& message) {
Send(new DevToolsAgentMsg_DispatchOnInspectorBackend(routing_id(), Send(new DevToolsAgentMsg_DispatchOnInspectorBackend(routing_id(),
message.utf8())); message.utf8()));
...@@ -50,4 +63,9 @@ bool DevToolsClient::isUnderTest() { ...@@ -50,4 +63,9 @@ bool DevToolsClient::isUnderTest() {
return RenderThreadImpl::current()->layout_test_mode(); return RenderThreadImpl::current()->layout_test_mode();
} }
void DevToolsClient::OnDispatchOnInspectorFrontend(const std::string& message) {
web_tools_frontend_->dispatchOnInspectorFrontend(
WebString::fromUTF8(message));
}
} // namespace content } // namespace content
...@@ -35,6 +35,9 @@ class CONTENT_EXPORT DevToolsClient ...@@ -35,6 +35,9 @@ class CONTENT_EXPORT DevToolsClient
virtual ~DevToolsClient(); virtual ~DevToolsClient();
private: private:
// RenderView::Observer implementation.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
// WebDevToolsFrontendClient implementation. // WebDevToolsFrontendClient implementation.
virtual void sendMessageToBackend(const blink::WebString&) OVERRIDE; virtual void sendMessageToBackend(const blink::WebString&) OVERRIDE;
virtual void sendMessageToEmbedder(const blink::WebString&) OVERRIDE; virtual void sendMessageToEmbedder(const blink::WebString&) OVERRIDE;
......
...@@ -179,9 +179,8 @@ void ShellDevToolsFrontend::HandleMessageFromDevToolsFrontendToBackend( ...@@ -179,9 +179,8 @@ void ShellDevToolsFrontend::HandleMessageFromDevToolsFrontendToBackend(
void ShellDevToolsFrontend::DispatchOnInspectorFrontend( void ShellDevToolsFrontend::DispatchOnInspectorFrontend(
const std::string& message) { const std::string& message) {
std::string code = "InspectorFrontendAPI.dispatchMessage(" + message + ");"; if (frontend_host_)
base::string16 javascript = base::UTF8ToUTF16(code); frontend_host_->DispatchOnDevToolsFrontend(message);
web_contents()->GetMainFrame()->ExecuteJavaScript(javascript);
} }
void ShellDevToolsFrontend::InspectedContentsClosing() { 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