summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-07 06:27:41 +0000
committerpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-07 06:27:41 +0000
commit684b4ba293df8f279147ea9d4b4bc665ec44a153 (patch)
treea712bd8032c65a38a0e8a0dffa2ed70286008f20 /chrome
parent122336cf5ea64521747cc22ec6bd0d918ba2e489 (diff)
downloadchromium_src-684b4ba293df8f279147ea9d4b4bc665ec44a153.zip
chromium_src-684b4ba293df8f279147ea9d4b4bc665ec44a153.tar.gz
chromium_src-684b4ba293df8f279147ea9d4b4bc665ec44a153.tar.bz2
DevTools: Enable debugging of non-TabContents including extensions.
Review URL: http://codereview.chromium.org/115028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15526 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser.cc10
-rw-r--r--chrome/browser/debugger/debugger_remote_service.cc15
-rw-r--r--chrome/browser/debugger/devtools_manager.cc204
-rw-r--r--chrome/browser/debugger/devtools_manager.h81
-rw-r--r--chrome/browser/debugger/devtools_manager_unittest.cc14
-rw-r--r--chrome/browser/debugger/devtools_view.cc2
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc32
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.cc9
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc10
9 files changed, 151 insertions, 226 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 78f1293..7d521b6 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -1053,14 +1053,8 @@ void Browser::OpenDebuggerWindow() {
void Browser::OpenJavaScriptConsole() {
UserMetrics::RecordAction(L"ShowJSConsole", profile_);
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableOutOfProcessDevTools)) {
- DevToolsManager* manager = g_browser_process->devtools_manager();
- manager->OpenDevToolsWindow(GetSelectedTabContents());
- } else {
- GetSelectedTabContents()->render_view_host()->
- ShowJavaScriptConsole();
- }
+ GetSelectedTabContents()->render_view_host()->
+ ShowJavaScriptConsole();
}
void Browser::OpenTaskManager() {
diff --git a/chrome/browser/debugger/debugger_remote_service.cc b/chrome/browser/debugger/debugger_remote_service.cc
index 729dc8a..95e8ec6 100644
--- a/chrome/browser/debugger/debugger_remote_service.cc
+++ b/chrome/browser/debugger/debugger_remote_service.cc
@@ -86,14 +86,14 @@ void DebuggerRemoteService::HandleMessage(
TabContents* tab_contents = ToTabContents(tab_uid);
if (tab_contents != NULL) {
DevToolsClientHost* client_host =
- manager->GetDevToolsClientHostFor(*tab_contents);
+ manager->GetDevToolsClientHostFor(tab_contents->render_view_host());
if (client_host != NULL) {
std::string v8_command;
DictionaryValue* v8_command_value;
content->GetDictionary(kDataWide, &v8_command_value);
JSONWriter::Write(v8_command_value, false, &v8_command);
g_browser_process->devtools_manager()->ForwardToDevToolsAgent(
- *client_host, DevToolsAgentMsg_DebuggerCommand(v8_command));
+ client_host, DevToolsAgentMsg_DebuggerCommand(v8_command));
send_response = false;
// Do not send response right now as the JSON will be received from
// the V8 debugger asynchronously
@@ -213,14 +213,15 @@ void DebuggerRemoteService::AttachTab(const std::string& destination,
response->SetInteger(kResultWide, Result::kUnknownTab);
return;
}
+ RenderViewHost* target_host = tab_contents->render_view_host();
if (g_browser_process->devtools_manager()->GetDevToolsClientHostFor(
- *tab_contents) == NULL) {
+ target_host) == NULL) {
DevToolsClientHost* client_host =
delegate_->inspectable_tab_proxy()->NewClientHost(tab_uid, this);
DevToolsManager* manager = g_browser_process->devtools_manager();
if (manager != NULL) {
- manager->RegisterDevToolsClientHostFor(*tab_contents, client_host);
- manager->ForwardToDevToolsAgent(*client_host, DevToolsAgentMsg_Attach());
+ manager->RegisterDevToolsClientHostFor(target_host, client_host);
+ manager->ForwardToDevToolsAgent(client_host, DevToolsAgentMsg_Attach());
response->SetInteger(kResultWide, Result::kOk);
} else {
response->SetInteger(kResultWide, Result::kDebuggerError);
@@ -251,10 +252,10 @@ void DebuggerRemoteService::DetachTab(const std::string& destination,
DevToolsManager* manager = g_browser_process->devtools_manager();
if (manager != NULL) {
DevToolsClientHost* client_host =
- manager->GetDevToolsClientHostFor(*tab_contents);
+ manager->GetDevToolsClientHostFor(tab_contents->render_view_host());
if (client_host != NULL) {
manager->ForwardToDevToolsAgent(
- *client_host, DevToolsAgentMsg_Detach());
+ client_host, DevToolsAgentMsg_Detach());
client_host->InspectedTabClosing();
resultCode = Result::kOk;
} else {
diff --git a/chrome/browser/debugger/devtools_manager.cc b/chrome/browser/debugger/devtools_manager.cc
index cf89d49..193cb0a 100644
--- a/chrome/browser/debugger/devtools_manager.cc
+++ b/chrome/browser/debugger/devtools_manager.cc
@@ -7,219 +7,157 @@
#include "chrome/browser/debugger/devtools_window.h"
#include "chrome/browser/debugger/devtools_client_host.h"
#include "chrome/browser/renderer_host/render_view_host.h"
-#include "chrome/browser/tab_contents/navigation_entry.h"
-#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/devtools_messages.h"
-#include "chrome/common/notification_registrar.h"
-#include "chrome/common/notification_type.h"
#include "googleurl/src/gurl.h"
-DevToolsManager::DevToolsManager() : tab_contents_listeners_(NULL) {
+DevToolsManager::DevToolsManager() {
}
DevToolsManager::~DevToolsManager() {
- DCHECK(!tab_contents_listeners_.get()) <<
- "All devtools client hosts must alredy have been destroyed.";
- DCHECK(navcontroller_to_client_host_.empty());
- DCHECK(client_host_to_navcontroller_.empty());
-}
-
-void DevToolsManager::Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- DCHECK(type == NotificationType::TAB_CONTENTS_DISCONNECTED);
-
- if (type == NotificationType::TAB_CONTENTS_DISCONNECTED) {
- Source<TabContents> src(source);
- DevToolsClientHost* client_host = GetDevToolsClientHostFor(*src.ptr());
- if (!client_host) {
- return;
- }
-
- // Active tab contents disconnecting from its renderer means that the tab
- // is closing.
- client_host->InspectedTabClosing();
- UnregisterDevToolsClientHost(client_host, &src->controller());
- }
+ DCHECK(inspected_rvh_to_client_host_.empty());
+ DCHECK(client_host_to_inspected_rvh_.empty());
}
DevToolsClientHost* DevToolsManager::GetDevToolsClientHostFor(
- const TabContents& tab_contents) {
- const NavigationController& navigation_controller = tab_contents.controller();
- ClientHostMap::const_iterator it =
- navcontroller_to_client_host_.find(&navigation_controller);
- if (it != navcontroller_to_client_host_.end()) {
+ RenderViewHost* inspected_rvh) {
+ InspectedRvhToClientHostMap::iterator it =
+ inspected_rvh_to_client_host_.find(inspected_rvh);
+ if (it != inspected_rvh_to_client_host_.end()) {
return it->second;
}
return NULL;
}
void DevToolsManager::RegisterDevToolsClientHostFor(
- TabContents& tab_contents,
+ RenderViewHost* inspected_rvh,
DevToolsClientHost* client_host) {
- DCHECK(!GetDevToolsClientHostFor(tab_contents));
+ DCHECK(!GetDevToolsClientHostFor(inspected_rvh));
- NavigationController* navigation_controller = &tab_contents.controller();
- navcontroller_to_client_host_[navigation_controller] = client_host;
- client_host_to_navcontroller_[client_host] = navigation_controller;
+ inspected_rvh_to_client_host_[inspected_rvh] = client_host;
+ client_host_to_inspected_rvh_[client_host] = inspected_rvh;
client_host->set_close_listener(this);
- StartListening(navigation_controller);
- SendAttachToAgent(tab_contents.render_view_host());
+ SendAttachToAgent(inspected_rvh);
}
void DevToolsManager::ForwardToDevToolsAgent(
- const RenderViewHost& client_rvh,
+ RenderViewHost* client_rvh,
const IPC::Message& message) {
- for (ClientHostMap::const_iterator it =
- navcontroller_to_client_host_.begin();
- it != navcontroller_to_client_host_.end();
- ++it) {
+ 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 (win->HasRenderViewHost(client_rvh)) {
- ForwardToDevToolsAgent(*win, message);
+ if (win->HasRenderViewHost(*client_rvh)) {
+ ForwardToDevToolsAgent(win, message);
return;
}
}
}
-void DevToolsManager::ForwardToDevToolsAgent(const DevToolsClientHost& from,
+void DevToolsManager::ForwardToDevToolsAgent(DevToolsClientHost* from,
const IPC::Message& message) {
- NavigationController* nav_controller =
- GetDevToolsAgentNavigationController(from);
- if (!nav_controller) {
+ RenderViewHost* inspected_rvh = GetInspectedRenderViewHost(from);
+ if (!inspected_rvh) {
+ // TODO(yurys): notify client that the agent is no longer available
NOTREACHED();
return;
}
- // TODO(yurys): notify client that the agent is no longer available
- TabContents* tc = nav_controller->tab_contents();
- if (!tc) {
- return;
- }
- RenderViewHost* target_host = tc->render_view_host();
- if (!target_host) {
- return;
- }
-
IPC::Message* m = new IPC::Message(message);
- m->set_routing_id(target_host->routing_id());
- target_host->Send(m);
+ m->set_routing_id(inspected_rvh->routing_id());
+ inspected_rvh->Send(m);
}
-void DevToolsManager::ForwardToDevToolsClient(const RenderViewHost& from,
+void DevToolsManager::ForwardToDevToolsClient(RenderViewHost* inspected_rvh,
const IPC::Message& message) {
- TabContents* tc = from.delegate()->GetAsTabContents();
- DevToolsClientHost* target_host = GetDevToolsClientHostFor(*tc);
- if (!target_host) {
+ DevToolsClientHost* client_host = GetDevToolsClientHostFor(inspected_rvh);
+ if (!client_host) {
// Client window was closed while there were messages
// being sent to it.
return;
}
- target_host->SendMessageToClient(message);
+ client_host->SendMessageToClient(message);
}
-void DevToolsManager::OpenDevToolsWindow(TabContents* wc) {
- DevToolsClientHost* host = GetDevToolsClientHostFor(*wc);
+void DevToolsManager::OpenDevToolsWindow(RenderViewHost* inspected_rvh) {
+ DevToolsClientHost* host = GetDevToolsClientHostFor(inspected_rvh);
if (!host) {
host = DevToolsWindow::Create();
- RegisterDevToolsClientHostFor(*wc, host);
+ RegisterDevToolsClientHostFor(inspected_rvh, host);
}
DevToolsWindow* window = host->AsDevToolsWindow();
if (window)
window->Show();
}
-void DevToolsManager::InspectElement(TabContents* wc, int x, int y) {
- OpenDevToolsWindow(wc);
- RenderViewHost* target_host = wc->render_view_host();
- if (!target_host) {
- return;
- }
+void DevToolsManager::InspectElement(RenderViewHost* inspected_rvh,
+ int x,
+ int y) {
+ OpenDevToolsWindow(inspected_rvh);
IPC::Message* m = new DevToolsAgentMsg_InspectElement(x, y);
- m->set_routing_id(target_host->routing_id());
- target_host->Send(m);
+ m->set_routing_id(inspected_rvh->routing_id());
+ inspected_rvh->Send(m);
}
void DevToolsManager::ClientHostClosing(DevToolsClientHost* host) {
- NavigationController* controller = GetDevToolsAgentNavigationController(
- *host);
- if (!controller) {
+ RenderViewHost* inspected_rvh = GetInspectedRenderViewHost(host);
+ if (!inspected_rvh) {
return;
}
+ SendDetachToAgent(inspected_rvh);
- TabContents* tab_contents = controller->tab_contents();
- if (!tab_contents) {
- return;
- }
- SendDetachToAgent(tab_contents->render_view_host());
- UnregisterDevToolsClientHost(host, controller);
+ inspected_rvh_to_client_host_.erase(inspected_rvh);
+ client_host_to_inspected_rvh_.erase(host);
}
-NavigationController* DevToolsManager::GetDevToolsAgentNavigationController(
- const DevToolsClientHost& client_host) {
- NavControllerMap::const_iterator it =
- client_host_to_navcontroller_.find(&client_host);
- if (it != client_host_to_navcontroller_.end()) {
+RenderViewHost* DevToolsManager::GetInspectedRenderViewHost(
+ DevToolsClientHost* client_host) {
+ ClientHostToInspectedRvhMap::iterator it =
+ client_host_to_inspected_rvh_.find(client_host);
+ if (it != client_host_to_inspected_rvh_.end()) {
return it->second;
}
return NULL;
}
-void DevToolsManager::UnregisterDevToolsClientHost(
- DevToolsClientHost* client_host,
- NavigationController* controller) {
- navcontroller_to_client_host_.erase(controller);
- client_host_to_navcontroller_.erase(client_host);
- StopListening(controller);
-}
-
-void DevToolsManager::StartListening(
- NavigationController* navigation_controller) {
- // TODO(yurys): add render host change listener
- if (!tab_contents_listeners_.get()) {
- tab_contents_listeners_.reset(new NotificationRegistrar);
- tab_contents_listeners_->Add(
- this,
- NotificationType::TAB_CONTENTS_DISCONNECTED,
- NotificationService::AllSources());
- }
-}
-
-void DevToolsManager::StopListening(
- NavigationController* navigation_controller) {
- DCHECK(tab_contents_listeners_.get());
- if (navcontroller_to_client_host_.empty()) {
- DCHECK(client_host_to_navcontroller_.empty());
- tab_contents_listeners_.reset();
+void DevToolsManager::UnregisterDevToolsClientHostFor(
+ RenderViewHost* inspected_rvh) {
+ DevToolsClientHost* host = GetDevToolsClientHostFor(inspected_rvh);
+ if (!host) {
+ return;
}
+ host->InspectedTabClosing();
+ inspected_rvh_to_client_host_.erase(inspected_rvh);
+ client_host_to_inspected_rvh_.erase(host);
}
-void DevToolsManager::OnNavigatingToPendingEntry(const TabContents& wc,
- RenderViewHost* target_host) {
- DevToolsClientHost* client_host = GetDevToolsClientHostFor(wc);
+void DevToolsManager::OnNavigatingToPendingEntry(RenderViewHost* inspected_rvh,
+ RenderViewHost* dest_rvh,
+ const GURL& gurl) {
+ DevToolsClientHost* client_host =
+ GetDevToolsClientHostFor(inspected_rvh);
if (client_host) {
- const NavigationEntry& entry = *wc.controller().pending_entry();
- client_host->SetInspectedTabUrl(entry.url().possibly_invalid_spec());
- SendAttachToAgent(target_host);
+ client_host->SetInspectedTabUrl(gurl.possibly_invalid_spec());
+ SendAttachToAgent(dest_rvh);
}
}
-void DevToolsManager::SendAttachToAgent(RenderViewHost* target_host) {
- if (target_host) {
+void DevToolsManager::SendAttachToAgent(RenderViewHost* inspected_rvh) {
+ if (inspected_rvh) {
IPC::Message* m = new DevToolsAgentMsg_Attach();
- m->set_routing_id(target_host->routing_id());
- target_host->Send(m);
+ m->set_routing_id(inspected_rvh->routing_id());
+ inspected_rvh->Send(m);
}
}
-void DevToolsManager::SendDetachToAgent(RenderViewHost* target_host) {
- if (target_host) {
+void DevToolsManager::SendDetachToAgent(RenderViewHost* inspected_rvh) {
+ if (inspected_rvh) {
IPC::Message* m = new DevToolsAgentMsg_Detach();
- m->set_routing_id(target_host->routing_id());
- target_host->Send(m);
+ m->set_routing_id(inspected_rvh->routing_id());
+ inspected_rvh->Send(m);
}
}
diff --git a/chrome/browser/debugger/devtools_manager.h b/chrome/browser/debugger/devtools_manager.h
index d29a6ea..3f9bdc8 100644
--- a/chrome/browser/debugger/devtools_manager.h
+++ b/chrome/browser/debugger/devtools_manager.h
@@ -7,86 +7,65 @@
#include <map>
-#include "base/basictypes.h"
-#include "base/scoped_ptr.h"
#include "chrome/browser/debugger/devtools_client_host.h"
-#include "chrome/common/notification_service.h"
namespace IPC {
class Message;
}
-class DevToolsClientHost;
-class NavigationController;
-class NotificationRegistrar;
+class GURL;
class RenderViewHost;
-class TabContents;
// This class is a singleton that manages DevToolsClientHost instances and
// routes messages between developer tools clients and agents.
-class DevToolsManager : public NotificationObserver,
- public DevToolsClientHost::CloseListener {
+class DevToolsManager : public DevToolsClientHost::CloseListener {
public:
DevToolsManager();
virtual ~DevToolsManager();
- // Returns DevToolsClientHost registered for |tab_contents| or NULL if
- // there is no alive DevToolsClientHost registered for |tab_contents|.
- DevToolsClientHost* GetDevToolsClientHostFor(const TabContents& tab_contents);
+ // Returns DevToolsClientHost registered for |inspected_rvh| or NULL if
+ // there is no alive DevToolsClientHost registered for |inspected_rvh|.
+ DevToolsClientHost* GetDevToolsClientHostFor(RenderViewHost* inspected_rvh);
- // Registers new DevToolsClientHost for |tab_contents|. There must be no
- // other DevToolsClientHosts registered for the TabContents at the moment.
- void RegisterDevToolsClientHostFor(TabContents& tab_contents,
+ // Registers new DevToolsClientHost for |inspected_rvh|. There must be no
+ // other DevToolsClientHosts registered for the RenderViewHost at the moment.
+ void RegisterDevToolsClientHostFor(RenderViewHost* inspected_rvh,
DevToolsClientHost* client_host);
+ void UnregisterDevToolsClientHostFor(RenderViewHost* inspected_rvh);
- void ForwardToDevToolsAgent(const RenderViewHost& client_rvh,
+ void ForwardToDevToolsAgent(RenderViewHost* client_rvh,
const IPC::Message& message);
- void ForwardToDevToolsAgent(const DevToolsClientHost& from,
+ void ForwardToDevToolsAgent(DevToolsClientHost* from,
const IPC::Message& message);
- void ForwardToDevToolsClient(const RenderViewHost& from,
+ void ForwardToDevToolsClient(RenderViewHost* inspected_rvh,
const IPC::Message& message);
- void OpenDevToolsWindow(TabContents* wc);
+ void OpenDevToolsWindow(RenderViewHost* inspected_rvh);
// Starts element inspection in the devtools client.
// Creates one by means of OpenDevToolsWindow if no client
// exists.
- void InspectElement(TabContents* tab_contents, int x, int y);
+ void InspectElement(RenderViewHost* inspected_rvh, int x, int y);
- // Sends 'Attach' message to the agent using |target_host| in case
- // there is a DevToolsClientHost registered for the |tab_contents|.
- void OnNavigatingToPendingEntry(
- const TabContents& tab_contents,
- RenderViewHost* target_host);
+ // Sends 'Attach' message to the agent using |dest_rvh| in case
+ // there is a DevToolsClientHost registered for the |inspected_rvh|.
+ void OnNavigatingToPendingEntry(RenderViewHost* inspected_rvh,
+ RenderViewHost* dest_rvh,
+ const GURL& gurl);
private:
- // NotificationObserver override.
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details);
-
// DevToolsClientHost::CloseListener override.
// This method will remove all references from the manager to the
// DevToolsClientHost and unregister all listeners related to the
// DevToolsClientHost.
virtual void ClientHostClosing(DevToolsClientHost* host);
- // Returns NavigationController for the tab that is inspected by devtools
+ // Returns RenderViewHost for the tab that is inspected by devtools
// client hosted by DevToolsClientHost.
- NavigationController* GetDevToolsAgentNavigationController(
- const DevToolsClientHost& client_host);
-
- void UnregisterDevToolsClientHost(
- DevToolsClientHost* client_host,
- NavigationController* navigation_controller);
- void StartListening(NavigationController* navigation_controller);
- void StopListening(NavigationController* navigation_controller);
- void SendAttachToAgent(RenderViewHost* target_host);
- void SendDetachToAgent(RenderViewHost* target_host);
-
- // This object is not NULL iff there is at least one registered
- // DevToolsClientHost.
- scoped_ptr<NotificationRegistrar> tab_contents_listeners_;
+ RenderViewHost* GetInspectedRenderViewHost(DevToolsClientHost* client_host);
+
+ void SendAttachToAgent(RenderViewHost* inspected_rvh);
+ void SendDetachToAgent(RenderViewHost* inspected_rvh);
// These two maps are for tracking dependencies between inspected tabs and
// their DevToolsClientHosts. They are usful for routing devtools messages
@@ -96,13 +75,13 @@ private:
//
// DevToolsManager start listening to DevToolsClientHosts when they are put
// into these maps and removes them when they are closing.
- typedef std::map<const NavigationController*,
- DevToolsClientHost*> ClientHostMap;
- ClientHostMap navcontroller_to_client_host_;
+ typedef std::map<RenderViewHost*, DevToolsClientHost*>
+ InspectedRvhToClientHostMap;
+ InspectedRvhToClientHostMap inspected_rvh_to_client_host_;
- typedef std::map<const DevToolsClientHost*,
- NavigationController*> NavControllerMap;
- NavControllerMap client_host_to_navcontroller_;
+ typedef std::map<DevToolsClientHost*, RenderViewHost*>
+ ClientHostToInspectedRvhMap;
+ ClientHostToInspectedRvhMap client_host_to_inspected_rvh_;
DISALLOW_COPY_AND_ASSIGN(DevToolsManager);
};
diff --git a/chrome/browser/debugger/devtools_manager_unittest.cc b/chrome/browser/debugger/devtools_manager_unittest.cc
index 5744471..5946c07 100644
--- a/chrome/browser/debugger/devtools_manager_unittest.cc
+++ b/chrome/browser/debugger/devtools_manager_unittest.cc
@@ -73,24 +73,24 @@ class DevToolsManagerTest : public RenderViewHostTestHarness {
TEST_F(DevToolsManagerTest, OpenAndManuallyCloseDevToolsClientHost) {
DevToolsManager manager;
- DevToolsClientHost* host = manager.GetDevToolsClientHostFor(*contents());
+ DevToolsClientHost* host = manager.GetDevToolsClientHostFor(rvh());
EXPECT_TRUE(NULL == host);
TestDevToolsClientHost client_host;
- manager.RegisterDevToolsClientHostFor(*contents(), &client_host);
+ manager.RegisterDevToolsClientHostFor(rvh(), &client_host);
// Test that just registered devtools host is returned.
- host = manager.GetDevToolsClientHostFor(*contents());
+ host = manager.GetDevToolsClientHostFor(rvh());
EXPECT_TRUE(&client_host == host);
EXPECT_EQ(0, TestDevToolsClientHost::close_counter);
// Test that the same devtools host is returned.
- host = manager.GetDevToolsClientHostFor(*contents());
+ host = manager.GetDevToolsClientHostFor(rvh());
EXPECT_TRUE(&client_host == host);
EXPECT_EQ(0, TestDevToolsClientHost::close_counter);
client_host.Close();
EXPECT_EQ(1, TestDevToolsClientHost::close_counter);
- host = manager.GetDevToolsClientHostFor(*contents());
+ host = manager.GetDevToolsClientHostFor(rvh());
EXPECT_TRUE(NULL == host);
}
@@ -98,11 +98,11 @@ TEST_F(DevToolsManagerTest, ForwardMessageToClient) {
DevToolsManager manager;
TestDevToolsClientHost client_host;
- manager.RegisterDevToolsClientHostFor(*contents(), &client_host);
+ manager.RegisterDevToolsClientHostFor(rvh(), &client_host);
EXPECT_EQ(0, TestDevToolsClientHost::close_counter);
IPC::Message m;
- manager.ForwardToDevToolsClient(*contents()->render_view_host(), m);
+ manager.ForwardToDevToolsClient(rvh(), m);
EXPECT_TRUE(&m == client_host.last_sent_message);
client_host.Close();
diff --git a/chrome/browser/debugger/devtools_view.cc b/chrome/browser/debugger/devtools_view.cc
index 3827ef5..d391139 100644
--- a/chrome/browser/debugger/devtools_view.cc
+++ b/chrome/browser/debugger/devtools_view.cc
@@ -87,7 +87,7 @@ bool DevToolsView::AcceleratorPressed(const views::Accelerator& accelerator) {
return false;
}
DevToolsManager* manager = g_browser_process->devtools_manager();
- manager->OpenDevToolsWindow(tab_contents_);
+ manager->OpenDevToolsWindow(tab_contents_->render_view_host());
return true;
}
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index b31181b..843a110 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -8,6 +8,7 @@
#include <vector>
#include "app/resource_bundle.h"
+#include "base/command_line.h"
#include "base/gfx/native_widget_types.h"
#include "base/string_util.h"
#include "base/time.h"
@@ -32,6 +33,7 @@
#include "chrome/common/notification_type.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/result_codes.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/thumbnail_score.h"
#include "chrome/common/url_constants.h"
#include "net/base/net_util.h"
@@ -558,14 +560,27 @@ void RenderViewHost::CopyImageAt(int x, int y) {
}
void RenderViewHost::InspectElementAt(int x, int y) {
- RendererSecurityPolicy::GetInstance()->GrantInspectElement(process()->pid());
- Send(new ViewMsg_InspectElement(routing_id(), x, y));
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableOutOfProcessDevTools)) {
+ DevToolsManager* manager = g_browser_process->devtools_manager();
+ manager->InspectElement(this, x, y);
+ } else {
+ RendererSecurityPolicy::GetInstance()->
+ GrantInspectElement(process()->pid());
+ Send(new ViewMsg_InspectElement(routing_id(), x, y));
+ }
}
void RenderViewHost::ShowJavaScriptConsole() {
- RendererSecurityPolicy::GetInstance()->GrantInspectElement(process()->pid());
-
- Send(new ViewMsg_ShowJavaScriptConsole(routing_id()));
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableOutOfProcessDevTools)) {
+ DevToolsManager* manager = g_browser_process->devtools_manager();
+ manager->OpenDevToolsWindow(this);
+ } else {
+ RendererSecurityPolicy::GetInstance()->
+ GrantInspectElement(process()->pid());
+ Send(new ViewMsg_ShowJavaScriptConsole(routing_id()));
+ }
}
void RenderViewHost::DragSourceEndedAt(
@@ -1218,11 +1233,11 @@ void RenderViewHost::DidDebugAttach() {
}
void RenderViewHost::OnForwardToDevToolsAgent(const IPC::Message& message) {
- g_browser_process->devtools_manager()->ForwardToDevToolsAgent(*this, message);
+ g_browser_process->devtools_manager()->ForwardToDevToolsAgent(this, message);
}
void RenderViewHost::OnForwardToDevToolsClient(const IPC::Message& message) {
- g_browser_process->devtools_manager()->ForwardToDevToolsClient(*this,
+ g_browser_process->devtools_manager()->ForwardToDevToolsClient(this,
message);
}
@@ -1351,6 +1366,9 @@ void RenderViewHost::OnDebugDisconnect() {
debugger_attached_ = false;
g_browser_process->debugger_wrapper()->OnDebugDisconnect();
}
+ DevToolsManager* devtools_manager = g_browser_process->devtools_manager();
+ if (devtools_manager) // NULL in tests
+ devtools_manager->UnregisterDevToolsClientHostFor(this);
}
void RenderViewHost::ForwardMessageFromExternalHost(const std::string& message,
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index bde8749..35624d3 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -11,7 +11,6 @@
#include "base/scoped_clipboard_writer.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/debugger/devtools_manager.h"
#include "chrome/browser/download/download_manager.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/search_engines/template_url_model.h"
@@ -636,13 +635,7 @@ void RenderViewContextMenu::CopyImageAt(int x, int y) {
}
void RenderViewContextMenu::Inspect(int x, int y) {
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableOutOfProcessDevTools)) {
- g_browser_process->devtools_manager()->InspectElement(
- source_tab_contents_, x, y);
- } else {
- source_tab_contents_->render_view_host()->InspectElementAt(x, y);
- }
+ source_tab_contents_->render_view_host()->InspectElementAt(x, y);
}
void RenderViewContextMenu::WriteTextToClipboard(
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 14cdd22..4582bbe 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -678,10 +678,12 @@ bool TabContents::NavigateToPendingEntry(bool reload) {
return false; // Unable to create the desired render view host.
// Tell DevTools agent that it is attached prior to the navigation.
- DevToolsManager* dev_tools_manager = g_browser_process->devtools_manager();
- if (dev_tools_manager) // NULL in unit tests.
- dev_tools_manager->OnNavigatingToPendingEntry(*this,
- dest_render_view_host);
+ DevToolsManager* devtools_manager = g_browser_process->devtools_manager();
+ if (devtools_manager) // NULL in unit tests.
+ devtools_manager->OnNavigatingToPendingEntry(
+ render_view_host(),
+ dest_render_view_host,
+ controller_.pending_entry()->url());
// Used for page load time metrics.
current_load_start_ = base::TimeTicks::Now();