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

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

Issue 1165013005: Changes html_viewer to get services from appropriate application (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment on OnTerminate 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') | components/html_viewer/html_viewer.cc » ('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"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 if (request.extraData()) 135 if (request.extraData())
136 return true; 136 return true;
137 137
138 // Otherwise we don't know if we're the right app to handle this request. Ask 138 // Otherwise we don't know if we're the right app to handle this request. Ask
139 // host to do the navigation for us. 139 // host to do the navigation for us.
140 return false; 140 return false;
141 } 141 }
142 142
143 } // namespace 143 } // namespace
144 144
145 HTMLDocument::HTMLDocument( 145 HTMLDocument::HTMLDocument(mojo::ApplicationImpl* html_document_app,
146 mojo::InterfaceRequest<mojo::ServiceProvider> services, 146 mojo::ApplicationConnection* connection,
147 URLResponsePtr response, 147 URLResponsePtr response,
148 mojo::ShellPtr shell, 148 Setup* setup)
149 Setup* setup) 149 : app_refcount_(
150 : app_refcount_(setup->app()->app_lifetime_helper()->CreateAppRefCount()), 150 html_document_app->app_lifetime_helper()->CreateAppRefCount()),
151 html_document_app_(html_document_app),
151 response_(response.Pass()), 152 response_(response.Pass()),
152 shell_(shell.Pass()),
153 web_view_(nullptr), 153 web_view_(nullptr),
154 root_(nullptr), 154 root_(nullptr),
155 view_manager_client_factory_(shell_.get(), this), 155 view_manager_client_factory_(html_document_app->shell(), this),
156 setup_(setup) { 156 setup_(setup) {
157 exported_services_.AddService(this); 157 connection->AddService(this);
158 exported_services_.AddService(&view_manager_client_factory_); 158 connection->AddService(&view_manager_client_factory_);
159 exported_services_.Bind(services.Pass());
160 if (setup_->did_init()) 159 if (setup_->did_init())
161 Load(response_.Pass()); 160 Load(response_.Pass());
162 } 161 }
163 162
164 HTMLDocument::~HTMLDocument() { 163 HTMLDocument::~HTMLDocument() {
165 STLDeleteElements(&ax_providers_); 164 STLDeleteElements(&ax_providers_);
166 STLDeleteElements(&ax_provider_requests_); 165 STLDeleteElements(&ax_provider_requests_);
167 166
168 if (web_view_) 167 if (web_view_)
169 web_view_->close(); 168 web_view_->close();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 void HTMLDocument::initializeLayerTreeView() { 264 void HTMLDocument::initializeLayerTreeView() {
266 if (setup_->is_headless()) { 265 if (setup_->is_headless()) {
267 web_layer_tree_view_impl_.reset(new WebLayerTreeViewImpl( 266 web_layer_tree_view_impl_.reset(new WebLayerTreeViewImpl(
268 setup_->compositor_thread(), nullptr, nullptr)); 267 setup_->compositor_thread(), nullptr, nullptr));
269 return; 268 return;
270 } 269 }
271 270
272 mojo::URLRequestPtr request(mojo::URLRequest::New()); 271 mojo::URLRequestPtr request(mojo::URLRequest::New());
273 request->url = mojo::String::From("mojo:surfaces_service"); 272 request->url = mojo::String::From("mojo:surfaces_service");
274 mojo::SurfacePtr surface; 273 mojo::SurfacePtr surface;
275 setup_->app()->ConnectToService(request.Pass(), &surface); 274 html_document_app_->ConnectToService(request.Pass(), &surface);
276 275
277 // TODO(jamesr): Should be mojo:gpu_service 276 // TODO(jamesr): Should be mojo:gpu_service
278 mojo::URLRequestPtr request2(mojo::URLRequest::New()); 277 mojo::URLRequestPtr request2(mojo::URLRequest::New());
279 request2->url = mojo::String::From("mojo:view_manager"); 278 request2->url = mojo::String::From("mojo:view_manager");
280 mojo::GpuPtr gpu_service; 279 mojo::GpuPtr gpu_service;
281 setup_->app()->ConnectToService(request2.Pass(), &gpu_service); 280 html_document_app_->ConnectToService(request2.Pass(), &gpu_service);
282 web_layer_tree_view_impl_.reset(new WebLayerTreeViewImpl( 281 web_layer_tree_view_impl_.reset(new WebLayerTreeViewImpl(
283 setup_->compositor_thread(), surface.Pass(), gpu_service.Pass())); 282 setup_->compositor_thread(), surface.Pass(), gpu_service.Pass()));
284 } 283 }
285 284
286 blink::WebLayerTreeView* HTMLDocument::layerTreeView() { 285 blink::WebLayerTreeView* HTMLDocument::layerTreeView() {
287 return web_layer_tree_view_impl_.get(); 286 return web_layer_tree_view_impl_.get();
288 } 287 }
289 288
290 blink::WebMediaPlayer* HTMLDocument::createMediaPlayer( 289 blink::WebMediaPlayer* HTMLDocument::createMediaPlayer(
291 blink::WebLocalFrame* frame, 290 blink::WebLocalFrame* frame,
292 const blink::WebURL& url, 291 const blink::WebURL& url,
293 blink::WebMediaPlayerClient* client, 292 blink::WebMediaPlayerClient* client,
294 blink::WebContentDecryptionModule* initial_cdm) { 293 blink::WebContentDecryptionModule* initial_cdm) {
295 return setup_->media_factory()->CreateMediaPlayer(frame, url, client, 294 return setup_->media_factory()->CreateMediaPlayer(
296 initial_cdm, shell_.get()); 295 frame, url, client, initial_cdm, html_document_app_->shell());
297 } 296 }
298 297
299 blink::WebFrame* HTMLDocument::createChildFrame( 298 blink::WebFrame* HTMLDocument::createChildFrame(
300 blink::WebLocalFrame* parent, 299 blink::WebLocalFrame* parent,
301 blink::WebTreeScopeType scope, 300 blink::WebTreeScopeType scope,
302 const blink::WebString& frameName, 301 const blink::WebString& frameName,
303 blink::WebSandboxFlags sandboxFlags) { 302 blink::WebSandboxFlags sandboxFlags) {
304 blink::WebLocalFrame* child_frame = blink::WebLocalFrame::create(scope, this); 303 blink::WebLocalFrame* child_frame = blink::WebLocalFrame::create(scope, this);
305 parent->appendChild(child_frame); 304 parent->appendChild(child_frame);
306 if (EnableOOPIFs()) { 305 if (EnableOOPIFs()) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 void HTMLDocument::OnViewViewportMetricsChanged( 401 void HTMLDocument::OnViewViewportMetricsChanged(
403 mojo::View* view, 402 mojo::View* view,
404 const mojo::ViewportMetrics& old_metrics, 403 const mojo::ViewportMetrics& old_metrics,
405 const mojo::ViewportMetrics& new_metrics) { 404 const mojo::ViewportMetrics& new_metrics) {
406 InitSetupAndLoadIfNecessary(); 405 InitSetupAndLoadIfNecessary();
407 } 406 }
408 407
409 void HTMLDocument::OnViewDestroyed(View* view) { 408 void HTMLDocument::OnViewDestroyed(View* view) {
410 DCHECK_EQ(view, root_); 409 DCHECK_EQ(view, root_);
411 root_ = nullptr; 410 root_ = nullptr;
412 shell_->QuitApplication();
413 } 411 }
414 412
415 void HTMLDocument::OnViewInputEvent(View* view, const mojo::EventPtr& event) { 413 void HTMLDocument::OnViewInputEvent(View* view, const mojo::EventPtr& event) {
416 if (event->pointer_data) { 414 if (event->pointer_data) {
417 // Blink expects coordintes to be in DIPs. 415 // Blink expects coordintes to be in DIPs.
418 event->pointer_data->x /= setup_->device_pixel_ratio(); 416 event->pointer_data->x /= setup_->device_pixel_ratio();
419 event->pointer_data->y /= setup_->device_pixel_ratio(); 417 event->pointer_data->y /= setup_->device_pixel_ratio();
420 event->pointer_data->screen_x /= setup_->device_pixel_ratio(); 418 event->pointer_data->screen_x /= setup_->device_pixel_ratio();
421 event->pointer_data->screen_y /= setup_->device_pixel_ratio(); 419 event->pointer_data->screen_y /= setup_->device_pixel_ratio();
422 } 420 }
423 421
424 if ((event->action == mojo::EVENT_TYPE_POINTER_DOWN || 422 if ((event->action == mojo::EVENT_TYPE_POINTER_DOWN ||
425 event->action == mojo::EVENT_TYPE_POINTER_UP || 423 event->action == mojo::EVENT_TYPE_POINTER_UP ||
426 event->action == mojo::EVENT_TYPE_POINTER_CANCEL || 424 event->action == mojo::EVENT_TYPE_POINTER_CANCEL ||
427 event->action == mojo::EVENT_TYPE_POINTER_MOVE) && 425 event->action == mojo::EVENT_TYPE_POINTER_MOVE) &&
428 event->pointer_data->kind == mojo::POINTER_KIND_TOUCH) { 426 event->pointer_data->kind == mojo::POINTER_KIND_TOUCH) {
429 touch_handler_->OnTouchEvent(*event); 427 touch_handler_->OnTouchEvent(*event);
430 return; 428 return;
431 } 429 }
432 scoped_ptr<blink::WebInputEvent> web_event = 430 scoped_ptr<blink::WebInputEvent> web_event =
433 event.To<scoped_ptr<blink::WebInputEvent>>(); 431 event.To<scoped_ptr<blink::WebInputEvent>>();
434 if (web_event) 432 if (web_event)
435 web_view_->handleInputEvent(*web_event); 433 web_view_->handleInputEvent(*web_event);
436 } 434 }
437 435
438 } // namespace html_viewer 436 } // namespace html_viewer
OLDNEW
« no previous file with comments | « components/html_viewer/html_document.h ('k') | components/html_viewer/html_viewer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698