diff options
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.cc | 44 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.h | 20 |
2 files changed, 62 insertions, 2 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 8c64d5f..9750d82 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -14,6 +14,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/cross_site_request_manager.h" #include "chrome/browser/debugger/debugger_wrapper.h" +#include "chrome/browser/debugger/tools_window.h" #include "chrome/browser/profile.h" #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/renderer_host/renderer_security_policy.h" @@ -87,6 +88,7 @@ RenderViewHost::RenderViewHost(SiteInstance* instance, renderer_initialized_(false), waiting_for_drag_context_response_(false), debugger_attached_(false), + tools_window_(NULL), enable_dom_ui_bindings_(false), pending_request_id_(0), enable_external_host_bindings_(false), @@ -96,7 +98,9 @@ RenderViewHost::RenderViewHost(SiteInstance* instance, run_modal_reply_msg_(NULL), has_unload_listener_(false), is_waiting_for_unload_ack_(false), - are_javascript_messages_suppressed_(false) { + are_javascript_messages_suppressed_(false), + inspected_process_id_(0), + inspected_view_id_(0) { DCHECK(instance_); DCHECK(delegate_); if (modal_dialog_event == NULL) @@ -554,6 +558,12 @@ void RenderViewHost::ShowJavaScriptConsole() { Send(new ViewMsg_ShowJavaScriptConsole(routing_id())); } +void RenderViewHost::ShowDeveloperTools() { + if (!tools_window_.get()) + tools_window_.reset(new ToolsWindow); + tools_window_->Show(process()->host_id(), routing_id()); +} + void RenderViewHost::DragSourceEndedAt( int client_x, int client_y, int screen_x, int screen_y) { Send(new ViewMsg_DragSourceEndedOrMoved( @@ -582,6 +592,16 @@ void RenderViewHost::AllowDOMUIBindings() { process()->host_id()); } +void RenderViewHost::SetUpToolsClient(int inspected_process_id, + int inspected_view_id) { + RendererSecurityPolicy::GetInstance()->GrantDOMUIBindings( + process()->host_id()); + Send(new ViewMsg_SetUpToolsClient(routing_id())); + + inspected_process_id_ = inspected_process_id; + inspected_view_id_ = inspected_view_id; +} + void RenderViewHost::AllowExternalHostBindings() { enable_external_host_bindings_ = true; } @@ -732,6 +752,8 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) IPC_MESSAGE_HANDLER(ViewHostMsg_DebuggerOutput, OnDebuggerOutput); IPC_MESSAGE_HANDLER(ViewHostMsg_DidDebugAttach, DidDebugAttach); + IPC_MESSAGE_HANDLER(ViewHostMsg_ToolsAgentMsg, OnToolsAgentMsg); + IPC_MESSAGE_HANDLER(ViewHostMsg_ToolsClientMsg, OnToolsClientMsg); IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, OnUserMetricsRecordAction) IPC_MESSAGE_HANDLER(ViewHostMsg_MissingPluginStatus, OnMissingPluginStatus); @@ -1171,6 +1193,26 @@ void RenderViewHost::DidDebugAttach() { } } +void RenderViewHost::OnToolsAgentMsg(int tools_message_type, + const std::wstring& body) { + RenderViewHost* host = RenderViewHost::FromID(inspected_process_id_, + inspected_view_id_); + CHECK(host); + if (host) { + host->Send(new ViewMsg_ToolsAgentMsg( + inspected_view_id_, tools_message_type, body)); + } +} + +void RenderViewHost::OnToolsClientMsg(int tools_message_type, + const std::wstring& body) { + if (!tools_window_.get()) { + NOTREACHED(); + return; + } + tools_window_->SendToolsClientMessage(tools_message_type, body); +} + void RenderViewHost::OnUserMetricsRecordAction(const std::wstring& action) { UserMetrics::RecordComputedAction(action.c_str(), process()->profile()); } diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index 2f36219..6c39393 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -26,6 +26,7 @@ class NavigationEntry; class RenderViewHostDelegate; class SiteInstance; class SkBitmap; +class ToolsWindow; class ViewMsg_Navigate; struct ContextMenuParams; struct ViewHostMsg_DidPrintPage_Params; @@ -291,6 +292,9 @@ class RenderViewHost : public RenderWidgetHost { // Show the JavaScript console. void ShowJavaScriptConsole(); + // Show the Web Inspector. + void ShowDeveloperTools(); + // Notifies the renderer that a drop occurred. This is necessary because the // render may be the one that started the drag. void DragSourceEndedAt( @@ -320,6 +324,11 @@ class RenderViewHost : public RenderWidgetHost { // Must be called before CreateRenderView(). void AllowDOMUIBindings(); + // Tell the render view to connect as a tools client to the specified + // renderer. Must be called when RenderView is created but before any + // navigation. + void SetUpToolsClient(int inspected_process_id, int inspected_view_id); + // Sets a property with the given name and value on the DOM UI binding object. // Must call AllowDOMUIBindings() on this renderer first. void SetDOMUIProperty(const std::string& name, const std::string& value); @@ -506,6 +515,8 @@ class RenderViewHost : public RenderWidgetHost { const std::wstring& source_id); void OnDebuggerOutput(const std::wstring& output); void DidDebugAttach(); + void OnToolsAgentMsg(int tools_message_type, const std::wstring& body); + void OnToolsClientMsg(int tools_message_type, const std::wstring& body); void OnUserMetricsRecordAction(const std::wstring& action); void OnMissingPluginStatus(int status); void OnMessageReceived(IPC::Message* msg) { } @@ -561,9 +572,12 @@ class RenderViewHost : public RenderWidgetHost { // information. bool waiting_for_drag_context_response_; - // is the debugger attached to us or not + // If the debugger attached to us or not. bool debugger_attached_; + // Allows to show exactly one developer tools window for this render view. + scoped_ptr<ToolsWindow> tools_window_; + // True if we've been told to set up the the Javascript bindings for // sending messages back to the browser. bool enable_dom_ui_bindings_; @@ -610,6 +624,10 @@ class RenderViewHost : public RenderWidgetHost { bool are_javascript_messages_suppressed_; + int inspected_process_id_; + + int inspected_view_id_; + DISALLOW_EVIL_CONSTRUCTORS(RenderViewHost); }; |