OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010-2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2010-2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include <memory> | 34 #include <memory> |
35 | 35 |
36 #include "bindings/core/v8/ScriptController.h" | 36 #include "bindings/core/v8/ScriptController.h" |
37 #include "bindings/core/v8/V8BindingForCore.h" | 37 #include "bindings/core/v8/V8BindingForCore.h" |
38 #include "core/CoreProbeSink.h" | 38 #include "core/CoreProbeSink.h" |
39 #include "core/events/WebInputEventConversion.h" | 39 #include "core/events/WebInputEventConversion.h" |
40 #include "core/exported/WebViewBase.h" | 40 #include "core/exported/WebViewBase.h" |
41 #include "core/frame/LocalFrame.h" | 41 #include "core/frame/LocalFrame.h" |
42 #include "core/frame/LocalFrameView.h" | 42 #include "core/frame/LocalFrameView.h" |
43 #include "core/frame/Settings.h" | 43 #include "core/frame/Settings.h" |
| 44 #include "core/frame/WebLocalFrameBase.h" |
44 #include "core/inspector/InspectedFrames.h" | 45 #include "core/inspector/InspectedFrames.h" |
45 #include "core/inspector/InspectorAnimationAgent.h" | 46 #include "core/inspector/InspectorAnimationAgent.h" |
46 #include "core/inspector/InspectorApplicationCacheAgent.h" | 47 #include "core/inspector/InspectorApplicationCacheAgent.h" |
47 #include "core/inspector/InspectorCSSAgent.h" | 48 #include "core/inspector/InspectorCSSAgent.h" |
48 #include "core/inspector/InspectorDOMAgent.h" | 49 #include "core/inspector/InspectorDOMAgent.h" |
49 #include "core/inspector/InspectorDOMDebuggerAgent.h" | 50 #include "core/inspector/InspectorDOMDebuggerAgent.h" |
50 #include "core/inspector/InspectorInputAgent.h" | 51 #include "core/inspector/InspectorInputAgent.h" |
51 #include "core/inspector/InspectorLayerTreeAgent.h" | 52 #include "core/inspector/InspectorLayerTreeAgent.h" |
52 #include "core/inspector/InspectorLogAgent.h" | 53 #include "core/inspector/InspectorLogAgent.h" |
53 #include "core/inspector/InspectorMemoryAgent.h" | 54 #include "core/inspector/InspectorMemoryAgent.h" |
(...skipping 27 matching lines...) Expand all Loading... |
81 #include "public/platform/Platform.h" | 82 #include "public/platform/Platform.h" |
82 #include "public/platform/WebLayerTreeView.h" | 83 #include "public/platform/WebLayerTreeView.h" |
83 #include "public/platform/WebRect.h" | 84 #include "public/platform/WebRect.h" |
84 #include "public/platform/WebString.h" | 85 #include "public/platform/WebString.h" |
85 #include "public/web/WebDevToolsAgentClient.h" | 86 #include "public/web/WebDevToolsAgentClient.h" |
86 #include "public/web/WebSettings.h" | 87 #include "public/web/WebSettings.h" |
87 #include "web/DevToolsEmulator.h" | 88 #include "web/DevToolsEmulator.h" |
88 #include "web/InspectorEmulationAgent.h" | 89 #include "web/InspectorEmulationAgent.h" |
89 #include "web/InspectorOverlayAgent.h" | 90 #include "web/InspectorOverlayAgent.h" |
90 #include "web/WebFrameWidgetImpl.h" | 91 #include "web/WebFrameWidgetImpl.h" |
91 #include "web/WebLocalFrameImpl.h" | |
92 #include "web/WebSettingsImpl.h" | 92 #include "web/WebSettingsImpl.h" |
93 | 93 |
94 namespace blink { | 94 namespace blink { |
95 | 95 |
96 namespace { | 96 namespace { |
97 | 97 |
98 bool IsMainFrame(WebLocalFrameImpl* frame) { | 98 bool IsMainFrame(WebLocalFrameBase* frame) { |
99 // TODO(dgozman): sometimes view->mainFrameImpl() does return null, even | 99 // TODO(dgozman): sometimes view->mainFrameImpl() does return null, even |
100 // though |frame| is meant to be main frame. See http://crbug.com/526162. | 100 // though |frame| is meant to be main frame. See http://crbug.com/526162. |
101 return frame->ViewImpl() && !frame->Parent(); | 101 return frame->ViewImpl() && !frame->Parent(); |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 class ClientMessageLoopAdapter : public MainThreadDebugger::ClientMessageLoop { | 105 class ClientMessageLoopAdapter : public MainThreadDebugger::ClientMessageLoop { |
106 public: | 106 public: |
107 ~ClientMessageLoopAdapter() override { instance_ = nullptr; } | 107 ~ClientMessageLoopAdapter() override { instance_ = nullptr; } |
108 | 108 |
109 static void EnsureMainThreadDebuggerCreated(WebDevToolsAgentClient* client) { | 109 static void EnsureMainThreadDebuggerCreated(WebDevToolsAgentClient* client) { |
110 if (instance_) | 110 if (instance_) |
111 return; | 111 return; |
112 std::unique_ptr<ClientMessageLoopAdapter> instance = | 112 std::unique_ptr<ClientMessageLoopAdapter> instance = |
113 WTF::WrapUnique(new ClientMessageLoopAdapter( | 113 WTF::WrapUnique(new ClientMessageLoopAdapter( |
114 WTF::WrapUnique(client->CreateClientMessageLoop()))); | 114 WTF::WrapUnique(client->CreateClientMessageLoop()))); |
115 instance_ = instance.get(); | 115 instance_ = instance.get(); |
116 MainThreadDebugger::Instance()->SetClientMessageLoop(std::move(instance)); | 116 MainThreadDebugger::Instance()->SetClientMessageLoop(std::move(instance)); |
117 } | 117 } |
118 | 118 |
119 static void ContinueProgram() { | 119 static void ContinueProgram() { |
120 // Release render thread if necessary. | 120 // Release render thread if necessary. |
121 if (instance_) | 121 if (instance_) |
122 instance_->QuitNow(); | 122 instance_->QuitNow(); |
123 } | 123 } |
124 | 124 |
125 static void PauseForCreateWindow(WebLocalFrameImpl* frame) { | 125 static void PauseForCreateWindow(WebLocalFrameBase* frame) { |
126 if (instance_) | 126 if (instance_) |
127 instance_->RunForCreateWindow(frame); | 127 instance_->RunForCreateWindow(frame); |
128 } | 128 } |
129 | 129 |
130 static bool ResumeForCreateWindow() { | 130 static bool ResumeForCreateWindow() { |
131 return instance_ ? instance_->QuitForCreateWindow() : false; | 131 return instance_ ? instance_->QuitForCreateWindow() : false; |
132 } | 132 } |
133 | 133 |
134 private: | 134 private: |
135 ClientMessageLoopAdapter( | 135 ClientMessageLoopAdapter( |
136 std::unique_ptr<WebDevToolsAgentClient::WebKitClientMessageLoop> | 136 std::unique_ptr<WebDevToolsAgentClient::WebKitClientMessageLoop> |
137 message_loop) | 137 message_loop) |
138 : running_for_debug_break_(false), | 138 : running_for_debug_break_(false), |
139 running_for_create_window_(false), | 139 running_for_create_window_(false), |
140 message_loop_(std::move(message_loop)) { | 140 message_loop_(std::move(message_loop)) { |
141 DCHECK(message_loop_.get()); | 141 DCHECK(message_loop_.get()); |
142 } | 142 } |
143 | 143 |
144 void Run(LocalFrame* frame) override { | 144 void Run(LocalFrame* frame) override { |
145 if (running_for_debug_break_) | 145 if (running_for_debug_break_) |
146 return; | 146 return; |
147 | 147 |
148 running_for_debug_break_ = true; | 148 running_for_debug_break_ = true; |
149 if (!running_for_create_window_) | 149 if (!running_for_create_window_) |
150 RunLoop(WebLocalFrameImpl::FromFrame(frame)); | 150 RunLoop(WebLocalFrameBase::FromFrame(frame)); |
151 } | 151 } |
152 | 152 |
153 void RunForCreateWindow(WebLocalFrameImpl* frame) { | 153 void RunForCreateWindow(WebLocalFrameBase* frame) { |
154 if (running_for_create_window_) | 154 if (running_for_create_window_) |
155 return; | 155 return; |
156 | 156 |
157 running_for_create_window_ = true; | 157 running_for_create_window_ = true; |
158 if (!running_for_debug_break_) | 158 if (!running_for_debug_break_) |
159 RunLoop(frame); | 159 RunLoop(frame); |
160 } | 160 } |
161 | 161 |
162 void RunLoop(WebLocalFrameImpl* frame) { | 162 void RunLoop(WebLocalFrameBase* frame) { |
163 // 0. Flush pending frontend messages. | 163 // 0. Flush pending frontend messages. |
164 WebDevToolsAgentImpl* agent = frame->DevToolsAgentImpl(); | 164 WebDevToolsAgentImpl* agent = frame->DevToolsAgentImpl(); |
165 agent->FlushProtocolNotifications(); | 165 agent->FlushProtocolNotifications(); |
166 | 166 |
167 // 1. Disable input events. | 167 // 1. Disable input events. |
168 WebFrameWidgetBase::SetIgnoreInputEvents(true); | 168 WebFrameWidgetBase::SetIgnoreInputEvents(true); |
169 for (const auto view : WebViewBase::AllInstances()) | 169 for (const auto view : WebViewBase::AllInstances()) |
170 view->ChromeClient().NotifyPopupOpeningObservers(); | 170 view->ChromeClient().NotifyPopupOpeningObservers(); |
171 | 171 |
172 // 2. Notify embedder about pausing. | 172 // 2. Notify embedder about pausing. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 } | 206 } |
207 return false; | 207 return false; |
208 } | 208 } |
209 | 209 |
210 void RunIfWaitingForDebugger(LocalFrame* frame) override { | 210 void RunIfWaitingForDebugger(LocalFrame* frame) override { |
211 // If we've paused for createWindow, handle it ourselves. | 211 // If we've paused for createWindow, handle it ourselves. |
212 if (QuitForCreateWindow()) | 212 if (QuitForCreateWindow()) |
213 return; | 213 return; |
214 // Otherwise, pass to the client (embedded workers do it differently). | 214 // Otherwise, pass to the client (embedded workers do it differently). |
215 WebDevToolsAgentImpl* agent = | 215 WebDevToolsAgentImpl* agent = |
216 WebLocalFrameImpl::FromFrame(frame)->DevToolsAgentImpl(); | 216 WebLocalFrameBase::FromFrame(frame)->DevToolsAgentImpl(); |
217 if (agent && agent->Client()) | 217 if (agent && agent->Client()) |
218 agent->Client()->ResumeStartup(); | 218 agent->Client()->ResumeStartup(); |
219 } | 219 } |
220 | 220 |
221 bool running_for_debug_break_; | 221 bool running_for_debug_break_; |
222 bool running_for_create_window_; | 222 bool running_for_create_window_; |
223 std::unique_ptr<WebDevToolsAgentClient::WebKitClientMessageLoop> | 223 std::unique_ptr<WebDevToolsAgentClient::WebKitClientMessageLoop> |
224 message_loop_; | 224 message_loop_; |
225 | 225 |
226 static ClientMessageLoopAdapter* instance_; | 226 static ClientMessageLoopAdapter* instance_; |
227 }; | 227 }; |
228 | 228 |
229 ClientMessageLoopAdapter* ClientMessageLoopAdapter::instance_ = nullptr; | 229 ClientMessageLoopAdapter* ClientMessageLoopAdapter::instance_ = nullptr; |
230 | 230 |
231 // static | 231 // static |
232 WebDevToolsAgentImpl* WebDevToolsAgentImpl::Create( | 232 WebDevToolsAgentImpl* WebDevToolsAgentImpl::Create( |
233 WebLocalFrameImpl* frame, | 233 WebLocalFrameBase* frame, |
234 WebDevToolsAgentClient* client) { | 234 WebDevToolsAgentClient* client) { |
235 if (!IsMainFrame(frame)) { | 235 if (!IsMainFrame(frame)) { |
236 WebDevToolsAgentImpl* agent = | 236 WebDevToolsAgentImpl* agent = |
237 new WebDevToolsAgentImpl(frame, client, false); | 237 new WebDevToolsAgentImpl(frame, client, false); |
238 if (frame->FrameWidget()) | 238 if (frame->FrameWidget()) |
239 agent->LayerTreeViewChanged( | 239 agent->LayerTreeViewChanged( |
240 ToWebFrameWidgetImpl(frame->FrameWidget())->LayerTreeView()); | 240 ToWebFrameWidgetImpl(frame->FrameWidget())->LayerTreeView()); |
241 return agent; | 241 return agent; |
242 } | 242 } |
243 | 243 |
244 WebViewBase* view = frame->ViewImpl(); | 244 WebViewBase* view = frame->ViewImpl(); |
245 WebDevToolsAgentImpl* agent = new WebDevToolsAgentImpl(frame, client, true); | 245 WebDevToolsAgentImpl* agent = new WebDevToolsAgentImpl(frame, client, true); |
246 agent->LayerTreeViewChanged(view->LayerTreeView()); | 246 agent->LayerTreeViewChanged(view->LayerTreeView()); |
247 return agent; | 247 return agent; |
248 } | 248 } |
249 | 249 |
250 WebDevToolsAgentImpl::WebDevToolsAgentImpl( | 250 WebDevToolsAgentImpl::WebDevToolsAgentImpl( |
251 WebLocalFrameImpl* web_local_frame_impl, | 251 WebLocalFrameBase* web_local_frame_impl, |
252 WebDevToolsAgentClient* client, | 252 WebDevToolsAgentClient* client, |
253 bool include_view_agents) | 253 bool include_view_agents) |
254 : client_(client), | 254 : client_(client), |
255 web_local_frame_impl_(web_local_frame_impl), | 255 web_local_frame_impl_(web_local_frame_impl), |
256 probe_sink_(web_local_frame_impl_->GetFrame()->GetProbeSink()), | 256 probe_sink_(web_local_frame_impl_->GetFrame()->GetProbeSink()), |
257 resource_content_loader_(InspectorResourceContentLoader::Create( | 257 resource_content_loader_(InspectorResourceContentLoader::Create( |
258 web_local_frame_impl_->GetFrame())), | 258 web_local_frame_impl_->GetFrame())), |
259 inspected_frames_( | 259 inspected_frames_( |
260 InspectedFrames::Create(web_local_frame_impl_->GetFrame())), | 260 InspectedFrames::Create(web_local_frame_impl_->GetFrame())), |
261 resource_container_(new InspectorResourceContainer(inspected_frames_)), | 261 resource_container_(new InspectorResourceContainer(inspected_frames_)), |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 | 565 |
566 void WebDevToolsAgentImpl::PageLayoutInvalidated(bool resized) { | 566 void WebDevToolsAgentImpl::PageLayoutInvalidated(bool resized) { |
567 if (overlay_agent_) | 567 if (overlay_agent_) |
568 overlay_agent_->PageLayoutInvalidated(resized); | 568 overlay_agent_->PageLayoutInvalidated(resized); |
569 } | 569 } |
570 | 570 |
571 void WebDevToolsAgentImpl::WaitForCreateWindow(LocalFrame* frame) { | 571 void WebDevToolsAgentImpl::WaitForCreateWindow(LocalFrame* frame) { |
572 if (!Attached()) | 572 if (!Attached()) |
573 return; | 573 return; |
574 if (client_ && | 574 if (client_ && |
575 client_->RequestDevToolsForFrame(WebLocalFrameImpl::FromFrame(frame))) | 575 client_->RequestDevToolsForFrame(WebLocalFrameBase::FromFrame(frame))) |
576 ClientMessageLoopAdapter::PauseForCreateWindow(web_local_frame_impl_); | 576 ClientMessageLoopAdapter::PauseForCreateWindow(web_local_frame_impl_); |
577 } | 577 } |
578 | 578 |
579 WebString WebDevToolsAgentImpl::EvaluateInWebInspectorOverlay( | 579 WebString WebDevToolsAgentImpl::EvaluateInWebInspectorOverlay( |
580 const WebString& script) { | 580 const WebString& script) { |
581 if (!overlay_agent_) | 581 if (!overlay_agent_) |
582 return WebString(); | 582 return WebString(); |
583 | 583 |
584 return overlay_agent_->EvaluateInOverlayForTest(script); | 584 return overlay_agent_->EvaluateInOverlayForTest(script); |
585 } | 585 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 } | 648 } |
649 | 649 |
650 bool WebDevToolsAgent::ShouldInterruptForMethod(const WebString& method) { | 650 bool WebDevToolsAgent::ShouldInterruptForMethod(const WebString& method) { |
651 return method == "Debugger.pause" || method == "Debugger.setBreakpoint" || | 651 return method == "Debugger.pause" || method == "Debugger.setBreakpoint" || |
652 method == "Debugger.setBreakpointByUrl" || | 652 method == "Debugger.setBreakpointByUrl" || |
653 method == "Debugger.removeBreakpoint" || | 653 method == "Debugger.removeBreakpoint" || |
654 method == "Debugger.setBreakpointsActive"; | 654 method == "Debugger.setBreakpointsActive"; |
655 } | 655 } |
656 | 656 |
657 } // namespace blink | 657 } // namespace blink |
OLD | NEW |