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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 root_->RemoveObserver(this); | 120 root_->RemoveObserver(this); |
121 ui::GestureRecognizer::Get()->CleanupStateForConsumer(this); | 121 ui::GestureRecognizer::Get()->CleanupStateForConsumer(this); |
122 } | 122 } |
123 | 123 |
124 base::WeakPtr<DocumentView> DocumentView::GetWeakPtr() { | 124 base::WeakPtr<DocumentView> DocumentView::GetWeakPtr() { |
125 return weak_factory_.GetWeakPtr(); | 125 return weak_factory_.GetWeakPtr(); |
126 } | 126 } |
127 | 127 |
128 void DocumentView::OnEmbed( | 128 void DocumentView::OnEmbed( |
129 mojo::View* root, | 129 mojo::View* root, |
130 mojo::InterfaceRequest<mojo::ServiceProvider> services, | 130 mojo::InterfaceRequest<mojo::ServiceProvider> services_provided_to_embedder, |
131 mojo::ServiceProviderPtr exposed_services) { | 131 mojo::ServiceProviderPtr embedder_provided_services) { |
132 root_ = root; | 132 root_ = root; |
133 imported_services_ = exposed_services.Pass(); | 133 |
134 navigator_host_.set_service_provider(imported_services_.get()); | 134 mojo::ConnectToService(embedder_provided_services.get(), &navigator_host_); |
| 135 mojo::ConnectToService(embedder_provided_services.get(), &test_harness_); |
| 136 |
| 137 services_provided_to_embedder_ = services_provided_to_embedder.Pass(); |
| 138 embedder_provided_services_ = embedder_provided_services.Pass(); |
135 | 139 |
136 Load(response_.Pass()); | 140 Load(response_.Pass()); |
137 | 141 |
138 UpdateRootSizeAndViewportMetrics(root_->bounds()); | 142 UpdateRootSizeAndViewportMetrics(root_->bounds()); |
139 | 143 |
140 // TODO(abarth): We should ask the view whether it is focused instead of | 144 // TODO(abarth): We should ask the view whether it is focused instead of |
141 // assuming that we're focused. | 145 // assuming that we're focused. |
142 web_view_->setFocus(true); | 146 web_view_->setFocus(true); |
143 root_->AddObserver(this); | 147 root_->AddObserver(this); |
144 } | 148 } |
(...skipping 26 matching lines...) Expand all Loading... |
171 bitmap_rasterizer_ = new RasterizerBitmap(layer_host_.get()); | 175 bitmap_rasterizer_ = new RasterizerBitmap(layer_host_.get()); |
172 return make_scoped_ptr(bitmap_rasterizer_); | 176 return make_scoped_ptr(bitmap_rasterizer_); |
173 } | 177 } |
174 | 178 |
175 void DocumentView::GetPixelsForTesting(std::vector<unsigned char>* pixels) { | 179 void DocumentView::GetPixelsForTesting(std::vector<unsigned char>* pixels) { |
176 DCHECK(RuntimeFlags::Get().testing()) << "Requires testing runtime flag"; | 180 DCHECK(RuntimeFlags::Get().testing()) << "Requires testing runtime flag"; |
177 DCHECK(root_layer_) << "The root layer owns the rasterizer"; | 181 DCHECK(root_layer_) << "The root layer owns the rasterizer"; |
178 return bitmap_rasterizer_->GetPixelsForTesting(pixels); | 182 return bitmap_rasterizer_->GetPixelsForTesting(pixels); |
179 } | 183 } |
180 | 184 |
| 185 TestHarnessPtr DocumentView::TakeTestHarness() { |
| 186 return test_harness_.Pass(); |
| 187 } |
| 188 |
| 189 mojo::ScopedMessagePipeHandle DocumentView::TakeServicesProvidedToEmbedder() { |
| 190 return services_provided_to_embedder_.PassMessagePipe(); |
| 191 } |
| 192 |
| 193 mojo::ScopedMessagePipeHandle DocumentView::TakeServicesProvidedByEmbedder() { |
| 194 return embedder_provided_services_.PassMessagePipe(); |
| 195 } |
| 196 |
181 mojo::Shell* DocumentView::GetShell() { | 197 mojo::Shell* DocumentView::GetShell() { |
182 return shell_; | 198 return shell_; |
183 } | 199 } |
184 | 200 |
185 void DocumentView::BeginFrame(base::TimeTicks frame_time) { | 201 void DocumentView::BeginFrame(base::TimeTicks frame_time) { |
186 double frame_time_sec = (frame_time - base::TimeTicks()).InSecondsF(); | 202 double frame_time_sec = (frame_time - base::TimeTicks()).InSecondsF(); |
187 double deadline_sec = frame_time_sec; | 203 double deadline_sec = frame_time_sec; |
188 double interval_sec = 1.0/60; | 204 double interval_sec = 1.0/60; |
189 blink::WebBeginFrameArgs web_begin_frame_args( | 205 blink::WebBeginFrameArgs web_begin_frame_args( |
190 frame_time_sec, deadline_sec, interval_sec); | 206 frame_time_sec, deadline_sec, interval_sec); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 } | 354 } |
339 } | 355 } |
340 } | 356 } |
341 } | 357 } |
342 | 358 |
343 void DocumentView::StartDebuggerInspectorBackend() { | 359 void DocumentView::StartDebuggerInspectorBackend() { |
344 // FIXME: Do we need this for dart? | 360 // FIXME: Do we need this for dart? |
345 } | 361 } |
346 | 362 |
347 } // namespace sky | 363 } // namespace sky |
OLD | NEW |