diff options
Diffstat (limited to 'chrome/browser')
24 files changed, 474 insertions, 3 deletions
diff --git a/chrome/browser/browser.scons b/chrome/browser/browser.scons index 349dc4e..2b9d266 100644 --- a/chrome/browser/browser.scons +++ b/chrome/browser/browser.scons @@ -400,6 +400,8 @@ input_files = ChromeFileList([ MSVSFilter('DOM UI', [ 'dom_ui/chrome_url_data_manager.cc', 'dom_ui/chrome_url_data_manager.h', + 'dom_ui/dev_tools_ui.cc', + 'dom_ui/dev_tools_ui.h', 'dom_ui/dom_ui.cc', 'dom_ui/dom_ui.h', 'dom_ui/dom_ui_contents.cc', diff --git a/chrome/browser/browser.vcproj b/chrome/browser/browser.vcproj index 317ed07..f618fbe 100644 --- a/chrome/browser/browser.vcproj +++ b/chrome/browser/browser.vcproj @@ -1490,6 +1490,14 @@ > </File> <File + RelativePath=".\dom_ui\dev_tools_ui.cc" + > + </File> + <File + RelativePath=".\dom_ui\dev_tools_ui.h" + > + </File> + <File RelativePath=".\dom_ui\dom_ui.cc" > </File> diff --git a/chrome/browser/debugger/debugger.scons b/chrome/browser/debugger/debugger.scons index 11907f24..c1800f6 100644 --- a/chrome/browser/debugger/debugger.scons +++ b/chrome/browser/debugger/debugger.scons @@ -55,6 +55,10 @@ input_files = ChromeFileList([ 'debugger_window.h', 'debugger_wrapper.cc', 'debugger_wrapper.h', + 'dev_tools_view.cc', + 'dev_tools_view.h', + 'dev_tools_window.cc', + 'dev_tools_window.h', ]) if env.Bit('linux'): @@ -63,6 +67,8 @@ if env.Bit('linux'): 'debugger_contents.cc', 'debugger_view.cc', 'debugger_window.cc', + 'dev_tools_view.cc', + 'dev_tools_window.cc', ) if env.Bit('mac'): @@ -73,6 +79,8 @@ if env.Bit('mac'): 'debugger_node.cc', 'debugger_view.cc', 'debugger_window.cc', + 'dev_tools_view.cc', + 'dev_tools_window.cc', ) if not env.Bit('mac'): diff --git a/chrome/browser/debugger/debugger.vcproj b/chrome/browser/debugger/debugger.vcproj index d72b86a..88af468 100644 --- a/chrome/browser/debugger/debugger.vcproj +++ b/chrome/browser/debugger/debugger.vcproj @@ -213,6 +213,22 @@ RelativePath=".\debugger_wrapper.h" > </File> + <File + RelativePath=".\dev_tools_view.cc" + > + </File> + <File + RelativePath=".\dev_tools_view.h" + > + </File> + <File + RelativePath=".\dev_tools_window.cc" + > + </File> + <File + RelativePath=".\dev_tools_window.h" + > + </File> </Files> <Globals> </Globals> diff --git a/chrome/browser/debugger/dev_tools_view.cc b/chrome/browser/debugger/dev_tools_view.cc new file mode 100644 index 0000000..4eab83b --- /dev/null +++ b/chrome/browser/debugger/dev_tools_view.cc @@ -0,0 +1,88 @@ +// Copyright (c) 2009 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 "chrome/browser/debugger/dev_tools_view.h" + +#include "chrome/browser/browser_list.h" +#include "chrome/browser/profile.h" +#include "chrome/browser/tab_contents/web_contents.h" +#include "chrome/browser/views/tab_contents_container_view.h" +#include "chrome/common/property_bag.h" +#include "chrome/common/render_messages.h" + +DevToolsView::DevToolsView(int inspected_process_id, int inspected_view_id) + : inspected_process_id_(inspected_process_id), + inspected_view_id_(inspected_view_id), + web_contents_(NULL) { + web_container_ = new TabContentsContainerView(); + AddChildView(web_container_); +} + +DevToolsView::~DevToolsView() { +} + +void DevToolsView::SendDevToolsClientMessage(const IPC::Message& message) { + if (!web_contents_) { + NOTREACHED(); + return; + } + IPC::Message* copy = new IPC::Message(message); + copy->set_routing_id(web_contents_->render_view_host()->routing_id()); + web_contents_->render_view_host()->Send(copy); +} + +std::string DevToolsView::GetClassName() const { + return "DevToolsView"; +} + +gfx::Size DevToolsView::GetPreferredSize() { + return gfx::Size(700, 400); +} + +void DevToolsView::Layout() { + web_container_->SetBounds(0, 0, width(), height()); +} + +void DevToolsView::ViewHierarchyChanged(bool is_add, + views::View* parent, + views::View* child) { + if (is_add && child == this) { + DCHECK(GetWidget()); + Init(); + } +} + +void DevToolsView::Init() { + // We can't create the WebContents until we've actually been put into a real + // view hierarchy somewhere. + Profile* profile = BrowserList::GetLastActive()->profile(); + + TabContents* tc = TabContents::CreateWithType(TAB_CONTENTS_DOM_UI, profile, + NULL); + web_contents_ = tc->AsWebContents(); + web_contents_->SetupController(profile); + web_contents_->set_delegate(this); + web_container_->SetTabContents(web_contents_); + web_contents_->render_view_host()->AllowDOMUIBindings(); + web_contents_->render_view_host()->SetInspectedView(inspected_process_id_, + inspected_view_id_); + + GURL contents("chrome-ui://inspector/debugger-oop.html"); + // this will call CreateRenderView to create renderer process + web_contents_->controller()->LoadURL(contents, GURL(), + PageTransition::START_PAGE); +} + +void DevToolsView::OnWindowClosing() { + web_container_->SetTabContents(NULL); // detach last (and only) tab + web_contents_->CloseContents(); // destroy the tab and navigation controller +} + +void DevToolsView::OpenURLFromTab(TabContents* source, + const GURL& url, const GURL& referrer, + WindowOpenDisposition disposition, + PageTransition::Type transition) { + NOTREACHED(); +} + diff --git a/chrome/browser/debugger/dev_tools_view.h b/chrome/browser/debugger/dev_tools_view.h new file mode 100644 index 0000000..6c2c087 --- /dev/null +++ b/chrome/browser/debugger/dev_tools_view.h @@ -0,0 +1,79 @@ +// Copyright (c) 2009 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. + +#ifndef CHROME_BROWSER_DEBUGGER_DEV_TOOLS_VIEW_H_ +#define CHROME_BROWSER_DEBUGGER_DEV_TOOLS_VIEW_H_ + +#include <string> + +#include "base/basictypes.h" +#include "base/gfx/size.h" +#include "chrome/browser/tab_contents/tab_contents_delegate.h" +#include "chrome/views/view.h" + +namespace IPC { +class Message; +} +class TabContentsContainerView; +class WebContents; + +class DevToolsView : public views::View, + public TabContentsDelegate { + public: + explicit DevToolsView(int inspected_process_id, int inspected_view_id); + virtual ~DevToolsView(); + + void SendDevToolsClientMessage(const IPC::Message& message); + + // Destroy content views when the window is closing. + void OnWindowClosing(); + + private: + // Overridden from TabContentsDelegate: + virtual void NavigationStateChanged(const TabContents* source, + unsigned changed_flags) {} + virtual void ReplaceContents(TabContents* source, + TabContents* new_contents) {} + virtual void AddNewContents(TabContents* source, + TabContents* new_contents, + WindowOpenDisposition disposition, + const gfx::Rect& initial_pos, + bool user_gesture) {} + virtual void ActivateContents(TabContents* contents) {} + virtual void LoadingStateChanged(TabContents* source) {} + virtual void CloseContents(TabContents* source) {} + virtual void MoveContents(TabContents* source, const gfx::Rect& pos) {} + virtual bool IsPopup(TabContents* source) { return false; } + virtual void ToolbarSizeChanged(TabContents* source, bool is_animating) {} + virtual void URLStarredChanged(TabContents* source, bool) {} + virtual void UpdateTargetURL(TabContents* source, const GURL& url) {} + virtual bool CanBlur() const { return false; } + + // Opens a new URL inside the passed in TabContents, if source is 0 open + // in the current front-most tab. + virtual void OpenURLFromTab(TabContents* source, + const GURL& url, const GURL& referrer, + WindowOpenDisposition disposition, + PageTransition::Type transition); + + // Overridden from views::View: + virtual std::string GetClassName() const; + virtual gfx::Size GetPreferredSize(); + virtual void Layout(); + virtual void ViewHierarchyChanged(bool is_add, + views::View* parent, + views::View* child); + + void Init(); + + const int inspected_process_id_; + const int inspected_view_id_; + WebContents* web_contents_; + TabContentsContainerView* web_container_; + + DISALLOW_COPY_AND_ASSIGN(DevToolsView); +}; + +#endif // CHROME_BROWSER_DEBUGGER_DEV_TOOLS_VIEW_H_ + diff --git a/chrome/browser/debugger/dev_tools_window.cc b/chrome/browser/debugger/dev_tools_window.cc new file mode 100644 index 0000000..a1f6959 --- /dev/null +++ b/chrome/browser/debugger/dev_tools_window.cc @@ -0,0 +1,53 @@ +// Copyright (c) 2009 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 "chrome/browser/debugger/dev_tools_window.h" + +#include "chrome/browser/debugger/dev_tools_view.h" +#include "chrome/views/window.h" + +DevToolsWindow::DevToolsWindow() : window_(NULL), tools_view_(NULL) { +} + +DevToolsWindow::~DevToolsWindow() { +} + +void DevToolsWindow::Show(int inspected_process_id, + int inspected_view_id) { + if (window_) { + window_->Show(); + return; + } + + tools_view_ = new DevToolsView(inspected_process_id, inspected_view_id); + window_ = views::Window::CreateChromeWindow(NULL, gfx::Rect(), this); + window_->Show(); +} + +void DevToolsWindow::SendDevToolsClientMessage(const IPC::Message& message) { + if (!tools_view_) + return; + tools_view_->SendDevToolsClientMessage(message); +} + +std::wstring DevToolsWindow::GetWindowTitle() const { + return L"Developer Tools"; +} + +void DevToolsWindow::WindowClosing() { + if (tools_view_) { + tools_view_->OnWindowClosing(); + tools_view_ = NULL; + window_ = NULL; + } +} + +bool DevToolsWindow::CanResize() const { + return true; +} + +views::View* DevToolsWindow::GetContentsView() { + return tools_view_; +} + diff --git a/chrome/browser/debugger/dev_tools_window.h b/chrome/browser/debugger/dev_tools_window.h new file mode 100644 index 0000000..3550c33 --- /dev/null +++ b/chrome/browser/debugger/dev_tools_window.h @@ -0,0 +1,46 @@ +// Copyright (c) 2009 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. + +#ifndef CHROME_BROWSER_DEBUGGER_DEV_TOOLS_WINDOW_H_ +#define CHROME_BROWSER_DEBUGGER_DEV_TOOLS_WINDOW_H_ + +#include "base/basictypes.h" + +#include "chrome/views/window_delegate.h" + +namespace IPC { +class Message; +} +namespace views { +class Window; +} +class DevToolsView; +class TabContents; + +class DevToolsWindow : public views::WindowDelegate { + public: + DevToolsWindow(); + virtual ~DevToolsWindow(); + + // Show inspector window for the tab + void Show(int inspected_process_id, + int inspected_view_id); + + void SendDevToolsClientMessage(const IPC::Message& message); + + private: + // views::WindowDelegate methods: + virtual std::wstring GetWindowTitle() const; + virtual void WindowClosing(); + virtual bool CanResize() const; + virtual views::View* GetContentsView(); + + views::Window* window_; + DevToolsView* tools_view_; + + DISALLOW_COPY_AND_ASSIGN(DevToolsWindow); +}; + +#endif // CHROME_BROWSER_DEBUGGER_DEV_TOOLS_WINDOW_H_ + diff --git a/chrome/browser/dom_ui/dev_tools_ui.cc b/chrome/browser/dom_ui/dev_tools_ui.cc new file mode 100644 index 0000000..327cd87 --- /dev/null +++ b/chrome/browser/dom_ui/dev_tools_ui.cc @@ -0,0 +1,23 @@ +// Copyright (c) 2009 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 "chrome/browser/dom_ui/dev_tools_ui.h" + +#include "chrome/browser/renderer_host/render_view_host.h" +#include "chrome/common/render_messages.h" + +// DevToolsUI is accessible from chrome-ui://devtools. +static const char kDevToolsHost[] = "devtools"; + +// static +GURL DevToolsUI::GetBaseURL() { + return GURL(DOMUIContents::GetScheme() + "://" + kDevToolsHost); +} + +void DevToolsUI::RenderViewCreated(RenderViewHost* render_view_host) { + render_view_host->Send(new ViewMsg_SetupDevToolsClient( + render_view_host->routing_id())); +} + + diff --git a/chrome/browser/dom_ui/dev_tools_ui.h b/chrome/browser/dom_ui/dev_tools_ui.h new file mode 100644 index 0000000..a13af96 --- /dev/null +++ b/chrome/browser/dom_ui/dev_tools_ui.h @@ -0,0 +1,26 @@ +// Copyright (c) 2009 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. + +#ifndef CHROME_BROWSER_DOM_UI_DEV_TOOLS_UI_H_ +#define CHROME_BROWSER_DOM_UI_DEV_TOOLS_UI_H_ + +#include "chrome/browser/dom_ui/dom_ui.h" + +class DevToolsUI : public DOMUI { + public: + explicit DevToolsUI(DOMUIContents* contents) : DOMUI(contents) {} + + // Return the URL for the front page of this UI. + static GURL GetBaseURL(); + + // DOMUI Implementation + virtual void Init() {} + virtual void RenderViewCreated(RenderViewHost* render_view_host); + + private: + DISALLOW_COPY_AND_ASSIGN(DevToolsUI); +}; + +#endif // CHROME_BROWSER_DOM_UI_DEV_TOOLS_UI_H_ + diff --git a/chrome/browser/dom_ui/dom_ui.h b/chrome/browser/dom_ui/dom_ui.h index 1de9c42..c9d34ed 100644 --- a/chrome/browser/dom_ui/dom_ui.h +++ b/chrome/browser/dom_ui/dom_ui.h @@ -10,6 +10,7 @@ class DictionaryValue; class DOMMessageHandler; +class RenderViewHost; class Value; // A DOMUI sets up the datasources and message handlers for a given HTML-based @@ -21,6 +22,8 @@ class DOMUI { virtual ~DOMUI(); virtual void Init() = 0; + virtual void RenderViewCreated(RenderViewHost* render_view_host) {} + // Called from DOMUIContents. void ProcessDOMUIMessage(const std::string& message, const std::string& content); diff --git a/chrome/browser/dom_ui/dom_ui_contents.cc b/chrome/browser/dom_ui/dom_ui_contents.cc index f7b83a2..68b05d9 100644 --- a/chrome/browser/dom_ui/dom_ui_contents.cc +++ b/chrome/browser/dom_ui/dom_ui_contents.cc @@ -5,6 +5,7 @@ #include "chrome/browser/dom_ui/dom_ui_contents.h" #include "chrome/browser/debugger/debugger_contents.h" +#include "chrome/browser/dom_ui/dev_tools_ui.h" #include "chrome/browser/dom_ui/dom_ui.h" #include "chrome/browser/dom_ui/downloads_ui.h" #include "chrome/browser/dom_ui/history_ui.h" @@ -167,6 +168,11 @@ WebPreferences DOMUIContents::GetWebkitPrefs() { return web_prefs; } +void DOMUIContents::RenderViewCreated(RenderViewHost* render_view_host) { + DCHECK(current_ui_); + current_ui_->RenderViewCreated(render_view_host); +} + bool DOMUIContents::ShouldDisplayFavIcon() { if (current_ui_) return current_ui_->ShouldDisplayFavIcon(); @@ -238,6 +244,8 @@ DOMUI* DOMUIContents::GetDOMUIForURL(const GURL &url) { return new DownloadsUI(this); } else if (url.host() == DebuggerContents::GetBaseURL().host()) { return new DebuggerContents(this); + } else if (url.host() == DevToolsUI::GetBaseURL().host()) { + return new DevToolsUI(this); } #else NOTIMPLEMENTED(); diff --git a/chrome/browser/dom_ui/dom_ui_contents.h b/chrome/browser/dom_ui/dom_ui_contents.h index 8220b175c..948ea6f 100644 --- a/chrome/browser/dom_ui/dom_ui_contents.h +++ b/chrome/browser/dom_ui/dom_ui_contents.h @@ -12,7 +12,7 @@ #include "webkit/glue/webpreferences.h" class DOMUI; -class render_view_host; +class RenderViewHost; // FavIconSource is the gateway between network-level chrome: // requests for favicons and the history backend that serves these. @@ -113,6 +113,8 @@ class DOMUIContents : public WebContents { virtual void RequestOpenURL(const GURL& url, const GURL& referrer, WindowOpenDisposition disposition); + virtual void RenderViewCreated(RenderViewHost* render_view_host); + // // TabContents overrides // @@ -120,7 +122,7 @@ class DOMUIContents : public WebContents { const ViewHostMsg_FrameNavigate_Params& params) { } virtual bool NavigateToPendingEntry(bool reload); - // Return the scheme used. We currently use chrome: + // Return the scheme used. We currently use chrome-ui: static const std::string GetScheme(); private: diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 5e644c2..35fd1fd 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -97,7 +97,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_(-1), + inspected_view_id_(-1) { DCHECK(instance_); DCHECK(delegate_); if (modal_dialog_event == NULL) @@ -733,6 +735,10 @@ 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_ForwardToDevToolsAgent, + OnForwardToDevToolsAgent); + IPC_MESSAGE_HANDLER(ViewHostMsg_ForwardToDevToolsClient, + OnForwardToDevToolsClient); IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, OnUserMetricsRecordAction) IPC_MESSAGE_HANDLER(ViewHostMsg_MissingPluginStatus, OnMissingPluginStatus); @@ -1168,6 +1174,28 @@ void RenderViewHost::DidDebugAttach() { } } +void RenderViewHost::SetInspectedView(int inspected_process_id, + int inspected_view_id) { + inspected_process_id_ = inspected_process_id; + inspected_view_id_ = inspected_view_id; +} + +void RenderViewHost::OnForwardToDevToolsAgent(const IPC::Message& message) { + RenderViewHost* host = RenderViewHost::FromID(inspected_process_id_, + inspected_view_id_); + if (!host) + return; + IPC::Message* m = new IPC::Message(message); + m->set_routing_id(inspected_view_id_); + host->Send(m); +} + +void RenderViewHost::OnForwardToDevToolsClient(const IPC::Message& message) { + RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); + if (view) + view->ForwardMessageToDevToolsClient(message); +} + 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 daf6044..812851c 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -320,6 +320,11 @@ class RenderViewHost : public RenderWidgetHost { // Must be called before CreateRenderView(). void AllowDOMUIBindings(); + // Tells the renderer which render view should be inspected by developer + // tools loaded in it. This method should be called before renderer is + // created. + void SetInspectedView(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); @@ -509,6 +514,8 @@ class RenderViewHost : public RenderWidgetHost { const std::wstring& source_id); void OnDebuggerOutput(const std::wstring& output); void DidDebugAttach(); + void OnForwardToDevToolsAgent(const IPC::Message& message); + void OnForwardToDevToolsClient(const IPC::Message& message); void OnUserMetricsRecordAction(const std::wstring& action); void OnMissingPluginStatus(int status); void OnMessageReceived(IPC::Message* msg) { } @@ -613,6 +620,12 @@ class RenderViewHost : public RenderWidgetHost { bool are_javascript_messages_suppressed_; + // When this renderer hosts developer tools this two fields contain rerndeder + // process id and render view id of the page being inspected. Both fieldes + // are -1 if the content of this renderer is not developer tools frontend. + 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 5a70c78..cf78cf4 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.h +++ b/chrome/browser/renderer_host/render_view_host_delegate.h @@ -112,6 +112,11 @@ class RenderViewHostDelegate { // specified events. This gives an opportunity to the browser to process the // event (used for keyboard shortcuts). virtual void HandleKeyboardEvent(const WebKeyboardEvent& event) = 0; + + // Forwards message to DevToolsClient in developer tools window open for + // this page. + virtual void ForwardMessageToDevToolsClient( + const IPC::Message& message) = 0; }; // Interface for saving web pages. diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc index 4511447..9781a0e 100644 --- a/chrome/browser/tab_contents/interstitial_page.cc +++ b/chrome/browser/tab_contents/interstitial_page.cc @@ -87,6 +87,7 @@ class InterstitialPage::InterstitialPageRVHViewDelegate virtual void UpdateDragCursor(bool is_drop_target); virtual void TakeFocus(bool reverse); virtual void HandleKeyboardEvent(const WebKeyboardEvent& event); + virtual void ForwardMessageToDevToolsClient(const IPC::Message& message); virtual void OnFindReply(int request_id, int number_of_matches, const gfx::Rect& selection_rect, @@ -502,6 +503,11 @@ void InterstitialPage::InterstitialPageRVHViewDelegate::HandleKeyboardEvent( interstitial_page_->tab()->GetViewDelegate()->HandleKeyboardEvent(event); } +void InterstitialPage::InterstitialPageRVHViewDelegate:: + ForwardMessageToDevToolsClient(const IPC::Message& message) { + NOTREACHED() << "InterstitialPage does not support developer tools content."; +} + void InterstitialPage::InterstitialPageRVHViewDelegate::OnFindReply( int request_id, int number_of_matches, const gfx::Rect& selection_rect, int active_match_ordinal, bool final_update) { diff --git a/chrome/browser/tab_contents/web_contents_view.h b/chrome/browser/tab_contents/web_contents_view.h index 1a8b4f6..f9d7075 100644 --- a/chrome/browser/tab_contents/web_contents_view.h +++ b/chrome/browser/tab_contents/web_contents_view.h @@ -108,6 +108,13 @@ class WebContentsView : public RenderViewHostDelegate::View { // RenderWidgetHost is deleted. Removes |host| from internal maps. void RenderWidgetHostDestroyed(RenderWidgetHost* host); + // Opens developer tools window for the page. + virtual void OpenDeveloperTools() = 0; + + // Forwards message to DevToolsClient in developer tools window open for this + // page. + virtual void ForwardMessageToDevToolsClient(const IPC::Message& message) = 0; + protected: WebContentsView() {} // Abstract interface. diff --git a/chrome/browser/tab_contents/web_contents_view_gtk.cc b/chrome/browser/tab_contents/web_contents_view_gtk.cc index 62fbd3a..e82b128 100644 --- a/chrome/browser/tab_contents/web_contents_view_gtk.cc +++ b/chrome/browser/tab_contents/web_contents_view_gtk.cc @@ -89,6 +89,15 @@ void WebContentsViewGtk::SizeContents(const gfx::Size& size) { NOTIMPLEMENTED(); } +void WebContentsViewGtk::OpenDeveloperTools() { + NOTIMPLEMENTED(); +} + +void WebContentsViewGtk::ForwardMessageToDevToolsClient( + const IPC::Message& message) { + NOTIMPLEMENTED(); +} + void WebContentsViewGtk::FindInPage(const Browser& browser, bool find_next, bool forward_direction) { NOTIMPLEMENTED(); diff --git a/chrome/browser/tab_contents/web_contents_view_gtk.h b/chrome/browser/tab_contents/web_contents_view_gtk.h index a4273f5..ea5e38c 100644 --- a/chrome/browser/tab_contents/web_contents_view_gtk.h +++ b/chrome/browser/tab_contents/web_contents_view_gtk.h @@ -30,6 +30,8 @@ class WebContentsViewGtk : public WebContentsView { virtual void SetPageTitle(const std::wstring& title); virtual void Invalidate(); virtual void SizeContents(const gfx::Size& size); + virtual void OpenDeveloperTools(); + virtual void ForwardMessageToDevToolsClient(const IPC::Message& message); virtual void FindInPage(const Browser& browser, bool find_next, bool forward_direction); virtual void HideFindBar(bool end_session); diff --git a/chrome/browser/tab_contents/web_contents_view_mac.h b/chrome/browser/tab_contents/web_contents_view_mac.h index d576605..44772a5 100644 --- a/chrome/browser/tab_contents/web_contents_view_mac.h +++ b/chrome/browser/tab_contents/web_contents_view_mac.h @@ -46,6 +46,8 @@ class WebContentsViewMac : public WebContentsView, virtual void SetPageTitle(const std::wstring& title); virtual void Invalidate(); virtual void SizeContents(const gfx::Size& size); + virtual void OpenDeveloperTools(); + virtual void ForwardMessageToDevToolsClient(const IPC::Message& message); virtual void FindInPage(const Browser& browser, bool find_next, bool forward_direction); virtual void HideFindBar(bool end_session); diff --git a/chrome/browser/tab_contents/web_contents_view_mac.mm b/chrome/browser/tab_contents/web_contents_view_mac.mm index c784ee0..a382bca 100644 --- a/chrome/browser/tab_contents/web_contents_view_mac.mm +++ b/chrome/browser/tab_contents/web_contents_view_mac.mm @@ -99,6 +99,15 @@ void WebContentsViewMac::SizeContents(const gfx::Size& size) { NOTIMPLEMENTED(); // Leaving the hack unimplemented. } +void WebContentsViewMac::OpenDeveloperTools() { + NOTIMPLEMENTED(); +} + +void WebContentsViewMac::ForwardMessageToDevToolsClient( + const IPC::Message& message) { + NOTIMPLEMENTED(); +} + void WebContentsViewMac::FindInPage(const Browser& browser, bool find_next, bool forward_direction) { if (!find_bar_.get()) { diff --git a/chrome/browser/tab_contents/web_contents_view_win.cc b/chrome/browser/tab_contents/web_contents_view_win.cc index b88a899..73602d7 100644 --- a/chrome/browser/tab_contents/web_contents_view_win.cc +++ b/chrome/browser/tab_contents/web_contents_view_win.cc @@ -9,6 +9,7 @@ #include "chrome/browser/bookmarks/bookmark_drag_data.h" #include "chrome/browser/browser.h" // TODO(beng): this dependency is awful. #include "chrome/browser/browser_process.h" +#include "chrome/browser/debugger/dev_tools_window.h" #include "chrome/browser/download/download_request_manager.h" #include "chrome/browser/renderer_host/render_process_host.h" #include "chrome/browser/renderer_host/render_view_host.h" @@ -212,6 +213,26 @@ void WebContentsViewWin::SizeContents(const gfx::Size& size) { WasSized(size); } +void WebContentsViewWin::OpenDeveloperTools() { + if (!dev_tools_window_.get()) + dev_tools_window_.reset(new DevToolsWindow); + + RenderViewHost* host = web_contents_->render_view_host(); + if (!host) + return; + + dev_tools_window_->Show(host->process()->host_id(), host->routing_id()); +} + +void WebContentsViewWin::ForwardMessageToDevToolsClient( + const IPC::Message& message) { + if (!dev_tools_window_.get()) { + NOTREACHED() << "Developer tools window is not open."; + return; + } + dev_tools_window_->SendDevToolsClientMessage(message); +} + void WebContentsViewWin::UpdateDragCursor(bool is_drop_target) { drop_target_->set_is_drop_target(is_drop_target); } diff --git a/chrome/browser/tab_contents/web_contents_view_win.h b/chrome/browser/tab_contents/web_contents_view_win.h index 6b891cf..afa2c3a 100644 --- a/chrome/browser/tab_contents/web_contents_view_win.h +++ b/chrome/browser/tab_contents/web_contents_view_win.h @@ -10,10 +10,12 @@ #include "chrome/browser/tab_contents/web_contents_view.h" #include "chrome/views/widget_win.h" +class DevToolsWindow; class SadTabView; struct WebDropData; class WebDropTarget; + // Windows-specific implementation of the WebContentsView. It is a HWND that // contains all of the contents of the tab and associated child views. class WebContentsViewWin : public WebContentsView, @@ -39,6 +41,8 @@ class WebContentsViewWin : public WebContentsView, virtual void SetPageTitle(const std::wstring& title); virtual void Invalidate(); virtual void SizeContents(const gfx::Size& size); + virtual void OpenDeveloperTools(); + virtual void ForwardMessageToDevToolsClient(const IPC::Message& message); // Backend implementation of RenderViewHostDelegate::View. virtual WebContents* CreateNewWindowInternal( @@ -96,6 +100,9 @@ class WebContentsViewWin : public WebContentsView, WebContents* web_contents_; + // Allows to show exactly one developer tools window for this page. + scoped_ptr<DevToolsWindow> dev_tools_window_; + // A drop target object that handles drags over this WebContents. scoped_refptr<WebDropTarget> drop_target_; |