diff options
author | yurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-20 11:14:55 +0000 |
---|---|---|
committer | yurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-20 11:14:55 +0000 |
commit | 5e1ce07a5f99e59bfe961c70e1d5cc2bf8f4fd86 (patch) | |
tree | c311ca8cfad3579e526aa6e8f97b6aff0b68ccdc /chrome/browser/renderer_host | |
parent | a10c64530127a1e735b8e7a0d4eb8351e3ef65d2 (diff) | |
download | chromium_src-5e1ce07a5f99e59bfe961c70e1d5cc2bf8f4fd86.zip chromium_src-5e1ce07a5f99e59bfe961c70e1d5cc2bf8f4fd86.tar.gz chromium_src-5e1ce07a5f99e59bfe961c70e1d5cc2bf8f4fd86.tar.bz2 |
Add tab content type for developer tools UI.
Add code routing messages between ToolsAgent and ToolsClient in the browser process.
There is no direct IPC channel between inspected process and developer tools UI so all messages have to be routed through the browser process.
On the side of inspected page there is ToolsAgent existing in all renderers so that we can start inspecting the page at any moment by talking to this object.
On the side of developer tools renderer there is ToolsClient which is created only for RenderView that host developer tools UI.
(darin: tools message representation will be later changed from id+string to just IPC::Message)
Review URL: http://codereview.chromium.org/21510
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10090 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.cc | 33 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.h | 14 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host_delegate.h | 5 |
3 files changed, 50 insertions, 2 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index ae84b8f..62a305f 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -96,7 +96,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) @@ -582,6 +584,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 +744,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 +1185,23 @@ void RenderViewHost::DidDebugAttach() { } } +void RenderViewHost::OnToolsAgentMsg(int tools_message_type, + const std::wstring& body) { + RenderViewHost* host = RenderViewHost::FromID(inspected_process_id_, + inspected_view_id_); + 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) { + RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); + if (view) + view->ForwardMessageToToolsClient(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 15d0c6f..c6bab37 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; @@ -320,6 +321,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 +512,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,7 +569,7 @@ 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_; // True if we've been told to set up the the Javascript bindings for @@ -610,6 +618,10 @@ class RenderViewHost : public RenderWidgetHost { bool are_javascript_messages_suppressed_; + int inspected_process_id_; + + int inspected_view_id_; + DISALLOW_EVIL_CONSTRUCTORS(RenderViewHost); }; diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h index 7cfe6f9..5623b57 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.h +++ b/chrome/browser/renderer_host/render_view_host_delegate.h @@ -119,6 +119,11 @@ class RenderViewHostDelegate { const gfx::Rect& selection_rect, int active_match_ordinal, bool final_update) = 0; + + // Forwards message to ToolsClient in developer tools window open for this + // page. + virtual void ForwardMessageToToolsClient(int tools_message_type, + const std::wstring& body) = 0; }; // Interface for saving web pages. |