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

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: 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
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/location.h" 8 #include "base/location.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.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/html_viewer/blink_input_events_type_converters.h" 15 #include "components/html_viewer/blink_input_events_type_converters.h"
16 #include "components/html_viewer/blink_url_request_type_converters.h" 16 #include "components/html_viewer/blink_url_request_type_converters.h"
17 #include "components/html_viewer/devtools_agent_impl.h"
17 #include "components/html_viewer/media_factory.h" 18 #include "components/html_viewer/media_factory.h"
18 #include "components/html_viewer/setup.h" 19 #include "components/html_viewer/setup.h"
19 #include "components/html_viewer/web_layer_tree_view_impl.h" 20 #include "components/html_viewer/web_layer_tree_view_impl.h"
20 #include "components/html_viewer/web_storage_namespace_impl.h" 21 #include "components/html_viewer/web_storage_namespace_impl.h"
21 #include "components/html_viewer/web_url_loader_impl.h" 22 #include "components/html_viewer/web_url_loader_impl.h"
22 #include "components/view_manager/public/cpp/view.h" 23 #include "components/view_manager/public/cpp/view.h"
23 #include "components/view_manager/public/interfaces/surfaces.mojom.h" 24 #include "components/view_manager/public/interfaces/surfaces.mojom.h"
24 #include "mojo/application/public/cpp/application_impl.h" 25 #include "mojo/application/public/cpp/application_impl.h"
25 #include "mojo/application/public/cpp/connect.h" 26 #include "mojo/application/public/cpp/connect.h"
26 #include "mojo/application/public/interfaces/shell.mojom.h" 27 #include "mojo/application/public/interfaces/shell.mojom.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 new AxProviderImpl(web_view_, request.Pass())); 158 new AxProviderImpl(web_view_, request.Pass()));
158 } 159 }
159 } 160 }
160 161
161 void HTMLDocument::Load(URLResponsePtr response) { 162 void HTMLDocument::Load(URLResponsePtr response) {
162 DCHECK(!web_view_); 163 DCHECK(!web_view_);
163 web_view_ = blink::WebView::create(this); 164 web_view_ = blink::WebView::create(this);
164 touch_handler_.reset(new TouchHandler(web_view_)); 165 touch_handler_.reset(new TouchHandler(web_view_));
165 web_layer_tree_view_impl_->set_widget(web_view_); 166 web_layer_tree_view_impl_->set_widget(web_view_);
166 ConfigureSettings(web_view_->settings()); 167 ConfigureSettings(web_view_->settings());
167 web_view_->setMainFrame( 168
168 blink::WebLocalFrame::create(blink::WebTreeScopeType::Document, this)); 169 blink::WebLocalFrame* main_frame =
170 blink::WebLocalFrame::create(blink::WebTreeScopeType::Document, this);
171 web_view_->setMainFrame(main_frame);
172
173 devtools_agent_.reset(new DevToolsAgentImpl(main_frame, shell_.get()));
sky 2015/06/02 23:28:32 Why do we always create devtools agent? Shouldn't
yzshen1 2015/06/05 17:29:29 This |devtools_agent_| registers itself with the D
sky 2015/06/05 19:13:30 SG
169 174
170 GURL url(response->url); 175 GURL url(response->url);
171 176
172 WebURLRequestExtraData* extra_data = new WebURLRequestExtraData; 177 WebURLRequestExtraData* extra_data = new WebURLRequestExtraData;
173 extra_data->synthetic_response = response.Pass(); 178 extra_data->synthetic_response = response.Pass();
174 179
175 blink::WebURLRequest web_request; 180 blink::WebURLRequest web_request;
176 web_request.initialize(); 181 web_request.initialize();
177 web_request.setURL(url); 182 web_request.setURL(url);
178 web_request.setExtraData(extra_data); 183 web_request.setExtraData(extra_data);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 blink::WebSandboxFlags sandboxFlags) { 256 blink::WebSandboxFlags sandboxFlags) {
252 blink::WebLocalFrame* web_frame = blink::WebLocalFrame::create(scope, this); 257 blink::WebLocalFrame* web_frame = blink::WebLocalFrame::create(scope, this);
253 parent->appendChild(web_frame); 258 parent->appendChild(web_frame);
254 return web_frame; 259 return web_frame;
255 } 260 }
256 261
257 void HTMLDocument::frameDetached(blink::WebFrame* frame) { 262 void HTMLDocument::frameDetached(blink::WebFrame* frame) {
258 if (frame->parent()) 263 if (frame->parent())
259 frame->parent()->removeChild(frame); 264 frame->parent()->removeChild(frame);
260 265
266 if (devtools_agent_ && frame == devtools_agent_->frame())
267 devtools_agent_.reset();
268
261 // |frame| is invalid after here. 269 // |frame| is invalid after here.
262 frame->close(); 270 frame->close();
263 } 271 }
264 272
265 blink::WebCookieJar* HTMLDocument::cookieJar(blink::WebLocalFrame* frame) { 273 blink::WebCookieJar* HTMLDocument::cookieJar(blink::WebLocalFrame* frame) {
266 // TODO(darin): Blink does not fallback to the Platform provided WebCookieJar. 274 // TODO(darin): Blink does not fallback to the Platform provided WebCookieJar.
267 // Either it should, as it once did, or we should find another solution here. 275 // Either it should, as it once did, or we should find another solution here.
268 return blink::Platform::current()->cookieJar(); 276 return blink::Platform::current()->cookieJar();
269 } 277 }
270 278
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 touch_handler_->OnTouchEvent(*event); 358 touch_handler_->OnTouchEvent(*event);
351 return; 359 return;
352 } 360 }
353 scoped_ptr<blink::WebInputEvent> web_event = 361 scoped_ptr<blink::WebInputEvent> web_event =
354 event.To<scoped_ptr<blink::WebInputEvent>>(); 362 event.To<scoped_ptr<blink::WebInputEvent>>();
355 if (web_event) 363 if (web_event)
356 web_view_->handleInputEvent(*web_event); 364 web_view_->handleInputEvent(*web_event);
357 } 365 }
358 366
359 } // namespace html_viewer 367 } // namespace html_viewer
OLDNEW
« components/html_viewer/devtools_agent_impl.cc ('K') | « components/html_viewer/html_document.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698