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