summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-02 17:59:36 +0000
committerpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-02 17:59:36 +0000
commitaa7e932f4c29e47c1f69afc8781115eaba0185bc (patch)
treefe227fa5da525f47e46a7c42a506e0a70817190f /chrome/browser
parent4f967820e2e2e24b438c230cc781df62ecdc2c89 (diff)
downloadchromium_src-aa7e932f4c29e47c1f69afc8781115eaba0185bc.zip
chromium_src-aa7e932f4c29e47c1f69afc8781115eaba0185bc.tar.gz
chromium_src-aa7e932f4c29e47c1f69afc8781115eaba0185bc.tar.bz2
DevTools: support cross-navigation instrumentation.
Review URL: http://codereview.chromium.org/343075 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30713 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/debugger/devtools_manager.cc35
-rw-r--r--chrome/browser/debugger/devtools_manager.h14
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc9
-rw-r--r--chrome/browser/renderer_host/render_view_host.h2
4 files changed, 54 insertions, 6 deletions
diff --git a/chrome/browser/debugger/devtools_manager.cc b/chrome/browser/debugger/devtools_manager.cc
index cc8cb22..2028904 100644
--- a/chrome/browser/debugger/devtools_manager.cc
+++ b/chrome/browser/debugger/devtools_manager.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/debugger/devtools_manager.h"
+#include <vector>
+
#include "base/message_loop.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browsing_instance.h"
@@ -57,7 +59,7 @@ void DevToolsManager::RegisterDevToolsClientHostFor(
client_host_to_inspected_rvh_[client_host] = inspected_rvh;
client_host->set_close_listener(this);
- SendAttachToAgent(inspected_rvh);
+ SendAttachToAgent(inspected_rvh, std::set<std::string>());
}
void DevToolsManager::ForwardToDevToolsAgent(
@@ -134,6 +136,22 @@ void DevToolsManager::ToggleDevToolsWindow(RenderViewHost* inspected_rvh) {
ToggleDevToolsWindow(inspected_rvh, false);
}
+void DevToolsManager::RuntimeFeatureStateChanged(RenderViewHost* inspected_rvh,
+ const std::string& feature,
+ bool enabled) {
+ RuntimeFeaturesMap::iterator it = runtime_features_.find(inspected_rvh);
+ if (it == runtime_features_.end()) {
+ std::pair<RenderViewHost*, std::set<std::string> > value(
+ inspected_rvh,
+ std::set<std::string>());
+ it = runtime_features_.insert(value).first;
+ }
+ if (enabled)
+ it->second.insert(feature);
+ else
+ it->second.erase(feature);
+}
+
void DevToolsManager::InspectElement(RenderViewHost* inspected_rvh,
int x,
int y) {
@@ -150,6 +168,7 @@ void DevToolsManager::ClientHostClosing(DevToolsClientHost* host) {
SendDetachToAgent(inspected_rvh);
inspected_rvh_to_client_host_.erase(inspected_rvh);
+ runtime_features_.erase(inspected_rvh);
client_host_to_inspected_rvh_.erase(host);
}
@@ -168,6 +187,8 @@ void DevToolsManager::UnregisterDevToolsClientHostFor(
if (!host)
return;
inspected_rvh_to_client_host_.erase(inspected_rvh);
+ runtime_features_.erase(inspected_rvh);
+
client_host_to_inspected_rvh_.erase(host);
if (inspected_rvh_for_reopen_ == inspected_rvh)
inspected_rvh_for_reopen_ = NULL;
@@ -198,10 +219,12 @@ void DevToolsManager::OnNavigatingToPendingEntry(RenderViewHost* rvh,
GetDevToolsClientHostFor(rvh);
if (client_host) {
// Navigating to URL in the inspected window.
+ std::set<std::string> runtime_features = runtime_features_[rvh];
inspected_rvh_to_client_host_.erase(rvh);
+ runtime_features_.erase(rvh);
inspected_rvh_to_client_host_[dest_rvh] = client_host;
client_host_to_inspected_rvh_[client_host] = dest_rvh;
- SendAttachToAgent(dest_rvh);
+ SendAttachToAgent(dest_rvh, runtime_features);
return;
}
@@ -222,11 +245,15 @@ void DevToolsManager::OnNavigatingToPendingEntry(RenderViewHost* rvh,
}
}
-void DevToolsManager::SendAttachToAgent(RenderViewHost* inspected_rvh) {
+void DevToolsManager::SendAttachToAgent(
+ RenderViewHost* inspected_rvh,
+ const std::set<std::string>& runtime_features) {
if (inspected_rvh) {
ChildProcessSecurityPolicy::GetInstance()->GrantReadRawCookies(
inspected_rvh->process()->id());
- IPC::Message* m = new DevToolsAgentMsg_Attach();
+ std::vector<std::string> features(runtime_features.begin(),
+ runtime_features.end());
+ IPC::Message* m = new DevToolsAgentMsg_Attach(features);
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 d5c6981..56ffb3f8 100644
--- a/chrome/browser/debugger/devtools_manager.h
+++ b/chrome/browser/debugger/devtools_manager.h
@@ -6,6 +6,8 @@
#define CHROME_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_
#include <map>
+#include <set>
+#include <string>
#include "base/ref_counted.h"
#include "chrome/browser/debugger/devtools_client_host.h"
@@ -54,8 +56,10 @@ class DevToolsManager : public DevToolsClientHost::CloseListener,
void ToggleInspectElementMode(RenderViewHost* client_rvh, bool enabled);
void OpenDevToolsWindow(RenderViewHost* inspected_rvh);
-
void ToggleDevToolsWindow(RenderViewHost* inspected_rvh);
+ void RuntimeFeatureStateChanged(RenderViewHost* inspected_rvh,
+ const std::string& feature,
+ bool enabled);
// Starts element inspection in the devtools client.
// Creates one by means of OpenDevToolsWindow if no client
@@ -79,7 +83,8 @@ private:
// client hosted by DevToolsClientHost.
RenderViewHost* GetInspectedRenderViewHost(DevToolsClientHost* client_host);
- void SendAttachToAgent(RenderViewHost* inspected_rvh);
+ void SendAttachToAgent(RenderViewHost* inspected_rvh,
+ const std::set<std::string>& runtime_features);
void SendDetachToAgent(RenderViewHost* inspected_rvh);
void ForceReopenWindow();
@@ -107,6 +112,11 @@ private:
typedef std::map<DevToolsClientHost*, RenderViewHost*>
ClientHostToInspectedRvhMap;
ClientHostToInspectedRvhMap client_host_to_inspected_rvh_;
+
+ typedef std::map<RenderViewHost*, std::set<std::string> >
+ RuntimeFeaturesMap;
+ RuntimeFeaturesMap runtime_features_;
+
RenderViewHost* inspected_rvh_for_reopen_;
bool in_initial_show_;
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index a56546f..dab321d 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -808,6 +808,8 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
OnUndockDevToolsWindow);
IPC_MESSAGE_HANDLER(ViewHostMsg_ToggleInspectElementMode,
OnToggleInspectElementMode);
+ IPC_MESSAGE_HANDLER(ViewHostMsg_DevToolsRuntimeFeatureStateChanged,
+ OnDevToolsRuntimeFeatureStateChanged);
IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction,
OnUserMetricsRecordAction)
IPC_MESSAGE_HANDLER(ViewHostMsg_MissingPluginStatus, OnMissingPluginStatus);
@@ -1438,6 +1440,13 @@ void RenderViewHost::OnToggleInspectElementMode(bool enabled) {
DevToolsManager::GetInstance()->ToggleInspectElementMode(this, enabled);
}
+void RenderViewHost::OnDevToolsRuntimeFeatureStateChanged(
+ const std::string& feature,
+ bool enabled) {
+ DevToolsManager::GetInstance()->
+ RuntimeFeatureStateChanged(this, feature, enabled);
+}
+
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 aa7fd49..6d1dfc8 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -554,6 +554,8 @@ class RenderViewHost : public RenderWidgetHost,
void OnDockDevToolsWindow();
void OnUndockDevToolsWindow();
void OnToggleInspectElementMode(bool enabled);
+ void OnDevToolsRuntimeFeatureStateChanged(const std::string& feature,
+ bool enabled);
void OnUserMetricsRecordAction(const std::wstring& action);
void OnMissingPluginStatus(int status);