| 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 "sky/viewer/document_view.h" | 5 #include "sky/viewer/document_view.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/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 base::WeakPtr<DocumentView> DocumentView::GetWeakPtr() { | 126 base::WeakPtr<DocumentView> DocumentView::GetWeakPtr() { |
| 127 return weak_factory_.GetWeakPtr(); | 127 return weak_factory_.GetWeakPtr(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 void DocumentView::OnEmbed( | 130 void DocumentView::OnEmbed( |
| 131 mojo::View* root, | 131 mojo::View* root, |
| 132 mojo::InterfaceRequest<mojo::ServiceProvider> services_provided_to_embedder, | 132 mojo::InterfaceRequest<mojo::ServiceProvider> services_provided_to_embedder, |
| 133 mojo::ServiceProviderPtr services_provided_by_embedder) { | 133 mojo::ServiceProviderPtr services_provided_by_embedder) { |
| 134 root_ = root; | 134 root_ = root; |
| 135 | 135 |
| 136 mojo::ConnectToService(services_provided_by_embedder.get(), &navigator_host_); | 136 if (services_provided_by_embedder.get()) { |
| 137 if (RuntimeFlags::Get().testing()) | 137 mojo::ConnectToService(services_provided_by_embedder.get(), |
| 138 mojo::ConnectToService(services_provided_by_embedder.get(), &test_harness_); | 138 &navigator_host_); |
| 139 if (RuntimeFlags::Get().testing()) |
| 140 mojo::ConnectToService(services_provided_by_embedder.get(), |
| 141 &test_harness_); |
| 142 } |
| 139 | 143 |
| 140 services_provided_to_embedder_ = services_provided_to_embedder.Pass(); | 144 services_provided_to_embedder_ = services_provided_to_embedder.Pass(); |
| 141 services_provided_by_embedder_ = services_provided_by_embedder.Pass(); | 145 services_provided_by_embedder_ = services_provided_by_embedder.Pass(); |
| 142 | 146 |
| 143 Load(response_.Pass()); | 147 Load(response_.Pass()); |
| 144 | 148 |
| 145 UpdateRootSizeAndViewportMetrics(root_->bounds()); | 149 UpdateRootSizeAndViewportMetrics(root_->bounds()); |
| 146 | 150 |
| 147 // TODO(abarth): We should ask the view whether it is focused instead of | 151 // TODO(abarth): We should ask the view whether it is focused instead of |
| 148 // assuming that we're focused. | 152 // assuming that we're focused. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 | 265 |
| 262 float DocumentView::GetDevicePixelRatio() const { | 266 float DocumentView::GetDevicePixelRatio() const { |
| 263 if (root_) | 267 if (root_) |
| 264 return root_->viewport_metrics().device_pixel_ratio; | 268 return root_->viewport_metrics().device_pixel_ratio; |
| 265 return 1.f; | 269 return 1.f; |
| 266 } | 270 } |
| 267 | 271 |
| 268 blink::WebNavigationPolicy DocumentView::decidePolicyForNavigation( | 272 blink::WebNavigationPolicy DocumentView::decidePolicyForNavigation( |
| 269 const blink::WebFrameClient::NavigationPolicyInfo& info) { | 273 const blink::WebFrameClient::NavigationPolicyInfo& info) { |
| 270 | 274 |
| 271 navigator_host_->RequestNavigate( | 275 if (navigator_host_.get()) { |
| 272 WebNavigationPolicyToNavigationTarget(info.defaultPolicy), | 276 navigator_host_->RequestNavigate( |
| 273 mojo::URLRequest::From(info.urlRequest).Pass()); | 277 WebNavigationPolicyToNavigationTarget(info.defaultPolicy), |
| 278 mojo::URLRequest::From(info.urlRequest).Pass()); |
| 279 } |
| 274 | 280 |
| 275 return blink::WebNavigationPolicyIgnore; | 281 return blink::WebNavigationPolicyIgnore; |
| 276 } | 282 } |
| 277 | 283 |
| 278 void DocumentView::didAddMessageToConsole( | 284 void DocumentView::didAddMessageToConsole( |
| 279 const blink::WebConsoleMessage& message, | 285 const blink::WebConsoleMessage& message, |
| 280 const blink::WebString& source_name, | 286 const blink::WebString& source_name, |
| 281 unsigned source_line, | 287 unsigned source_line, |
| 282 const blink::WebString& stack_trace) { | 288 const blink::WebString& stack_trace) { |
| 283 } | 289 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 interface_names[0] = mojo::ViewManagerClient::Name_; | 379 interface_names[0] = mojo::ViewManagerClient::Name_; |
| 374 mojo::ServiceProviderImpl* sp_impl(new mojo::ServiceProviderImpl()); | 380 mojo::ServiceProviderImpl* sp_impl(new mojo::ServiceProviderImpl()); |
| 375 sp_impl->AddService(&view_manager_client_factory_); | 381 sp_impl->AddService(&view_manager_client_factory_); |
| 376 mojo::ServiceProviderPtr sp; | 382 mojo::ServiceProviderPtr sp; |
| 377 service_registry_service_provider_binding_.reset( | 383 service_registry_service_provider_binding_.reset( |
| 378 new mojo::StrongBinding<mojo::ServiceProvider>(sp_impl, &sp)); | 384 new mojo::StrongBinding<mojo::ServiceProvider>(sp_impl, &sp)); |
| 379 service_registry_->AddServices(interface_names.Pass(), sp.Pass()); | 385 service_registry_->AddServices(interface_names.Pass(), sp.Pass()); |
| 380 } | 386 } |
| 381 | 387 |
| 382 } // namespace sky | 388 } // namespace sky |
| OLD | NEW |