summaryrefslogtreecommitdiffstats
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
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
-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
-rw-r--r--chrome/common/devtools_messages_internal.h3
-rw-r--r--chrome/common/render_messages_internal.h6
-rw-r--r--chrome/renderer/devtools_agent.cc29
-rw-r--r--chrome/renderer/devtools_agent.h9
-rw-r--r--webkit/api/public/WebDevToolsAgent.h4
-rw-r--r--webkit/api/public/WebDevToolsAgentClient.h3
-rw-r--r--webkit/glue/devtools/js/inject_dispatch.js12
-rw-r--r--webkit/glue/webdevtoolsagent_impl.cc87
-rw-r--r--webkit/glue/webdevtoolsagent_impl.h8
13 files changed, 183 insertions, 38 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);
diff --git a/chrome/common/devtools_messages_internal.h b/chrome/common/devtools_messages_internal.h
index d91166f..be187a7 100644
--- a/chrome/common/devtools_messages_internal.h
+++ b/chrome/common/devtools_messages_internal.h
@@ -65,7 +65,8 @@ IPC_END_MESSAGES(DevToolsClient)
IPC_BEGIN_MESSAGES(DevToolsAgent)
// Tells agent that there is a client host connected to it.
- IPC_MESSAGE_CONTROL0(DevToolsAgentMsg_Attach)
+ IPC_MESSAGE_CONTROL1(DevToolsAgentMsg_Attach,
+ std::vector<std::string> /* runtime_features */)
// Tells agent that there is no longer a client host connected to it.
IPC_MESSAGE_CONTROL0(DevToolsAgentMsg_Detach)
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 81f9c1f..4b45f8f 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -1407,6 +1407,12 @@ IPC_BEGIN_MESSAGES(ViewHost)
IPC_MESSAGE_ROUTED1(ViewHostMsg_ToggleInspectElementMode,
bool /* enabled */)
+ // Updates runtime features store in devtools manager in order to support
+ // cross-navigation instrumentation.
+ IPC_MESSAGE_ROUTED2(ViewHostMsg_DevToolsRuntimeFeatureStateChanged,
+ std::string /* feature */,
+ bool /* enabled */)
+
// Send back a string to be recorded by UserMetrics.
IPC_MESSAGE_ROUTED1(ViewHostMsg_UserMetricsRecordAction,
std::wstring /* action */)
diff --git a/chrome/renderer/devtools_agent.cc b/chrome/renderer/devtools_agent.cc
index ca70cc1..87dc832 100644
--- a/chrome/renderer/devtools_agent.cc
+++ b/chrome/renderer/devtools_agent.cc
@@ -10,6 +10,7 @@
#include "webkit/api/public/WebDevToolsAgent.h"
#include "webkit/api/public/WebPoint.h"
#include "webkit/api/public/WebString.h"
+#include "webkit/glue/glue_util.h"
using WebKit::WebDevToolsAgent;
using WebKit::WebPoint;
@@ -19,9 +20,9 @@ using WebKit::WebView;
// static
std::map<int, DevToolsAgent*> DevToolsAgent::agent_for_routing_id_;
-DevToolsAgent::DevToolsAgent(int routing_id, RenderView* view)
+DevToolsAgent::DevToolsAgent(int routing_id, RenderView* render_view)
: routing_id_(routing_id),
- view_(view) {
+ render_view_(render_view) {
agent_for_routing_id_[routing_id] = this;
}
@@ -64,7 +65,7 @@ void DevToolsAgent::sendMessageToFrontend(const WebString& class_name,
param1.utf8(),
param2.utf8(),
param3.utf8()));
- view_->Send(m);
+ render_view_->Send(m);
}
int DevToolsAgent::hostIdentifier() {
@@ -72,7 +73,15 @@ int DevToolsAgent::hostIdentifier() {
}
void DevToolsAgent::forceRepaint() {
- view_->GenerateFullRepaint();
+ render_view_->GenerateFullRepaint();
+}
+
+void DevToolsAgent::runtimeFeatureStateChanged(const WebKit::WebString& feature,
+ bool enabled) {
+ render_view_->Send(new ViewHostMsg_DevToolsRuntimeFeatureStateChanged(
+ routing_id_,
+ feature.utf8(),
+ enabled));
}
// static
@@ -85,10 +94,14 @@ DevToolsAgent* DevToolsAgent::FromHostId(int host_id) {
return NULL;
}
-void DevToolsAgent::OnAttach() {
+void DevToolsAgent::OnAttach(const std::vector<std::string>& runtime_features) {
WebDevToolsAgent* web_agent = GetWebAgent();
if (web_agent) {
web_agent->attach();
+ for (std::vector<std::string>::const_iterator it = runtime_features.begin();
+ it != runtime_features.end(); ++it) {
+ web_agent->setRuntimeFeatureEnabled(WebString::fromUTF8(*it), true);
+ }
}
}
@@ -126,12 +139,14 @@ void DevToolsAgent::OnInspectElement(int x, int y) {
void DevToolsAgent::OnSetApuAgentEnabled(bool enabled) {
WebDevToolsAgent* web_agent = GetWebAgent();
if (web_agent) {
- web_agent->setApuAgentEnabled(enabled);
+ web_agent->setRuntimeFeatureEnabled(
+ webkit_glue::StdStringToWebString("apu-agent"),
+ enabled);
}
}
WebDevToolsAgent* DevToolsAgent::GetWebAgent() {
- WebView* web_view = view_->webview();
+ WebView* web_view = render_view_->webview();
if (!web_view)
return NULL;
return web_view->devToolsAgent();
diff --git a/chrome/renderer/devtools_agent.h b/chrome/renderer/devtools_agent.h
index 2110841..9f52e9e 100644
--- a/chrome/renderer/devtools_agent.h
+++ b/chrome/renderer/devtools_agent.h
@@ -7,6 +7,7 @@
#include <map>
#include <string>
+#include <vector>
#include "base/basictypes.h"
#include "webkit/api/public/WebDevToolsAgentClient.h"
@@ -43,18 +44,20 @@ class DevToolsAgent : public WebKit::WebDevToolsAgentClient {
const WebKit::WebString& param3);
virtual int hostIdentifier();
virtual void forceRepaint();
+ virtual void runtimeFeatureStateChanged(const WebKit::WebString& feature,
+ bool enabled);
// Returns agent instance for its host id.
static DevToolsAgent* FromHostId(int host_id);
- RenderView* render_view() { return view_; }
+ RenderView* render_view() { return render_view_; }
WebKit::WebDevToolsAgent* GetWebAgent();
private:
friend class DevToolsAgentFilter;
- void OnAttach();
+ void OnAttach(const std::vector<std::string>& runtime_features);
void OnDetach();
void OnRpcMessage(const std::string& class_name,
const std::string& method_name,
@@ -67,7 +70,7 @@ class DevToolsAgent : public WebKit::WebDevToolsAgentClient {
static std::map<int, DevToolsAgent*> agent_for_routing_id_;
int routing_id_; // View routing id that we can access from IO thread.
- RenderView* view_;
+ RenderView* render_view_;
DISALLOW_COPY_AND_ASSIGN(DevToolsAgent);
};
diff --git a/webkit/api/public/WebDevToolsAgent.h b/webkit/api/public/WebDevToolsAgent.h
index 4ae1077..4005b30 100644
--- a/webkit/api/public/WebDevToolsAgent.h
+++ b/webkit/api/public/WebDevToolsAgent.h
@@ -52,10 +52,10 @@ public:
virtual void inspectElementAt(const WebPoint&) = 0;
- virtual void setApuAgentEnabled(bool enabled) = 0;
+ virtual void setRuntimeFeatureEnabled(const WebString& feature, bool enabled) = 0;
// Asynchronously executes debugger command in the render thread.
- // |caller_id| will be used for sending response.
+ // |callerIdentifier| will be used for sending response.
WEBKIT_API static void executeDebuggerCommand(
const WebString& command, int callerIdentifier);
diff --git a/webkit/api/public/WebDevToolsAgentClient.h b/webkit/api/public/WebDevToolsAgentClient.h
index 4cb01d6..d3c48c7 100644
--- a/webkit/api/public/WebDevToolsAgentClient.h
+++ b/webkit/api/public/WebDevToolsAgentClient.h
@@ -50,6 +50,9 @@ public:
// Returns the identifier of the entity hosting this agent.
virtual int hostIdentifier() = 0;
+ // Notifies host upon runtime feature being enabled/disabled.
+ virtual void runtimeFeatureStateChanged(const WebString& feature, bool enabled) = 0;
+
protected:
~WebDevToolsAgentClient() {}
};
diff --git a/webkit/glue/devtools/js/inject_dispatch.js b/webkit/glue/devtools/js/inject_dispatch.js
index a6127580..fa7fb10 100644
--- a/webkit/glue/devtools/js/inject_dispatch.js
+++ b/webkit/glue/devtools/js/inject_dispatch.js
@@ -61,6 +61,18 @@ function dispatch(method, var_args) {
return;
}
+ // Sniff some inspector controller state changes in order to support
+ // cross-navigation instrumentation. Keep names in sync with
+ // webdevtoolsagent_impl.
+ if (method == 'timelineProfilerWasStarted')
+ DevToolsAgentHost.runtimeFeatureStateChanged('timeline-profiler', true);
+ else if (method == 'timelineProfilerWasStopped')
+ DevToolsAgentHost.runtimeFeatureStateChanged('timeline-profiler', false);
+ else if (method == 'resourceTrackingWasEnabled')
+ DevToolsAgentHost.runtimeFeatureStateChanged('resource-tracking', true);
+ else if (method == 'resourceTrackingWasDisabled')
+ DevToolsAgentHost.runtimeFeatureStateChanged('resource-tracking', false);
+
if (ApuAgentDispatcher.enabled) {
ApuAgentDispatcher.dispatchToApu(method, args);
return;
diff --git a/webkit/glue/webdevtoolsagent_impl.cc b/webkit/glue/webdevtoolsagent_impl.cc
index ea84c14..3e0b768 100644
--- a/webkit/glue/webdevtoolsagent_impl.cc
+++ b/webkit/glue/webdevtoolsagent_impl.cc
@@ -27,6 +27,7 @@
#include "webkit/api/public/WebDataSource.h"
#include "webkit/api/public/WebDevToolsAgentClient.h"
#include "webkit/api/public/WebFrame.h"
+#include "webkit/api/public/WebString.h"
#include "webkit/api/public/WebURL.h"
#include "webkit/api/public/WebURLRequest.h"
#include "webkit/api/src/WebViewImpl.h"
@@ -82,6 +83,13 @@ void SetApuAgentEnabledInUtilityContext(v8::Handle<v8::Context> context,
dispatcher->Set(v8::String::New("enabled"), v8::Boolean::New(enabled));
}
+// TODO(pfeldman): Make this public in WebDevToolsAgent API.
+static const char kApuAgentFeatureName[] = "apu-agent";
+
+// Keep these in sync with the ones in inject_dispatch.js.
+static const char kTimelineFeatureName[] = "timeline-profiler";
+static const char kResourceTrackingFeatureName[] = "resource-tracking";
+
} // namespace
WebDevToolsAgentImpl::WebDevToolsAgentImpl(
@@ -271,24 +279,23 @@ void WebDevToolsAgentImpl::inspectElementAt(const WebPoint& point) {
web_view_impl_->inspectElementAt(point);
}
-void WebDevToolsAgentImpl::setApuAgentEnabled(bool enable) {
- apu_agent_enabled_ = enable;
- SetApuAgentEnabledInUtilityContext(utility_context_, enable);
- InspectorController* ic = web_view_impl_->page()->inspectorController();
- if (enable) {
- resource_tracking_was_enabled_ = ic->resourceTrackingEnabled();
- ic->startTimelineProfiler();
- if (!resource_tracking_was_enabled_) {
- // TODO(knorton): Introduce some kind of agents dependency here so that
- // user could turn off resource tracking while apu agent is on.
- ic->enableResourceTracking(false, false);
- }
- } else {
- ic->stopTimelineProfiler();
- if (!resource_tracking_was_enabled_) {
- ic->disableResourceTracking(false);
- }
- resource_tracking_was_enabled_ = false;
+void WebDevToolsAgentImpl::setRuntimeFeatureEnabled(const WebString& wfeature,
+ bool enabled) {
+ String feature = webkit_glue::WebStringToString(wfeature);
+ if (feature == kApuAgentFeatureName) {
+ setApuAgentEnabled(enabled);
+ } else if (feature == kTimelineFeatureName) {
+ InspectorController* ic = web_view_impl_->page()->inspectorController();
+ if (enabled)
+ ic->startTimelineProfiler();
+ else
+ ic->stopTimelineProfiler();
+ } else if (feature == kResourceTrackingFeatureName) {
+ InspectorController* ic = web_view_impl_->page()->inspectorController();
+ if (enabled)
+ ic->enableResourceTracking(false /* not sticky */, false /* no reload */);
+ else
+ ic->disableResourceTracking(false /* not sticky */);
}
}
@@ -315,6 +322,9 @@ void WebDevToolsAgentImpl::InitDevToolsAgentHost() {
devtools_agent_host_->AddProtoFunction(
"dispatchToApu",
WebDevToolsAgentImpl::JsDispatchToApu);
+ devtools_agent_host_->AddProtoFunction(
+ "runtimeFeatureStateChanged",
+ WebDevToolsAgentImpl::JsOnRuntimeFeatureStateChanged);
devtools_agent_host_->Build();
v8::HandleScope scope;
@@ -379,6 +389,30 @@ void WebDevToolsAgentImpl::ResetInspectorFrontendProxy() {
ScriptObject(state, injected_script));
}
+void WebDevToolsAgentImpl::setApuAgentEnabled(bool enabled) {
+ apu_agent_enabled_ = enabled;
+ SetApuAgentEnabledInUtilityContext(utility_context_, enabled);
+ InspectorController* ic = web_view_impl_->page()->inspectorController();
+ if (enabled) {
+ resource_tracking_was_enabled_ = ic->resourceTrackingEnabled();
+ ic->startTimelineProfiler();
+ if (!resource_tracking_was_enabled_) {
+ // TODO(knorton): Introduce some kind of agents dependency here so that
+ // user could turn off resource tracking while apu agent is on.
+ ic->enableResourceTracking(false, false);
+ }
+ } else {
+ ic->stopTimelineProfiler();
+ if (!resource_tracking_was_enabled_) {
+ ic->disableResourceTracking(false);
+ }
+ resource_tracking_was_enabled_ = false;
+ }
+ client_->runtimeFeatureStateChanged(
+ webkit_glue::StringToWebString(kApuAgentFeatureName),
+ enabled);
+}
+
// static
v8::Handle<v8::Value> WebDevToolsAgentImpl::JsDispatchOnClient(
const v8::Arguments& args) {
@@ -407,6 +441,23 @@ v8::Handle<v8::Value> WebDevToolsAgentImpl::JsDispatchToApu(
return v8::Undefined();
}
+// static
+v8::Handle<v8::Value> WebDevToolsAgentImpl::JsOnRuntimeFeatureStateChanged(
+ const v8::Arguments& args) {
+ v8::TryCatch exception_catcher;
+ String feature = WebCore::toWebCoreStringWithNullCheck(args[0]);
+ bool enabled = args[1]->ToBoolean()->Value();
+ if (feature.isEmpty() || exception_catcher.HasCaught()) {
+ return v8::Undefined();
+ }
+ WebDevToolsAgentImpl* agent = static_cast<WebDevToolsAgentImpl*>(
+ v8::External::Cast(*args.Data())->Value());
+ agent->client_->runtimeFeatureStateChanged(
+ webkit_glue::StringToWebString(feature),
+ enabled);
+ return v8::Undefined();
+}
+
namespace WebKit {
// static
diff --git a/webkit/glue/webdevtoolsagent_impl.h b/webkit/glue/webdevtoolsagent_impl.h
index 7db9762..3771378 100644
--- a/webkit/glue/webdevtoolsagent_impl.h
+++ b/webkit/glue/webdevtoolsagent_impl.h
@@ -26,6 +26,7 @@ namespace WebKit {
class WebDevToolsAgentClient;
class WebFrame;
class WebFrameImpl;
+class WebString;
class WebViewImpl;
}
@@ -67,7 +68,8 @@ class WebDevToolsAgentImpl : public WebKit::WebDevToolsAgent,
const WebKit::WebString& param2,
const WebKit::WebString& param3);
virtual void inspectElementAt(const WebKit::WebPoint& point);
- virtual void setApuAgentEnabled(bool enable);
+ virtual void setRuntimeFeatureEnabled(const WebKit::WebString& feature,
+ bool enabled);
// DevToolsRpc::Delegate implementation.
void SendRpcMessage(const WebCore::String& class_name,
@@ -91,11 +93,15 @@ class WebDevToolsAgentImpl : public WebKit::WebDevToolsAgent,
private:
static v8::Handle<v8::Value> JsDispatchOnClient(const v8::Arguments& args);
static v8::Handle<v8::Value> JsDispatchToApu(const v8::Arguments& args);
+ static v8::Handle<v8::Value> JsOnRuntimeFeatureStateChanged(
+ const v8::Arguments& args);
+
void DisposeUtilityContext();
void UnhideResourcesPanelIfNecessary();
void InitDevToolsAgentHost();
void ResetInspectorFrontendProxy();
+ void setApuAgentEnabled(bool enabled);
// Creates InspectorBackend v8 wrapper in the utility context so that it's
// methods prototype is Function.protoype object from the utility context.