Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: components/html_viewer/html_document.cc

Issue 1163953002: html_viewer: Add DevToolsAgentImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't create DevToolsAgentImpl instance unless --remote-debugging-port is specified Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/html_viewer/html_document.h ('k') | mandoline/app/android/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/html_viewer/html_document.h" 5 #include "components/html_viewer/html_document.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
15 #include "components/devtools_service/public/cpp/switches.h"
15 #include "components/html_viewer/blink_input_events_type_converters.h" 16 #include "components/html_viewer/blink_input_events_type_converters.h"
16 #include "components/html_viewer/blink_url_request_type_converters.h" 17 #include "components/html_viewer/blink_url_request_type_converters.h"
18 #include "components/html_viewer/devtools_agent_impl.h"
17 #include "components/html_viewer/media_factory.h" 19 #include "components/html_viewer/media_factory.h"
18 #include "components/html_viewer/setup.h" 20 #include "components/html_viewer/setup.h"
19 #include "components/html_viewer/web_layer_tree_view_impl.h" 21 #include "components/html_viewer/web_layer_tree_view_impl.h"
20 #include "components/html_viewer/web_storage_namespace_impl.h" 22 #include "components/html_viewer/web_storage_namespace_impl.h"
21 #include "components/html_viewer/web_url_loader_impl.h" 23 #include "components/html_viewer/web_url_loader_impl.h"
22 #include "components/view_manager/public/cpp/view.h" 24 #include "components/view_manager/public/cpp/view.h"
23 #include "components/view_manager/public/cpp/view_manager.h" 25 #include "components/view_manager/public/cpp/view_manager.h"
24 #include "components/view_manager/public/cpp/view_property.h" 26 #include "components/view_manager/public/cpp/view_property.h"
25 #include "components/view_manager/public/interfaces/surfaces.mojom.h" 27 #include "components/view_manager/public/interfaces/surfaces.mojom.h"
26 #include "mojo/application/public/cpp/application_impl.h" 28 #include "mojo/application/public/cpp/application_impl.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 namespace html_viewer { 62 namespace html_viewer {
61 namespace { 63 namespace {
62 64
63 // Switch to enable out of process iframes. 65 // Switch to enable out of process iframes.
64 const char kOOPIF[] = "oopifs"; 66 const char kOOPIF[] = "oopifs";
65 67
66 bool EnableOOPIFs() { 68 bool EnableOOPIFs() {
67 return base::CommandLine::ForCurrentProcess()->HasSwitch(kOOPIF); 69 return base::CommandLine::ForCurrentProcess()->HasSwitch(kOOPIF);
68 } 70 }
69 71
72 bool EnableRemoteDebugging() {
73 return base::CommandLine::ForCurrentProcess()->HasSwitch(
74 devtools_service::kRemoteDebuggingPort);
75 }
76
70 // WebRemoteFrameClient implementation used for OOPIFs. 77 // WebRemoteFrameClient implementation used for OOPIFs.
71 // TODO(sky): this needs to talk to browser by way of an interface. 78 // TODO(sky): this needs to talk to browser by way of an interface.
72 class RemoteFrameClientImpl : public blink::WebRemoteFrameClient { 79 class RemoteFrameClientImpl : public blink::WebRemoteFrameClient {
73 public: 80 public:
74 explicit RemoteFrameClientImpl(mojo::View* view) : view_(view) {} 81 explicit RemoteFrameClientImpl(mojo::View* view) : view_(view) {}
75 ~RemoteFrameClientImpl() {} 82 ~RemoteFrameClientImpl() {}
76 83
77 // WebRemoteFrameClient methods: 84 // WebRemoteFrameClient methods:
78 virtual void postMessageEvent(blink::WebLocalFrame* source_frame, 85 virtual void postMessageEvent(blink::WebLocalFrame* source_frame,
79 blink::WebRemoteFrame* target_frame, 86 blink::WebRemoteFrame* target_frame,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 mojo::InterfaceRequest<mandoline::FrameTreeClient> request) { 214 mojo::InterfaceRequest<mandoline::FrameTreeClient> request) {
208 frame_tree_manager_binding_.Bind(request.Pass()); 215 frame_tree_manager_binding_.Bind(request.Pass());
209 } 216 }
210 217
211 void HTMLDocument::Load(URLResponsePtr response) { 218 void HTMLDocument::Load(URLResponsePtr response) {
212 DCHECK(!web_view_); 219 DCHECK(!web_view_);
213 web_view_ = blink::WebView::create(this); 220 web_view_ = blink::WebView::create(this);
214 touch_handler_.reset(new TouchHandler(web_view_)); 221 touch_handler_.reset(new TouchHandler(web_view_));
215 web_layer_tree_view_impl_->set_widget(web_view_); 222 web_layer_tree_view_impl_->set_widget(web_view_);
216 ConfigureSettings(web_view_->settings()); 223 ConfigureSettings(web_view_->settings());
217 web_view_->setMainFrame( 224
218 blink::WebLocalFrame::create(blink::WebTreeScopeType::Document, this)); 225 blink::WebLocalFrame* main_frame =
226 blink::WebLocalFrame::create(blink::WebTreeScopeType::Document, this);
227 web_view_->setMainFrame(main_frame);
228
229 // TODO(yzshen): http://crbug.com/498986 Creating DevToolsAgentImpl instances
230 // causes html_viewer_apptests flakiness currently. Before we fix that we
231 // cannot enable remote debugging (which is required by Telemetry tests) on
232 // the bots.
233 if (EnableRemoteDebugging()) {
234 devtools_agent_.reset(
235 new DevToolsAgentImpl(main_frame, html_document_app_->shell()));
236 }
219 237
220 GURL url(response->url); 238 GURL url(response->url);
221 239
222 WebURLRequestExtraData* extra_data = new WebURLRequestExtraData; 240 WebURLRequestExtraData* extra_data = new WebURLRequestExtraData;
223 extra_data->synthetic_response = response.Pass(); 241 extra_data->synthetic_response = response.Pass();
224 242
225 blink::WebURLRequest web_request; 243 blink::WebURLRequest web_request;
226 web_request.initialize(); 244 web_request.initialize();
227 web_request.setURL(url); 245 web_request.setURL(url);
228 web_request.setExtraData(extra_data); 246 web_request.setExtraData(extra_data);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 child_frame_data.scope = scope; 340 child_frame_data.scope = scope;
323 frame_to_view_[child_frame] = child_frame_data; 341 frame_to_view_[child_frame] = child_frame_data;
324 } 342 }
325 return child_frame; 343 return child_frame;
326 } 344 }
327 345
328 void HTMLDocument::frameDetached(blink::WebFrame* frame) { 346 void HTMLDocument::frameDetached(blink::WebFrame* frame) {
329 if (frame->parent()) 347 if (frame->parent())
330 frame->parent()->removeChild(frame); 348 frame->parent()->removeChild(frame);
331 349
350 if (devtools_agent_ && frame == devtools_agent_->frame())
351 devtools_agent_.reset();
352
332 // |frame| is invalid after here. 353 // |frame| is invalid after here.
333 frame->close(); 354 frame->close();
334 } 355 }
335 356
336 blink::WebCookieJar* HTMLDocument::cookieJar(blink::WebLocalFrame* frame) { 357 blink::WebCookieJar* HTMLDocument::cookieJar(blink::WebLocalFrame* frame) {
337 // TODO(darin): Blink does not fallback to the Platform provided WebCookieJar. 358 // TODO(darin): Blink does not fallback to the Platform provided WebCookieJar.
338 // Either it should, as it once did, or we should find another solution here. 359 // Either it should, as it once did, or we should find another solution here.
339 return blink::Platform::current()->cookieJar(); 360 return blink::Platform::current()->cookieJar();
340 } 361 }
341 362
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 touch_handler_->OnTouchEvent(*event); 456 touch_handler_->OnTouchEvent(*event);
436 return; 457 return;
437 } 458 }
438 scoped_ptr<blink::WebInputEvent> web_event = 459 scoped_ptr<blink::WebInputEvent> web_event =
439 event.To<scoped_ptr<blink::WebInputEvent>>(); 460 event.To<scoped_ptr<blink::WebInputEvent>>();
440 if (web_event) 461 if (web_event)
441 web_view_->handleInputEvent(*web_event); 462 web_view_->handleInputEvent(*web_event);
442 } 463 }
443 464
444 } // namespace html_viewer 465 } // namespace html_viewer
OLDNEW
« no previous file with comments | « components/html_viewer/html_document.h ('k') | mandoline/app/android/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698