diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/debugger/devtools_manager.cc | 9 | ||||
-rw-r--r-- | chrome/browser/debugger/devtools_manager.h | 1 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.cc | 17 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.h | 10 |
4 files changed, 36 insertions, 1 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); |