summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/debugger/devtools_manager.cc9
-rw-r--r--chrome/browser/debugger/devtools_manager.h1
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc17
-rw-r--r--chrome/browser/renderer_host/render_view_host.h10
-rw-r--r--chrome/common/render_messages_internal.h4
-rw-r--r--chrome/renderer/devtools_client.cc6
-rw-r--r--chrome/renderer/devtools_client.h1
-rw-r--r--webkit/glue/devtools/js/devtools_host_stub.js2
-rw-r--r--webkit/glue/devtools/js/inspector_controller_impl.js29
-rw-r--r--webkit/glue/webdevtoolsclient_delegate.h1
-rw-r--r--webkit/glue/webdevtoolsclient_impl.cc13
-rw-r--r--webkit/glue/webdevtoolsclient_impl.h2
12 files changed, 84 insertions, 11 deletions
diff --git a/chrome/browser/debugger/devtools_manager.cc b/chrome/browser/debugger/devtools_manager.cc
index 8cc56d0..c68f806 100644
--- a/chrome/browser/debugger/devtools_manager.cc
+++ b/chrome/browser/debugger/devtools_manager.cc
@@ -118,6 +118,15 @@ void DevToolsManager::UndockWindow(RenderViewHost* client_rvh) {
ReopenWindow(client_rvh, false);
}
+void DevToolsManager::ToggleInspectElementMode(RenderViewHost* client_rvh,
+ bool enabled) {
+ DevToolsClientHost* client_host = FindOnwerDevToolsClientHost(client_rvh);
+ DCHECK(client_host);
+ RenderViewHost* inspected_rvh = GetInspectedRenderViewHost(client_host);
+ DCHECK(inspected_rvh);
+ inspected_rvh->set_in_inspect_element_mode(enabled);
+}
+
void DevToolsManager::OpenDevToolsWindow(RenderViewHost* inspected_rvh) {
ToggleDevToolsWindow(inspected_rvh, true);
}
diff --git a/chrome/browser/debugger/devtools_manager.h b/chrome/browser/debugger/devtools_manager.h
index 27ab730..d5c6981 100644
--- a/chrome/browser/debugger/devtools_manager.h
+++ b/chrome/browser/debugger/devtools_manager.h
@@ -51,6 +51,7 @@ class DevToolsManager : public DevToolsClientHost::CloseListener,
void CloseWindow(RenderViewHost* client_rvn);
void DockWindow(RenderViewHost* client_rvn);
void UndockWindow(RenderViewHost* client_rvn);
+ void ToggleInspectElementMode(RenderViewHost* client_rvh, bool enabled);
void OpenDevToolsWindow(RenderViewHost* inspected_rvh);
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index ff6b8e3..73a66fa 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -109,7 +109,8 @@ RenderViewHost::RenderViewHost(SiteInstance* instance,
run_modal_reply_msg_(NULL),
is_waiting_for_unload_ack_(false),
are_javascript_messages_suppressed_(false),
- sudden_termination_allowed_(false) {
+ sudden_termination_allowed_(false),
+ in_inspect_element_mode_(false) {
DCHECK(instance_);
DCHECK(delegate_);
if (modal_dialog_event == NULL)
@@ -781,6 +782,8 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
OnDockDevToolsWindow);
IPC_MESSAGE_HANDLER(ViewHostMsg_UndockDevToolsWindow,
OnUndockDevToolsWindow);
+ IPC_MESSAGE_HANDLER(ViewHostMsg_ToggleInspectElementMode,
+ OnToggleInspectElementMode);
IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction,
OnUserMetricsRecordAction)
IPC_MESSAGE_HANDLER(ViewHostMsg_MissingPluginStatus, OnMissingPluginStatus);
@@ -1328,6 +1331,10 @@ void RenderViewHost::OnUndockDevToolsWindow() {
DevToolsManager::GetInstance()->UndockWindow(this);
}
+void RenderViewHost::OnToggleInspectElementMode(bool enabled) {
+ DevToolsManager::GetInstance()->ToggleInspectElementMode(this, enabled);
+}
+
void RenderViewHost::OnUserMetricsRecordAction(const std::wstring& action) {
UserMetrics::RecordComputedAction(action.c_str(), process()->profile());
}
@@ -1481,6 +1488,14 @@ gfx::Rect RenderViewHost::GetRootWindowResizerRect() const {
void RenderViewHost::ForwardMouseEvent(
const WebKit::WebMouseEvent& mouse_event) {
+ if (in_inspect_element_mode_ &&
+ mouse_event.type == WebInputEvent::MouseDown) {
+ in_inspect_element_mode_ = false;
+ DevToolsManager::GetInstance()->InspectElement(this, mouse_event.x,
+ mouse_event.y);
+ return;
+ }
+
// We make a copy of the mouse event because
// RenderWidgetHost::ForwardMouseEvent will delete |mouse_event|.
WebKit::WebMouseEvent event_copy(mouse_event);
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 90a4d53..a55095a 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -418,6 +418,10 @@ class RenderViewHost : public RenderWidgetHost,
void SignalModalDialogEvent();
void ResetModalDialogEvent();
+ void set_in_inspect_element_mode(bool enabled) {
+ in_inspect_element_mode_ = enabled;
+ }
+
protected:
// RenderWidgetHost protected overrides.
virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event);
@@ -522,6 +526,7 @@ class RenderViewHost : public RenderWidgetHost,
void OnCloseDevToolsWindow();
void OnDockDevToolsWindow();
void OnUndockDevToolsWindow();
+ void OnToggleInspectElementMode(bool enabled);
void OnUserMetricsRecordAction(const std::wstring& action);
void OnMissingPluginStatus(int status);
@@ -618,6 +623,11 @@ class RenderViewHost : public RenderWidgetHost,
// True if the render view can be shut down suddenly.
bool sudden_termination_allowed_;
+ // DevTools triggers this mode when user chooses inspect lens tool.
+ // While in this mode, mouse click is converted into InspectElement
+ // command.
+ bool in_inspect_element_mode_;
+
NotificationRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(RenderViewHost);
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 1d99d61..71675fe 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -1138,6 +1138,10 @@ IPC_BEGIN_MESSAGES(ViewHost)
// Detaches dev tools window that is inspecting current render_view_host.
IPC_MESSAGE_ROUTED0(ViewHostMsg_UndockDevToolsWindow)
+ // Detaches dev tools window that is inspecting current render_view_host.
+ IPC_MESSAGE_ROUTED1(ViewHostMsg_ToggleInspectElementMode,
+ 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_client.cc b/chrome/renderer/devtools_client.cc
index 6d88ccd..d726656 100644
--- a/chrome/renderer/devtools_client.cc
+++ b/chrome/renderer/devtools_client.cc
@@ -67,6 +67,12 @@ void DevToolsClient::UndockWindow() {
render_view_->routing_id()));
}
+void DevToolsClient::ToggleInspectElementMode(bool enabled) {
+ render_view_->Send(new ViewHostMsg_ToggleInspectElementMode(
+ render_view_->routing_id(), enabled));
+}
+
+
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 295cb30..200e068 100644
--- a/chrome/renderer/devtools_client.h
+++ b/chrome/renderer/devtools_client.h
@@ -42,6 +42,7 @@ class DevToolsClient : public WebDevToolsClientDelegate {
virtual void CloseWindow();
virtual void DockWindow();
virtual void UndockWindow();
+ virtual void ToggleInspectElementMode(bool enabled);
private:
void OnRpcMessage(const std::string& class_name,
diff --git a/webkit/glue/devtools/js/devtools_host_stub.js b/webkit/glue/devtools/js/devtools_host_stub.js
index 4d875d3..026153a 100644
--- a/webkit/glue/devtools/js/devtools_host_stub.js
+++ b/webkit/glue/devtools/js/devtools_host_stub.js
@@ -226,6 +226,8 @@ RemoteToolsAgentStub.prototype.ExecuteUtilityFunction = function(callId,
} catch (e) {
result = [ e.toString(), true ];
}
+ } else if (functionName == 'InspectorController') {
+ // do nothing;
} else {
alert('Unexpected utility function:' + functionName);
}
diff --git a/webkit/glue/devtools/js/inspector_controller_impl.js b/webkit/glue/devtools/js/inspector_controller_impl.js
index dc24478..cbfcd57 100644
--- a/webkit/glue/devtools/js/inspector_controller_impl.js
+++ b/webkit/glue/devtools/js/inspector_controller_impl.js
@@ -20,7 +20,7 @@ goog.inherits(devtools.InspectorControllerImpl,
/**
* {@inheritDoc}.
*/
-devtools.InspectorController.prototype.platform = function() {
+devtools.InspectorControllerImpl.prototype.platform = function() {
return DevToolsHost.getPlatform();
};
@@ -28,7 +28,7 @@ devtools.InspectorController.prototype.platform = function() {
/**
* {@inheritDoc}.
*/
-devtools.InspectorController.prototype.closeWindow = function() {
+devtools.InspectorControllerImpl.prototype.closeWindow = function() {
DevToolsHost.closeWindow();
};
@@ -36,7 +36,7 @@ devtools.InspectorController.prototype.closeWindow = function() {
/**
* {@inheritDoc}.
*/
-devtools.InspectorController.prototype.attach = function() {
+devtools.InspectorControllerImpl.prototype.attach = function() {
DevToolsHost.dockWindow();
};
@@ -44,7 +44,7 @@ devtools.InspectorController.prototype.attach = function() {
/**
* {@inheritDoc}.
*/
-devtools.InspectorController.prototype.detach = function() {
+devtools.InspectorControllerImpl.prototype.detach = function() {
DevToolsHost.undockWindow();
};
@@ -52,7 +52,7 @@ devtools.InspectorController.prototype.detach = function() {
/**
* {@inheritDoc}.
*/
-devtools.InspectorController.prototype.storeLastActivePanel = function(panel) {
+devtools.InspectorControllerImpl.prototype.storeLastActivePanel = function(panel) {
RemoteToolsAgent.ExecuteUtilityFunction(
devtools.Callback.wrap(undefined),
'InspectorController', JSON.stringify(['storeLastActivePanel', panel]));
@@ -62,7 +62,7 @@ devtools.InspectorController.prototype.storeLastActivePanel = function(panel) {
/**
* {@inheritDoc}.
*/
-devtools.InspectorController.prototype.clearMessages = function() {
+devtools.InspectorControllerImpl.prototype.clearMessages = function() {
RemoteToolsAgent.ClearConsoleMessages();
};
@@ -78,7 +78,7 @@ devtools.InspectorControllerImpl.prototype.hiddenPanels = function() {
/**
* {@inheritDoc}.
*/
-devtools.InspectorController.prototype.search = function(sourceRow, query) {
+devtools.InspectorControllerImpl.prototype.search = function(sourceRow, query) {
return DevToolsHost.search(sourceRow, query);
};
@@ -86,6 +86,15 @@ devtools.InspectorController.prototype.search = function(sourceRow, query) {
/**
* {@inheritDoc}.
*/
+devtools.InspectorControllerImpl.prototype.toggleNodeSearch = function() {
+ devtools.InspectorController.prototype.toggleNodeSearch.call(this);
+ DevToolsHost.toggleInspectElementMode(this.searchingForNode());
+};
+
+
+/**
+ * {@inheritDoc}.
+ */
devtools.InspectorControllerImpl.prototype.addSourceToFrame =
function(mimeType, source, element) {
return DevToolsHost.addSourceToFrame(mimeType, source, element);
@@ -133,7 +142,7 @@ devtools.InspectorControllerImpl.prototype.inspectedWindow = function() {
/**
* {@inheritDoc}.
*/
-devtools.InspectorController.prototype.enableResourceTracking =
+devtools.InspectorControllerImpl.prototype.enableResourceTracking =
function(always) {
devtools.tools.setResourceTrackingEnabled(true, always);
}
@@ -142,7 +151,7 @@ devtools.InspectorController.prototype.enableResourceTracking =
/**
* {@inheritDoc}.
*/
-devtools.InspectorController.prototype.disableResourceTracking =
+devtools.InspectorControllerImpl.prototype.disableResourceTracking =
function(always) {
devtools.tools.setResourceTrackingEnabled(false, always);
};
@@ -173,7 +182,7 @@ devtools.InspectorControllerImpl.prototype.removeBreakpoint = function(
};
-devtools.InspectorController.prototype.pauseInDebugger = function() {
+devtools.InspectorControllerImpl.prototype.pauseInDebugger = function() {
devtools.tools.getDebuggerAgent().pauseExecution();
};
diff --git a/webkit/glue/webdevtoolsclient_delegate.h b/webkit/glue/webdevtoolsclient_delegate.h
index 09d088b..b7ef635 100644
--- a/webkit/glue/webdevtoolsclient_delegate.h
+++ b/webkit/glue/webdevtoolsclient_delegate.h
@@ -22,6 +22,7 @@ class WebDevToolsClientDelegate {
virtual void CloseWindow() = 0;
virtual void DockWindow() = 0;
virtual void UndockWindow() = 0;
+ virtual void ToggleInspectElementMode(bool enabled) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(WebDevToolsClientDelegate);
diff --git a/webkit/glue/webdevtoolsclient_impl.cc b/webkit/glue/webdevtoolsclient_impl.cc
index 5bb2883..eaf923f 100644
--- a/webkit/glue/webdevtoolsclient_impl.cc
+++ b/webkit/glue/webdevtoolsclient_impl.cc
@@ -181,6 +181,9 @@ WebDevToolsClientImpl::WebDevToolsClientImpl(
dev_tools_host_->AddProtoFunction(
"undockWindow",
WebDevToolsClientImpl::JsUndockWindow);
+ dev_tools_host_->AddProtoFunction(
+ "toggleInspectElementMode",
+ WebDevToolsClientImpl::JsToggleInspectElementMode);
dev_tools_host_->Build();
}
@@ -357,3 +360,13 @@ v8::Handle<v8::Value> WebDevToolsClientImpl::JsUndockWindow(
client->delegate_->UndockWindow();
return v8::Undefined();
}
+
+// static
+v8::Handle<v8::Value> WebDevToolsClientImpl::JsToggleInspectElementMode(
+ const v8::Arguments& args) {
+ WebDevToolsClientImpl* client = static_cast<WebDevToolsClientImpl*>(
+ v8::External::Cast(*args.Data())->Value());
+ int enabled = static_cast<int>(args[0]->BooleanValue());
+ client->delegate_->ToggleInspectElementMode(enabled);
+ return v8::Undefined();
+}
diff --git a/webkit/glue/webdevtoolsclient_impl.h b/webkit/glue/webdevtoolsclient_impl.h
index 8180458..ce07dd4 100644
--- a/webkit/glue/webdevtoolsclient_impl.h
+++ b/webkit/glue/webdevtoolsclient_impl.h
@@ -67,6 +67,8 @@ class WebDevToolsClientImpl : public WebDevToolsClient,
static v8::Handle<v8::Value> JsCloseWindow(const v8::Arguments& args);
static v8::Handle<v8::Value> JsDockWindow(const v8::Arguments& args);
static v8::Handle<v8::Value> JsUndockWindow(const v8::Arguments& args);
+ static v8::Handle<v8::Value> JsToggleInspectElementMode(
+ const v8::Arguments& args);
WebViewImpl* web_view_impl_;
WebDevToolsClientDelegate* delegate_;