summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-01 07:50:04 +0000
committerpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-01 07:50:04 +0000
commit10fb687b87f5fde62b3df3e2dd5c5d6f5533d715 (patch)
tree32440c96aec4e6fc8f4e9e11f036e599f3e73388 /chrome
parentbb965d182303371fece6ca3254689d73a25e5548 (diff)
downloadchromium_src-10fb687b87f5fde62b3df3e2dd5c5d6f5533d715.zip
chromium_src-10fb687b87f5fde62b3df3e2dd5c5d6f5533d715.tar.gz
chromium_src-10fb687b87f5fde62b3df3e2dd5c5d6f5533d715.tar.bz2
DevTools: Introduce docked version of DevTools.
Review URL: http://codereview.chromium.org/149071 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19713 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/debugger/devtools_container.cc50
-rw-r--r--chrome/browser/debugger/devtools_container.h40
-rw-r--r--chrome/browser/debugger/devtools_manager.cc83
-rw-r--r--chrome/browser/debugger/devtools_manager.h10
-rw-r--r--chrome/browser/debugger/devtools_window.cc188
-rw-r--r--chrome/browser/debugger/devtools_window.h46
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc18
-rw-r--r--chrome/browser/renderer_host/render_view_host.h5
-rw-r--r--chrome/chrome.gyp2
-rw-r--r--chrome/common/render_messages_internal.h11
-rw-r--r--chrome/renderer/devtools_client.cc15
-rw-r--r--chrome/renderer/devtools_client.h4
12 files changed, 404 insertions, 68 deletions
diff --git a/chrome/browser/debugger/devtools_container.cc b/chrome/browser/debugger/devtools_container.cc
new file mode 100644
index 0000000..28e5b62
--- /dev/null
+++ b/chrome/browser/debugger/devtools_container.cc
@@ -0,0 +1,50 @@
+// 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/devtools_client_host.h"
+#include "chrome/browser/debugger/devtools_container.h"
+#include "chrome/browser/debugger/devtools_manager.h"
+#include "chrome/browser/debugger/devtools_window.h"
+#include "chrome/browser/views/frame/browser_view.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/views/tab_contents/tab_contents_container.h"
+
+#include "app/gfx/canvas.h"
+#include "skia/ext/skia_utils_win.h"
+#include "views/background.h"
+
+DevToolsContainer::DevToolsContainer()
+ : devtools_contents_(NULL) {
+ contents_container_ = new TabContentsContainer();
+ AddChildView(contents_container_);
+}
+
+DevToolsContainer::~DevToolsContainer() {
+}
+
+void DevToolsContainer::ChangeTabContents(TabContents* tab_contents) {
+ devtools_contents_ = NULL;
+ if (tab_contents) {
+ DevToolsClientHost* client_host = DevToolsManager::GetInstance()->
+ GetDevToolsClientHostFor(tab_contents->render_view_host());
+ if (client_host) {
+ DevToolsWindow* window = client_host->AsDevToolsWindow();
+ if (window && window->is_docked())
+ devtools_contents_ = window->tab_contents();
+ }
+ }
+ contents_container_->ChangeTabContents(devtools_contents_);
+ SetVisible(devtools_contents_ != NULL);
+ GetParent()->Layout();
+}
+
+gfx::Size DevToolsContainer::GetPreferredSize() {
+ return gfx::Size(800, 200);
+}
+
+void DevToolsContainer::Layout() {
+ contents_container_->SetVisible(true);
+ contents_container_->SetBounds(0, 0, width(), height());
+ contents_container_->Layout();
+}
diff --git a/chrome/browser/debugger/devtools_container.h b/chrome/browser/debugger/devtools_container.h
new file mode 100644
index 0000000..2c55de9
--- /dev/null
+++ b/chrome/browser/debugger/devtools_container.h
@@ -0,0 +1,40 @@
+// 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_DEVTOOLS_CONTAINER_H_
+#define CHROME_BROWSER_DEBUGGER_DEVTOOLS_CONTAINER_H_
+
+#include "base/scoped_ptr.h"
+#include "views/view.h"
+
+class TabContents;
+class TabContentsContainer;
+
+// A views::View subclass that contains a docked dev tools window associated
+// with a TabContents.
+class DevToolsContainer : public views::View {
+ public:
+ explicit DevToolsContainer();
+ virtual ~DevToolsContainer();
+
+ // Changes the TabContents for which this container is showing dev tools. Can
+ // be NULL.
+ void ChangeTabContents(TabContents* tab_contents);
+
+ // Overridden from views::View:
+ virtual gfx::Size GetPreferredSize();
+ virtual void Layout();
+
+ private:
+ TabContents* GetDevToolsContents(TabContents* tab_contents);
+
+ TabContents* devtools_contents_;
+
+ // The view that contains the dev tools for selected TabContents.
+ TabContentsContainer* contents_container_;
+
+ DISALLOW_COPY_AND_ASSIGN(DevToolsContainer);
+};
+
+#endif // CHROME_BROWSER_DEBUGGER_DEVTOOLS_CONTAINER_H_
diff --git a/chrome/browser/debugger/devtools_manager.cc b/chrome/browser/debugger/devtools_manager.cc
index 40dfbb8..605553a 100644
--- a/chrome/browser/debugger/devtools_manager.cc
+++ b/chrome/browser/debugger/devtools_manager.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/site_instance.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/devtools_messages.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
@@ -56,18 +57,9 @@ void DevToolsManager::RegisterDevToolsClientHostFor(
void DevToolsManager::ForwardToDevToolsAgent(
RenderViewHost* client_rvh,
const IPC::Message& message) {
- for (InspectedRvhToClientHostMap::iterator it =
- inspected_rvh_to_client_host_.begin();
- it != inspected_rvh_to_client_host_.end();
- ++it) {
- DevToolsWindow* win = it->second->AsDevToolsWindow();
- if (!win) {
- continue;
- }
- if (client_rvh == win->GetRenderViewHost()) {
- ForwardToDevToolsAgent(win, message);
- return;
- }
+ DevToolsClientHost* client_host = FindOnwerDevToolsClientHost(client_rvh);
+ if (client_host) {
+ ForwardToDevToolsAgent(client_host, message);
}
}
@@ -96,11 +88,34 @@ void DevToolsManager::ForwardToDevToolsClient(RenderViewHost* inspected_rvh,
client_host->SendMessageToClient(message);
}
-void DevToolsManager::OpenDevToolsWindow(RenderViewHost* inspected_rvh) {
+void DevToolsManager::CloseWindow(RenderViewHost* client_rvh) {
+ DevToolsClientHost* client_host = FindOnwerDevToolsClientHost(client_rvh);
+ if (!client_host) {
+ return;
+ }
+ RenderViewHost* inspected_rvh = GetInspectedRenderViewHost(client_host);
+ DCHECK(inspected_rvh);
+ SendDetachToAgent(inspected_rvh);
+
+ UnregisterDevToolsClientHostFor(inspected_rvh);
+}
+
+void DevToolsManager::DockWindow(RenderViewHost* client_rvh) {
+ ReopenWindow(client_rvh, true);
+}
+
+void DevToolsManager::UndockWindow(RenderViewHost* client_rvh) {
+ ReopenWindow(client_rvh, false);
+}
+
+void DevToolsManager::OpenDevToolsWindow(RenderViewHost* inspected_rvh,
+ bool docked) {
DevToolsClientHost* host = GetDevToolsClientHostFor(inspected_rvh);
if (!host) {
- host = new DevToolsWindow(
- inspected_rvh->site_instance()->browsing_instance()->profile());
+ host = DevToolsWindow::CreateDevToolsWindow(
+ inspected_rvh->site_instance()->browsing_instance()->profile(),
+ inspected_rvh,
+ docked);
RegisterDevToolsClientHostFor(inspected_rvh, host);
}
DevToolsWindow* window = host->AsDevToolsWindow();
@@ -147,12 +162,14 @@ void DevToolsManager::UnregisterDevToolsClientHostFor(
if (!host) {
return;
}
- host->InspectedTabClosing();
inspected_rvh_to_client_host_.erase(inspected_rvh);
client_host_to_inspected_rvh_.erase(host);
if (inspected_rvh_for_reopen_ == inspected_rvh) {
inspected_rvh_for_reopen_ = NULL;
}
+
+ // Issue tab closing event post unbound.
+ host->InspectedTabClosing();
}
void DevToolsManager::OnNavigatingToPendingEntry(RenderViewHost* rvh,
@@ -214,3 +231,37 @@ void DevToolsManager::ForceReopenWindow() {
OpenDevToolsWindow(inspected_rvn);
}
}
+
+DevToolsClientHost* DevToolsManager::FindOnwerDevToolsClientHost(
+ RenderViewHost* client_rvh) {
+ for (InspectedRvhToClientHostMap::iterator it =
+ inspected_rvh_to_client_host_.begin();
+ it != inspected_rvh_to_client_host_.end();
+ ++it) {
+ DevToolsWindow* win = it->second->AsDevToolsWindow();
+ if (!win) {
+ continue;
+ }
+ if (client_rvh == win->GetRenderViewHost()) {
+ return it->second;
+ }
+ }
+ return NULL;
+}
+
+void DevToolsManager::ReopenWindow(RenderViewHost* client_rvh, bool docked) {
+ DevToolsClientHost* client_host = FindOnwerDevToolsClientHost(client_rvh);
+ if (!client_host) {
+ return;
+ }
+ DevToolsWindow* window = client_host->AsDevToolsWindow();
+ DCHECK(window);
+ if (window->is_docked() == docked) {
+ return;
+ }
+ RenderViewHost* inspected_rvh = GetInspectedRenderViewHost(client_host);
+ DCHECK(inspected_rvh);
+ SendDetachToAgent(inspected_rvh);
+ UnregisterDevToolsClientHostFor(inspected_rvh);
+ OpenDevToolsWindow(inspected_rvh, docked);
+}
diff --git a/chrome/browser/debugger/devtools_manager.h b/chrome/browser/debugger/devtools_manager.h
index 3790d27..b904e6f 100644
--- a/chrome/browser/debugger/devtools_manager.h
+++ b/chrome/browser/debugger/devtools_manager.h
@@ -44,7 +44,11 @@ class DevToolsManager : public DevToolsClientHost::CloseListener,
void ForwardToDevToolsClient(RenderViewHost* inspected_rvh,
const IPC::Message& message);
- void OpenDevToolsWindow(RenderViewHost* inspected_rvh);
+ void CloseWindow(RenderViewHost* client_rvn);
+ void DockWindow(RenderViewHost* client_rvn);
+ void UndockWindow(RenderViewHost* client_rvn);
+
+ void OpenDevToolsWindow(RenderViewHost* inspected_rvh, bool docked = false);
// Starts element inspection in the devtools client.
// Creates one by means of OpenDevToolsWindow if no client
@@ -73,6 +77,10 @@ private:
void ForceReopenWindow();
+ DevToolsClientHost* FindOnwerDevToolsClientHost(RenderViewHost* client_rvh);
+
+ void ReopenWindow(RenderViewHost* client_rvh, bool docked);
+
// These two maps are for tracking dependencies between inspected tabs and
// their DevToolsClientHosts. They are usful for routing devtools messages
// and allow us to have at most one devtools client host per tab. We use
diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc
index 99b0dcc..f3c81ea 100644
--- a/chrome/browser/debugger/devtools_window.cc
+++ b/chrome/browser/debugger/devtools_window.cc
@@ -5,9 +5,9 @@
#include "app/l10n_util.h"
#include "base/command_line.h"
#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_window.h"
-#include "chrome/browser/debugger/devtools_client_host.h"
#include "chrome/browser/debugger/devtools_manager.h"
#include "chrome/browser/debugger/devtools_window.h"
#include "chrome/browser/profile.h"
@@ -15,6 +15,8 @@
#include "chrome/browser/tab_contents/navigation_entry.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tab_contents/tab_contents_view.h"
+#include "chrome/browser/tabs/tab_strip_model.h"
+#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
@@ -22,10 +24,117 @@
#include "chrome/common/url_constants.h"
#include "grit/generated_resources.h"
-DevToolsWindow::DevToolsWindow(Profile* profile)
- : TabStripModelObserver(),
- inspected_tab_closing_(false) {
+namespace {
+
+class FloatingWindow : public DevToolsWindow,
+ TabStripModelObserver {
+ public:
+ FloatingWindow(Profile* profile);
+ virtual ~FloatingWindow();
+ virtual void Show();
+ virtual void InspectedTabClosing();
+
+ // TabStripModelObserver implementation
+ virtual void TabClosingAt(TabContents* contents, int index);
+ virtual void TabStripEmpty();
+
+ private:
+ bool inspected_tab_closing_;
+ DISALLOW_COPY_AND_ASSIGN(FloatingWindow);
+};
+
+class DockedWindow : public DevToolsWindow {
+ public:
+ DockedWindow(Profile* profile, BrowserWindow* window);
+ virtual ~DockedWindow();
+ virtual void Show();
+ virtual void InspectedTabClosing();
+
+ private:
+
+ BrowserWindow* window_;
+ DISALLOW_COPY_AND_ASSIGN(DockedWindow);
+};
+
+} // namespace
+
+// static
+DevToolsWindow* DevToolsWindow::CreateDevToolsWindow(
+ Profile* profile,
+ RenderViewHost* inspected_rvh,
+ bool docked) {
+ if (docked) {
+ BrowserWindow* window = DevToolsWindow::GetBrowserWindow(inspected_rvh);
+ if (window) {
+ return new DockedWindow(profile, window);
+ }
+ }
+ return new FloatingWindow(profile);
+}
+
+DevToolsWindow::DevToolsWindow(bool docked)
+ : docked_(docked) {
+}
+
+DevToolsWindow::~DevToolsWindow() {
+}
+
+DevToolsWindow* DevToolsWindow::AsDevToolsWindow() {
+ return this;
+}
+
+RenderViewHost* DevToolsWindow::GetRenderViewHost() {
+ return tab_contents_->render_view_host();
+}
+
+void DevToolsWindow::SendMessageToClient(const IPC::Message& message) {
+ RenderViewHost* target_host = tab_contents_->render_view_host();
+ IPC::Message* m = new IPC::Message(message);
+ m->set_routing_id(target_host->routing_id());
+ target_host->Send(m);
+}
+
+void DevToolsWindow::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ tab_contents_->render_view_host()->
+ ExecuteJavascriptInWebFrame(
+ L"", docked_ ? L"WebInspector.setAttachedWindow(true);" :
+ L"WebInspector.setAttachedWindow(false);");
+}
+GURL DevToolsWindow::GetContentsUrl() {
+ return GURL(std::string(chrome::kChromeUIDevToolsURL) + "devtools.html");
+}
+
+void DevToolsWindow::InitTabContents(TabContents* tab_contents) {
+ tab_contents_ = tab_contents;
+ registrar_.Add(this, NotificationType::LOAD_STOP,
+ Source<NavigationController>(&tab_contents_->controller()));
+}
+
+// static
+BrowserWindow* DevToolsWindow::GetBrowserWindow(RenderViewHost* rvh) {
+ for (BrowserList::const_iterator it = BrowserList::begin();
+ it != BrowserList::end(); ++it) {
+ Browser* browser = *it;
+ for (int i = 0; i < browser->tab_count(); ++i) {
+ TabContents* tab_contents = browser->GetTabContentsAt(i);
+ if (tab_contents->render_view_host() == rvh) {
+ return browser->window();
+ }
+ }
+ }
+ return NULL;
+}
+
+//
+// Floating window implementation
+//
+FloatingWindow::FloatingWindow(Profile* profile)
+ : DevToolsWindow(false),
+ TabStripModelObserver(),
+ inspected_tab_closing_(false) {
// TODO(pfeldman): Make browser's getter for this key static.
std::wstring wp_key = L"";
wp_key.append(prefs::kBrowserWindowPlacement);
@@ -49,53 +158,74 @@ DevToolsWindow::DevToolsWindow(Profile* profile)
}
browser_ = Browser::CreateForApp(L"DevToolsApp", profile, false);
- GURL contents(std::string(chrome::kChromeUIDevToolsURL) + "devtools.html");
- browser_->AddTabWithURL(contents, GURL(), PageTransition::START_PAGE, true,
- -1, false, NULL);
- tab_contents_ = browser_->GetSelectedTabContents();
+ browser_->AddTabWithURL(GetContentsUrl(), GURL(), PageTransition::START_PAGE,
+ true, -1, false, NULL);
+ TabContents* tab_contents = browser_->GetSelectedTabContents();
browser_->tabstrip_model()->AddObserver(this);
// Wipe out page icon so that the default application icon is used.
- NavigationEntry* entry = tab_contents_->controller().GetActiveEntry();
+ NavigationEntry* entry = tab_contents->controller().GetActiveEntry();
entry->favicon().set_bitmap(SkBitmap());
entry->favicon().set_is_valid(true);
+
+ InitTabContents(tab_contents);
}
-DevToolsWindow::~DevToolsWindow() {
+FloatingWindow::~FloatingWindow() {
}
-void DevToolsWindow::Show() {
+void FloatingWindow::Show() {
browser_->window()->Show();
tab_contents_->view()->SetInitialFocus();
}
-DevToolsWindow* DevToolsWindow::AsDevToolsWindow() {
- return this;
-}
-
-RenderViewHost* DevToolsWindow::GetRenderViewHost() const {
- return tab_contents_->render_view_host();
-}
-
-void DevToolsWindow::InspectedTabClosing() {
+void FloatingWindow::InspectedTabClosing() {
inspected_tab_closing_ = true;
browser_->CloseAllTabs();
}
-void DevToolsWindow::SendMessageToClient(const IPC::Message& message) {
- RenderViewHost* target_host = tab_contents_->render_view_host();
- IPC::Message* m = new IPC::Message(message);
- m->set_routing_id(target_host->routing_id());
- target_host->Send(m);
-}
-
-void DevToolsWindow::TabClosingAt(TabContents* contents, int index) {
+void FloatingWindow::TabClosingAt(TabContents* contents, int index) {
if (!inspected_tab_closing_ && contents == tab_contents_) {
// Notify manager that this DevToolsClientHost no longer exists.
NotifyCloseListener();
}
}
-void DevToolsWindow::TabStripEmpty() {
+void FloatingWindow::TabStripEmpty() {
delete this;
}
+
+//
+// Docked window implementation
+//
+DockedWindow::DockedWindow(Profile* profile, BrowserWindow* window)
+ : DevToolsWindow(true),
+ window_(window) {
+ TabContents* tab_contents = new TabContents(profile,
+ NULL, MSG_ROUTING_NONE, NULL);
+ tab_contents->render_view_host()->AllowDOMUIBindings();
+ tab_contents->controller().LoadURL(GetContentsUrl(), GURL(),
+ PageTransition::START_PAGE);
+ browser_ = NULL;
+ InitTabContents(tab_contents);
+}
+
+DockedWindow::~DockedWindow() {
+}
+
+void DockedWindow::Show() {
+ //TODO(pfeldman): Add SetDevToolsVisible to BrowserWindow API.
+//#ifdef OS_WIN
+// BrowserView* browser_view = static_cast<BrowserView*>(window_);
+// browser_view->UpdateDevTools();
+// tab_contents_->view()->SetInitialFocus();
+//#endif
+}
+
+void DockedWindow::InspectedTabClosing() {
+//#ifdef OS_WIN
+// BrowserView* browser_view = static_cast<BrowserView*>(window_);
+// browser_view->UpdateDevTools();
+//#endif
+// delete this;
+}
diff --git a/chrome/browser/debugger/devtools_window.h b/chrome/browser/debugger/devtools_window.h
index db6c246..ba75ea7 100644
--- a/chrome/browser/debugger/devtools_window.h
+++ b/chrome/browser/debugger/devtools_window.h
@@ -8,47 +8,55 @@
#include <string>
#include "base/basictypes.h"
-#include "base/scoped_ptr.h"
#include "chrome/browser/debugger/devtools_client_host.h"
-#include "chrome/browser/tabs/tab_strip_model.h"
+#include "chrome/common/notification_registrar.h"
+#include "chrome/common/notification_service.h"
namespace IPC {
class Message;
}
class Browser;
+class BrowserWindow;
class Profile;
class RenderViewHost;
class TabContents;
-class DevToolsWindow : public DevToolsClientHost,
- TabStripModelObserver {
+class DevToolsWindow : public DevToolsClientHost, public NotificationObserver {
public:
- // Factory method for creating platform specific devtools windows.
- DevToolsWindow(Profile* profile);
+ static DevToolsWindow* CreateDevToolsWindow(Profile* profile,
+ RenderViewHost* inspected_rvh,
+ bool docked);
virtual ~DevToolsWindow();
-
- // Show this window.
- void Show();
-
- RenderViewHost* GetRenderViewHost() const;
+ virtual void Show() = 0;
+ bool is_docked() { return docked_; };
+ RenderViewHost* GetRenderViewHost();
// DevToolsClientHost override.
virtual DevToolsWindow* AsDevToolsWindow();
- virtual void InspectedTabClosing();
virtual void SendMessageToClient(const IPC::Message& message);
- // TabStripModelObserver implementation
- virtual void TabClosingAt(TabContents* contents, int index);
- virtual void TabStripEmpty();
+ // NotificationObserver override.
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+ TabContents* tab_contents() { return tab_contents_; }
Browser* browser() { return browser_; }
- private:
- Browser* browser_;
+ protected:
+ DevToolsWindow(bool docked);
+ GURL GetContentsUrl();
+ void InitTabContents(TabContents* tab_contents);
+
TabContents* tab_contents_;
- std::string inspected_url_;
- bool inspected_tab_closing_;
+ Browser* browser_;
+
+ private:
+ static BrowserWindow* GetBrowserWindow(RenderViewHost* rvh);
+ NotificationRegistrar registrar_;
+
+ bool docked_;
DISALLOW_COPY_AND_ASSIGN(DevToolsWindow);
};
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 87f4bf0..d313178 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -733,6 +733,12 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
OnForwardToDevToolsAgent);
IPC_MESSAGE_HANDLER(ViewHostMsg_ForwardToDevToolsClient,
OnForwardToDevToolsClient);
+ IPC_MESSAGE_HANDLER(ViewHostMsg_CloseDevToolsWindow,
+ OnCloseDevToolsWindow);
+ IPC_MESSAGE_HANDLER(ViewHostMsg_DockDevToolsWindow,
+ OnDockDevToolsWindow);
+ IPC_MESSAGE_HANDLER(ViewHostMsg_UndockDevToolsWindow,
+ OnUndockDevToolsWindow);
IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction,
OnUserMetricsRecordAction)
IPC_MESSAGE_HANDLER(ViewHostMsg_MissingPluginStatus, OnMissingPluginStatus);
@@ -1204,6 +1210,18 @@ void RenderViewHost::OnForwardToDevToolsClient(const IPC::Message& message) {
DevToolsManager::GetInstance()->ForwardToDevToolsClient(this, message);
}
+void RenderViewHost::OnCloseDevToolsWindow() {
+ DevToolsManager::GetInstance()->CloseWindow(this);
+}
+
+void RenderViewHost::OnDockDevToolsWindow() {
+ DevToolsManager::GetInstance()->DockWindow(this);
+}
+
+void RenderViewHost::OnUndockDevToolsWindow() {
+ DevToolsManager::GetInstance()->UndockWindow(this);
+}
+
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 0e783a5..a30dbc2 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -515,9 +515,14 @@ class RenderViewHost : public RenderWidgetHost {
void OnAddMessageToConsole(const std::wstring& message,
int32 line_no,
const std::wstring& source_id);
+
void OnUpdateInspectorSettings(const std::wstring& raw_settings);
void OnForwardToDevToolsAgent(const IPC::Message& message);
void OnForwardToDevToolsClient(const IPC::Message& message);
+ void OnCloseDevToolsWindow();
+ void OnDockDevToolsWindow();
+ void OnUndockDevToolsWindow();
+
void OnUserMetricsRecordAction(const std::wstring& action);
void OnMissingPluginStatus(int status);
void OnMessageReceived(IPC::Message* msg) { }
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index d47a5c0..852d27e0 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -2112,6 +2112,8 @@
'browser/debugger/devtools_remote_message.h',
'browser/debugger/devtools_remote_service.cc',
'browser/debugger/devtools_remote_service.h',
+ 'browser/debugger/devtools_container.cc',
+ 'browser/debugger/devtools_container.h',
'browser/debugger/devtools_window.cc',
'browser/debugger/devtools_window.h',
'browser/debugger/inspectable_tab_proxy.cc',
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index c8de0fe..dc94406 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -1092,9 +1092,14 @@ IPC_BEGIN_MESSAGES(ViewHost)
IPC_MESSAGE_ROUTED1(ViewHostMsg_ForwardToDevToolsAgent,
IPC::Message /* one of DevToolsAgentMsg_XXX types */)
- IPC_MESSAGE_ROUTED2(ViewHostMsg_ToolsAgentMsg,
- int, /* tools msg type */
- std::wstring /* body */)
+ // Closes dev tools window that is inspecting current render_view_host.
+ IPC_MESSAGE_ROUTED0(ViewHostMsg_CloseDevToolsWindow)
+
+ // Attaches dev tools window that is inspecting current render_view_host.
+ IPC_MESSAGE_ROUTED0(ViewHostMsg_DockDevToolsWindow)
+
+ // Detaches dev tools window that is inspecting current render_view_host.
+ IPC_MESSAGE_ROUTED0(ViewHostMsg_UndockDevToolsWindow)
// Send back a string to be recorded by UserMetrics.
IPC_MESSAGE_ROUTED1(ViewHostMsg_UserMetricsRecordAction,
diff --git a/chrome/renderer/devtools_client.cc b/chrome/renderer/devtools_client.cc
index b0f9a8f..feca1a71 100644
--- a/chrome/renderer/devtools_client.cc
+++ b/chrome/renderer/devtools_client.cc
@@ -51,6 +51,21 @@ void DevToolsClient::ActivateWindow() {
render_view_->TakeFocus(render_view_->webview(), false);
}
+void DevToolsClient::CloseWindow() {
+ render_view_->Send(new ViewHostMsg_CloseDevToolsWindow(
+ render_view_->routing_id()));
+}
+
+void DevToolsClient::DockWindow() {
+ render_view_->Send(new ViewHostMsg_DockDevToolsWindow(
+ render_view_->routing_id()));
+}
+
+void DevToolsClient::UndockWindow() {
+ render_view_->Send(new ViewHostMsg_UndockDevToolsWindow(
+ render_view_->routing_id()));
+}
+
void DevToolsClient::OnRpcMessage(const std::string& class_name,
const std::string& method_name,
const std::string& raw_msg) {
diff --git a/chrome/renderer/devtools_client.h b/chrome/renderer/devtools_client.h
index 744232a..295cb30 100644
--- a/chrome/renderer/devtools_client.h
+++ b/chrome/renderer/devtools_client.h
@@ -37,7 +37,11 @@ class DevToolsClient : public WebDevToolsClientDelegate {
const std::string& method_name,
const std::string& raw_msg);
virtual void SendDebuggerCommandToAgent(const std::string& command);
+
virtual void ActivateWindow();
+ virtual void CloseWindow();
+ virtual void DockWindow();
+ virtual void UndockWindow();
private:
void OnRpcMessage(const std::string& class_name,