summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
diff options
context:
space:
mode:
authoryurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-20 11:14:55 +0000
committeryurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-20 11:14:55 +0000
commit5e1ce07a5f99e59bfe961c70e1d5cc2bf8f4fd86 (patch)
treec311ca8cfad3579e526aa6e8f97b6aff0b68ccdc /chrome/browser/tab_contents
parenta10c64530127a1e735b8e7a0d4eb8351e3ef65d2 (diff)
downloadchromium_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/tab_contents')
-rw-r--r--chrome/browser/tab_contents/tab_contents_factory.cc7
-rw-r--r--chrome/browser/tab_contents/tab_contents_type.h1
-rw-r--r--chrome/browser/tab_contents/web_contents_view.h8
-rw-r--r--chrome/browser/tab_contents/web_contents_view_gtk.cc9
-rw-r--r--chrome/browser/tab_contents/web_contents_view_gtk.h3
-rw-r--r--chrome/browser/tab_contents/web_contents_view_mac.h3
-rw-r--r--chrome/browser/tab_contents/web_contents_view_mac.mm9
-rw-r--r--chrome/browser/tab_contents/web_contents_view_win.cc21
-rw-r--r--chrome/browser/tab_contents/web_contents_view_win.h7
9 files changed, 68 insertions, 0 deletions
diff --git a/chrome/browser/tab_contents/tab_contents_factory.cc b/chrome/browser/tab_contents/tab_contents_factory.cc
index e6aa1a2..50031b1 100644
--- a/chrome/browser/tab_contents/tab_contents_factory.cc
+++ b/chrome/browser/tab_contents/tab_contents_factory.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/debugger/debugger_contents.h"
+#include "chrome/browser/debugger/tools_contents.h"
#include "chrome/browser/tab_contents/tab_contents_factory.h"
#include "chrome/browser/tab_contents/view_source_contents.h"
#include "chrome/browser/tab_contents/web_contents.h"
@@ -70,6 +71,9 @@ TabContents* TabContents::CreateWithType(TabContentsType type,
case TAB_CONTENTS_DEBUGGER:
contents = new DebuggerContents(profile, instance);
break;
+ case TAB_CONTENTS_TOOLS:
+ contents = new ToolsContents(profile, instance);
+ break;
case TAB_CONTENTS_DOM_UI:
contents = new DOMUIContents(profile, instance, NULL);
break;
@@ -120,6 +124,9 @@ TabContentsType TabContents::TypeForURL(GURL* url) {
if (DebuggerContents::IsDebuggerUrl(*url))
return TAB_CONTENTS_DEBUGGER;
+ if (ToolsContents::IsToolsUrl(*url))
+ return TAB_CONTENTS_TOOLS;
+
if (url->SchemeIs(DOMUIContents::GetScheme().c_str()))
return TAB_CONTENTS_DOM_UI;
diff --git a/chrome/browser/tab_contents/tab_contents_type.h b/chrome/browser/tab_contents/tab_contents_type.h
index 87cd6452..6a8afd9 100644
--- a/chrome/browser/tab_contents/tab_contents_type.h
+++ b/chrome/browser/tab_contents/tab_contents_type.h
@@ -21,6 +21,7 @@ enum TabContentsType {
TAB_CONTENTS_ABOUT_UI,
TAB_CONTENTS_DEBUGGER,
TAB_CONTENTS_DOM_UI,
+ TAB_CONTENTS_TOOLS,
TAB_CONTENTS_NUM_TYPES
};
diff --git a/chrome/browser/tab_contents/web_contents_view.h b/chrome/browser/tab_contents/web_contents_view.h
index 4bf8dca..f286776 100644
--- a/chrome/browser/tab_contents/web_contents_view.h
+++ b/chrome/browser/tab_contents/web_contents_view.h
@@ -108,6 +108,14 @@ 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 ToolsClient in developer tools window open for this
+ // page.
+ virtual void ForwardMessageToToolsClient(int tools_message_type,
+ const std::wstring& body) = 0;
+
// Find in page --------------------------------------------------------------
// Opens the find in page window if it isn't already open. It will advance to
diff --git a/chrome/browser/tab_contents/web_contents_view_gtk.cc b/chrome/browser/tab_contents/web_contents_view_gtk.cc
index 22b450f..41d5033 100644
--- a/chrome/browser/tab_contents/web_contents_view_gtk.cc
+++ b/chrome/browser/tab_contents/web_contents_view_gtk.cc
@@ -77,6 +77,15 @@ void WebContentsViewGtk::SizeContents(const gfx::Size& size) {
NOTIMPLEMENTED();
}
+void WebContentsViewGtk::OpenDeveloperTools() {
+ NOTIMPLEMENTED();
+}
+
+void WebContentsViewGtk::ForwardMessageToToolsClient(int tools_message_type,
+ const std::wstring& body) {
+ 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..2bd347e 100644
--- a/chrome/browser/tab_contents/web_contents_view_gtk.h
+++ b/chrome/browser/tab_contents/web_contents_view_gtk.h
@@ -30,6 +30,9 @@ 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 ForwardMessageToToolsClient(int tools_message_type,
+ const std::wstring& body);
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..26d59f3 100644
--- a/chrome/browser/tab_contents/web_contents_view_mac.h
+++ b/chrome/browser/tab_contents/web_contents_view_mac.h
@@ -46,6 +46,9 @@ 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 ForwardMessageToToolsClient(int tools_message_type,
+ const std::wstring& body);
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 ba80b54..5275993 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::ForwardMessageToToolsClient(int tools_message_type,
+ const std::wstring& body) {
+ 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 9728ec8..be41930 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/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"
@@ -216,6 +217,26 @@ void WebContentsViewWin::SizeContents(const gfx::Size& size) {
WasSized(size);
}
+void WebContentsViewWin::OpenDeveloperTools() {
+ if (!tools_window_.get())
+ tools_window_.reset(new ToolsWindow);
+
+ RenderViewHost* host = web_contents_->render_view_host();
+ if (!host)
+ return;
+
+ tools_window_->Show(host->process()->host_id(), host->routing_id());
+}
+
+void WebContentsViewWin::ForwardMessageToToolsClient(int tools_message_type,
+ const std::wstring& body) {
+ if (!tools_window_.get()) {
+ NOTREACHED() << "Developer tools window is not open.";
+ return;
+ }
+ tools_window_->SendToolsClientMessage(tools_message_type, body);
+}
+
void WebContentsViewWin::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.h b/chrome/browser/tab_contents/web_contents_view_win.h
index a8649d7..2c80eaf 100644
--- a/chrome/browser/tab_contents/web_contents_view_win.h
+++ b/chrome/browser/tab_contents/web_contents_view_win.h
@@ -12,6 +12,7 @@
class FindBarWin;
class SadTabView;
+class ToolsWindow;
struct WebDropData;
class WebDropTarget;
@@ -40,6 +41,9 @@ 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 ForwardMessageToToolsClient(int tools_message_type,
+ const std::wstring& body);
virtual void FindInPage(const Browser& browser,
bool find_next, bool forward_direction);
virtual void HideFindBar(bool end_session);
@@ -108,6 +112,9 @@ class WebContentsViewWin : public WebContentsView,
WebContents* web_contents_;
+ // Allows to show exactly one developer tools window for this page.
+ scoped_ptr<ToolsWindow> tools_window_;
+
// For find in page. This may be NULL if there is no find bar, and if it is
// non-NULL, it may or may not be visible.
scoped_ptr<FindBarWin> find_bar_;