| OLD | NEW |
| 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 if (web_view_) | 199 if (web_view_) |
| 200 web_view_->close(); | 200 web_view_->close(); |
| 201 if (root_) | 201 if (root_) |
| 202 root_->RemoveObserver(this); | 202 root_->RemoveObserver(this); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void HTMLDocument::OnEmbed(View* root) { | 205 void HTMLDocument::OnEmbed(View* root) { |
| 206 DCHECK(!global_state_->is_headless()); | 206 DCHECK(!global_state_->is_headless()); |
| 207 root_ = root; | 207 root_ = root; |
| 208 root_->AddObserver(this); | 208 root_->AddObserver(this); |
| 209 root_->RequestCompositorFrameReceiver( |
| 210 compositor_frame_receiver_request_.Pass()); |
| 209 UpdateFocus(); | 211 UpdateFocus(); |
| 210 | 212 |
| 211 InitGlobalStateAndLoadIfNecessary(); | 213 InitGlobalStateAndLoadIfNecessary(); |
| 212 } | 214 } |
| 213 | 215 |
| 214 void HTMLDocument::OnViewManagerDestroyed(ViewManager* view_manager) { | 216 void HTMLDocument::OnViewManagerDestroyed(ViewManager* view_manager) { |
| 215 delete this; | 217 delete this; |
| 216 } | 218 } |
| 217 | 219 |
| 218 void HTMLDocument::Create(mojo::ApplicationConnection* connection, | 220 void HTMLDocument::Create(mojo::ApplicationConnection* connection, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 } | 298 } |
| 297 | 299 |
| 298 void HTMLDocument::initializeLayerTreeView() { | 300 void HTMLDocument::initializeLayerTreeView() { |
| 299 if (global_state_->is_headless()) { | 301 if (global_state_->is_headless()) { |
| 300 web_layer_tree_view_impl_.reset( | 302 web_layer_tree_view_impl_.reset( |
| 301 new WebLayerTreeViewImpl(global_state_->compositor_thread(), nullptr, | 303 new WebLayerTreeViewImpl(global_state_->compositor_thread(), nullptr, |
| 302 nullptr, nullptr, nullptr)); | 304 nullptr, nullptr, nullptr)); |
| 303 return; | 305 return; |
| 304 } | 306 } |
| 305 | 307 |
| 306 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 308 mojo::CompositorFrameReceiverPtr receiver; |
| 307 request->url = mojo::String::From("mojo:view_manager"); | 309 compositor_frame_receiver_request_ = GetProxy(&receiver); |
| 308 mojo::SurfacePtr surface; | |
| 309 html_document_app_->ConnectToService(request.Pass(), &surface); | |
| 310 | 310 |
| 311 // TODO(jamesr): Should be mojo:gpu_service | 311 // TODO(jamesr): Should be mojo:gpu_service |
| 312 mojo::URLRequestPtr request2(mojo::URLRequest::New()); | 312 mojo::URLRequestPtr request2(mojo::URLRequest::New()); |
| 313 request2->url = mojo::String::From("mojo:view_manager"); | 313 request2->url = mojo::String::From("mojo:view_manager"); |
| 314 mojo::GpuPtr gpu_service; | 314 mojo::GpuPtr gpu_service; |
| 315 html_document_app_->ConnectToService(request2.Pass(), &gpu_service); | 315 html_document_app_->ConnectToService(request2.Pass(), &gpu_service); |
| 316 web_layer_tree_view_impl_.reset(new WebLayerTreeViewImpl( | 316 web_layer_tree_view_impl_.reset(new WebLayerTreeViewImpl( |
| 317 global_state_->compositor_thread(), | 317 global_state_->compositor_thread(), |
| 318 global_state_->gpu_memory_buffer_manager(), | 318 global_state_->gpu_memory_buffer_manager(), |
| 319 global_state_->raster_thread_helper()->task_graph_runner(), | 319 global_state_->raster_thread_helper()->task_graph_runner(), |
| 320 surface.Pass(), gpu_service.Pass())); | 320 receiver.Pass(), gpu_service.Pass())); |
| 321 } | 321 } |
| 322 | 322 |
| 323 blink::WebLayerTreeView* HTMLDocument::layerTreeView() { | 323 blink::WebLayerTreeView* HTMLDocument::layerTreeView() { |
| 324 return web_layer_tree_view_impl_.get(); | 324 return web_layer_tree_view_impl_.get(); |
| 325 } | 325 } |
| 326 | 326 |
| 327 blink::WebMediaPlayer* HTMLDocument::createMediaPlayer( | 327 blink::WebMediaPlayer* HTMLDocument::createMediaPlayer( |
| 328 blink::WebLocalFrame* frame, | 328 blink::WebLocalFrame* frame, |
| 329 const blink::WebURL& url, | 329 const blink::WebURL& url, |
| 330 blink::WebMediaPlayerClient* client, | 330 blink::WebMediaPlayerClient* client, |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 | 490 |
| 491 void HTMLDocument::UpdateFocus() { | 491 void HTMLDocument::UpdateFocus() { |
| 492 if (!web_view_) | 492 if (!web_view_) |
| 493 return; | 493 return; |
| 494 bool is_focused = root_ && root_->HasFocus(); | 494 bool is_focused = root_ && root_->HasFocus(); |
| 495 web_view_->setFocus(is_focused); | 495 web_view_->setFocus(is_focused); |
| 496 web_view_->setIsActive(is_focused); | 496 web_view_->setIsActive(is_focused); |
| 497 } | 497 } |
| 498 | 498 |
| 499 } // namespace html_viewer | 499 } // namespace html_viewer |
| OLD | NEW |