| 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/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 9 #include "mojo/public/cpp/application/connect.h" | 9 #include "mojo/public/cpp/application/connect.h" |
| 10 #include "sky/engine/public/platform/WebInputEvent.h" | 10 #include "sky/engine/public/platform/WebInputEvent.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 namespace shell { | 26 namespace shell { |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 void ConfigureSettings(blink::WebSettings* settings) { | 30 void ConfigureSettings(blink::WebSettings* settings) { |
| 31 settings->setDefaultFixedFontSize(13); | 31 settings->setDefaultFixedFontSize(13); |
| 32 settings->setDefaultFontSize(16); | 32 settings->setDefaultFontSize(16); |
| 33 settings->setLoadsImagesAutomatically(true); | 33 settings->setLoadsImagesAutomatically(true); |
| 34 } | 34 } |
| 35 | 35 |
| 36 PlatformImpl* g_platform_impl = nullptr; |
| 37 |
| 36 } | 38 } |
| 37 | 39 |
| 38 Engine::Engine(const Config& config) | 40 Engine::Engine(const Config& config) |
| 39 : config_(config), | 41 : config_(config), |
| 40 animator_(new Animator(config, this)), | 42 animator_(new Animator(config, this)), |
| 41 web_view_(nullptr), | 43 web_view_(nullptr), |
| 42 device_pixel_ratio_(1.0f), | 44 device_pixel_ratio_(1.0f), |
| 43 viewport_observer_binding_(this), | 45 viewport_observer_binding_(this), |
| 44 weak_factory_(this) { | 46 weak_factory_(this) { |
| 45 } | 47 } |
| 46 | 48 |
| 47 Engine::~Engine() { | 49 Engine::~Engine() { |
| 48 if (web_view_) | 50 if (web_view_) |
| 49 web_view_->close(); | 51 web_view_->close(); |
| 50 } | 52 } |
| 51 | 53 |
| 52 base::WeakPtr<Engine> Engine::GetWeakPtr() { | 54 base::WeakPtr<Engine> Engine::GetWeakPtr() { |
| 53 return weak_factory_.GetWeakPtr(); | 55 return weak_factory_.GetWeakPtr(); |
| 54 } | 56 } |
| 55 | 57 |
| 56 void Engine::Init() { | 58 void Engine::Init(ServiceProviderContext* service_provider_context) { |
| 57 TRACE_EVENT0("sky", "Engine::Init"); | 59 TRACE_EVENT0("sky", "Engine::Init"); |
| 58 | 60 |
| 59 service_provider_ = CreateServiceProvider(config_.service_provider_context); | 61 mojo::ServiceProviderPtr service_provider = |
| 62 CreateServiceProvider(service_provider_context); |
| 60 mojo::NetworkServicePtr network_service; | 63 mojo::NetworkServicePtr network_service; |
| 61 mojo::ConnectToService(service_provider_.get(), &network_service); | 64 mojo::ConnectToService(service_provider.get(), &network_service); |
| 62 platform_impl_.reset(new PlatformImpl(network_service.Pass())); | |
| 63 | 65 |
| 64 blink::initialize(platform_impl_.get()); | 66 DCHECK(!g_platform_impl); |
| 67 g_platform_impl = new PlatformImpl(network_service.Pass()); |
| 68 blink::initialize(g_platform_impl); |
| 65 } | 69 } |
| 66 | 70 |
| 67 void Engine::BeginFrame(base::TimeTicks frame_time) { | 71 void Engine::BeginFrame(base::TimeTicks frame_time) { |
| 68 TRACE_EVENT0("sky", "Engine::BeginFrame"); | 72 TRACE_EVENT0("sky", "Engine::BeginFrame"); |
| 69 | 73 |
| 70 if (sky_view_) | 74 if (sky_view_) |
| 71 sky_view_->BeginFrame(frame_time); | 75 sky_view_->BeginFrame(frame_time); |
| 72 | 76 |
| 73 if (web_view_) { | 77 if (web_view_) { |
| 74 double frame_time_sec = (frame_time - base::TimeTicks()).InSecondsF(); | 78 double frame_time_sec = (frame_time - base::TimeTicks()).InSecondsF(); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 | 248 |
| 245 void Engine::DidNavigateLocally(const mojo::String& url) { | 249 void Engine::DidNavigateLocally(const mojo::String& url) { |
| 246 } | 250 } |
| 247 | 251 |
| 248 void Engine::RequestNavigateHistory(int32_t delta) { | 252 void Engine::RequestNavigateHistory(int32_t delta) { |
| 249 NOTIMPLEMENTED(); | 253 NOTIMPLEMENTED(); |
| 250 } | 254 } |
| 251 | 255 |
| 252 } // namespace shell | 256 } // namespace shell |
| 253 } // namespace sky | 257 } // namespace sky |
| OLD | NEW |