| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/shell/ui/engine.h" | 5 #include "sky/shell/ui/engine.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" |
| 9 #include "base/threading/worker_pool.h" |
| 8 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| 11 #include "mojo/common/data_pipe_utils.h" |
| 9 #include "mojo/public/cpp/application/connect.h" | 12 #include "mojo/public/cpp/application/connect.h" |
| 10 #include "sky/engine/public/platform/WebInputEvent.h" | 13 #include "sky/engine/public/platform/WebInputEvent.h" |
| 11 #include "sky/engine/public/platform/sky_display_metrics.h" | 14 #include "sky/engine/public/platform/sky_display_metrics.h" |
| 12 #include "sky/engine/public/platform/sky_display_metrics.h" | 15 #include "sky/engine/public/platform/sky_display_metrics.h" |
| 13 #include "sky/engine/public/web/Sky.h" | 16 #include "sky/engine/public/web/Sky.h" |
| 14 #include "sky/engine/public/web/WebLocalFrame.h" | 17 #include "sky/engine/public/web/WebLocalFrame.h" |
| 15 #include "sky/engine/public/web/WebSettings.h" | 18 #include "sky/engine/public/web/WebSettings.h" |
| 16 #include "sky/engine/public/web/WebView.h" | 19 #include "sky/engine/public/web/WebView.h" |
| 17 #include "sky/services/platform/platform_impl.h" | 20 #include "sky/services/platform/platform_impl.h" |
| 18 #include "sky/shell/dart/dart_library_provider_files.h" | 21 #include "sky/shell/dart/dart_library_provider_files.h" |
| 19 #include "sky/shell/dart/dart_library_provider_network.h" | 22 #include "sky/shell/dart/dart_library_provider_network.h" |
| 20 #include "sky/shell/service_provider.h" | 23 #include "sky/shell/service_provider.h" |
| 21 #include "sky/shell/ui/animator.h" | 24 #include "sky/shell/ui/animator.h" |
| 22 #include "sky/shell/ui/input_event_converter.h" | 25 #include "sky/shell/ui/input_event_converter.h" |
| 23 #include "sky/shell/ui/internals.h" | 26 #include "sky/shell/ui/internals.h" |
| 24 #include "third_party/skia/include/core/SkCanvas.h" | 27 #include "third_party/skia/include/core/SkCanvas.h" |
| 25 #include "third_party/skia/include/core/SkPictureRecorder.h" | 28 #include "third_party/skia/include/core/SkPictureRecorder.h" |
| 26 | 29 |
| 27 namespace sky { | 30 namespace sky { |
| 28 namespace shell { | 31 namespace shell { |
| 29 | 32 |
| 30 namespace { | 33 namespace { |
| 31 | 34 |
| 35 void Ignored(bool) { |
| 36 } |
| 37 |
| 38 mojo::ScopedDataPipeConsumerHandle Fetch(const base::FilePath& path) { |
| 39 mojo::DataPipe pipe; |
| 40 auto runner = base::WorkerPool::GetTaskRunner(true); |
| 41 mojo::common::CopyFromFile(base::FilePath(path), pipe.producer_handle.Pass(), |
| 42 0, runner.get(), base::Bind(&Ignored)); |
| 43 return pipe.consumer_handle.Pass(); |
| 44 } |
| 45 |
| 32 void ConfigureSettings(blink::WebSettings* settings) { | 46 void ConfigureSettings(blink::WebSettings* settings) { |
| 33 settings->setDefaultFixedFontSize(13); | 47 settings->setDefaultFixedFontSize(13); |
| 34 settings->setDefaultFontSize(16); | 48 settings->setDefaultFontSize(16); |
| 35 settings->setLoadsImagesAutomatically(true); | 49 settings->setLoadsImagesAutomatically(true); |
| 36 } | 50 } |
| 37 | 51 |
| 38 PlatformImpl* g_platform_impl = nullptr; | 52 PlatformImpl* g_platform_impl = nullptr; |
| 39 | 53 |
| 40 } | 54 } |
| 41 | 55 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 RunFromLibrary(url); | 225 RunFromLibrary(url); |
| 212 } | 226 } |
| 213 | 227 |
| 214 void Engine::RunFromFile(const mojo::String& main, | 228 void Engine::RunFromFile(const mojo::String& main, |
| 215 const mojo::String& package_root) { | 229 const mojo::String& package_root) { |
| 216 dart_library_provider_.reset( | 230 dart_library_provider_.reset( |
| 217 new DartLibraryProviderFiles(base::FilePath(package_root))); | 231 new DartLibraryProviderFiles(base::FilePath(package_root))); |
| 218 RunFromLibrary(main); | 232 RunFromLibrary(main); |
| 219 } | 233 } |
| 220 | 234 |
| 221 void Engine::RunFromSnapshot(const mojo::String& url, | 235 void Engine::RunFromSnapshot(const mojo::String& path) { |
| 222 mojo::ScopedDataPipeConsumerHandle snapshot) { | |
| 223 CloseWebViewIfNeeded(); | 236 CloseWebViewIfNeeded(); |
| 224 sky_view_ = blink::SkyView::Create(this); | 237 sky_view_ = blink::SkyView::Create(this); |
| 225 sky_view_->RunFromSnapshot(blink::WebString::fromUTF8(url), snapshot.Pass()); | 238 sky_view_->RunFromSnapshot(blink::WebString::fromUTF8(path), |
| 239 Fetch(base::FilePath(path))); |
| 226 UpdateSkyViewSize(); | 240 UpdateSkyViewSize(); |
| 227 } | 241 } |
| 228 | 242 |
| 229 void Engine::LoadUsingWebView(const mojo::String& mojo_url) { | 243 void Engine::LoadUsingWebView(const mojo::String& mojo_url) { |
| 230 GURL url(mojo_url); | 244 GURL url(mojo_url); |
| 231 DCHECK(blink::WebView::shouldUseWebView(url)); | 245 DCHECK(blink::WebView::shouldUseWebView(url)); |
| 232 | 246 |
| 233 if (sky_view_) | 247 if (sky_view_) |
| 234 sky_view_ = nullptr; | 248 sky_view_ = nullptr; |
| 235 | 249 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 | 304 |
| 291 void Engine::DidNavigateLocally(const mojo::String& url) { | 305 void Engine::DidNavigateLocally(const mojo::String& url) { |
| 292 } | 306 } |
| 293 | 307 |
| 294 void Engine::RequestNavigateHistory(int32_t delta) { | 308 void Engine::RequestNavigateHistory(int32_t delta) { |
| 295 NOTIMPLEMENTED(); | 309 NOTIMPLEMENTED(); |
| 296 } | 310 } |
| 297 | 311 |
| 298 } // namespace shell | 312 } // namespace shell |
| 299 } // namespace sky | 313 } // namespace sky |
| OLD | NEW |