| 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 #ifndef SKY_SHELL_UI_ENGINE_H_ | 5 #ifndef SKY_SHELL_UI_ENGINE_H_ |
| 6 #define SKY_SHELL_UI_ENGINE_H_ | 6 #define SKY_SHELL_UI_ENGINE_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "mojo/public/cpp/bindings/binding.h" | 12 #include "mojo/public/cpp/bindings/binding.h" |
| 13 #include "mojo/public/cpp/system/core.h" | 13 #include "mojo/public/cpp/system/core.h" |
| 14 #include "mojo/public/interfaces/application/service_provider.mojom.h" | 14 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
| 15 #include "mojo/services/navigation/public/interfaces/navigation.mojom.h" | 15 #include "mojo/services/navigation/public/interfaces/navigation.mojom.h" |
| 16 #include "skia/ext/refptr.h" | 16 #include "skia/ext/refptr.h" |
| 17 #include "sky/engine/public/platform/ServiceProvider.h" | 17 #include "sky/engine/public/platform/ServiceProvider.h" |
| 18 #include "sky/engine/public/sky/sky_view.h" | 18 #include "sky/engine/public/sky/sky_view.h" |
| 19 #include "sky/engine/public/sky/sky_view_client.h" | 19 #include "sky/engine/public/sky/sky_view_client.h" |
| 20 #include "sky/engine/public/web/WebFrameClient.h" | |
| 21 #include "sky/engine/public/web/WebViewClient.h" | |
| 22 #include "sky/shell/gpu_delegate.h" | 20 #include "sky/shell/gpu_delegate.h" |
| 23 #include "sky/shell/ui_delegate.h" | 21 #include "sky/shell/ui_delegate.h" |
| 24 #include "sky/shell/service_provider.h" | 22 #include "sky/shell/service_provider.h" |
| 25 #include "third_party/skia/include/core/SkPicture.h" | 23 #include "third_party/skia/include/core/SkPicture.h" |
| 26 #include "ui/gfx/geometry/size.h" | 24 #include "ui/gfx/geometry/size.h" |
| 27 | 25 |
| 28 namespace sky { | 26 namespace sky { |
| 29 class PlatformImpl; | 27 class PlatformImpl; |
| 30 namespace shell { | 28 namespace shell { |
| 31 class Animator; | 29 class Animator; |
| 32 | 30 |
| 33 class Engine : public UIDelegate, | 31 class Engine : public UIDelegate, |
| 34 public ViewportObserver, | 32 public ViewportObserver, |
| 35 public blink::ServiceProvider, | 33 public blink::ServiceProvider, |
| 36 public mojo::NavigatorHost, | 34 public mojo::NavigatorHost, |
| 37 public blink::WebFrameClient, | |
| 38 public blink::WebViewClient, | |
| 39 public blink::SkyViewClient { | 35 public blink::SkyViewClient { |
| 40 public: | 36 public: |
| 41 struct Config { | 37 struct Config { |
| 42 Config(); | 38 Config(); |
| 43 ~Config(); | 39 ~Config(); |
| 44 | 40 |
| 45 ServiceProviderContext* service_provider_context; | 41 ServiceProviderContext* service_provider_context; |
| 46 | 42 |
| 47 base::WeakPtr<GPUDelegate> gpu_delegate; | 43 base::WeakPtr<GPUDelegate> gpu_delegate; |
| 48 scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner; | 44 scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 68 // ViewportObserver: | 64 // ViewportObserver: |
| 69 void OnViewportMetricsChanged(int width, int height, | 65 void OnViewportMetricsChanged(int width, int height, |
| 70 float device_pixel_ratio) override; | 66 float device_pixel_ratio) override; |
| 71 void OnInputEvent(InputEventPtr event) override; | 67 void OnInputEvent(InputEventPtr event) override; |
| 72 | 68 |
| 73 void RunFromNetwork(const mojo::String& url) override; | 69 void RunFromNetwork(const mojo::String& url) override; |
| 74 void RunFromFile(const mojo::String& main, | 70 void RunFromFile(const mojo::String& main, |
| 75 const mojo::String& package_root) override; | 71 const mojo::String& package_root) override; |
| 76 void RunFromSnapshot(const mojo::String& path) override; | 72 void RunFromSnapshot(const mojo::String& path) override; |
| 77 | 73 |
| 78 // WebViewClient methods: | |
| 79 void frameDetached(blink::WebFrame*) override; | |
| 80 void initializeLayerTreeView() override; | |
| 81 void scheduleVisualUpdate() override; | |
| 82 blink::WebScreenInfo screenInfo() override; | |
| 83 blink::ServiceProvider* services() override; | |
| 84 | |
| 85 // WebFrameClient methods: | |
| 86 void didCreateIsolate(blink::WebLocalFrame* frame, | |
| 87 Dart_Isolate isolate) override; | |
| 88 | |
| 89 // SkyViewClient methods: | 74 // SkyViewClient methods: |
| 90 void ScheduleFrame() override; | 75 void ScheduleFrame() override; |
| 91 void DidCreateIsolate(Dart_Isolate isolate) override; | 76 void DidCreateIsolate(Dart_Isolate isolate) override; |
| 92 | 77 |
| 93 // Services methods: | 78 // Services methods: |
| 94 mojo::NavigatorHost* NavigatorHost() override; | 79 mojo::NavigatorHost* NavigatorHost() override; |
| 95 | 80 |
| 96 // NavigatorHost methods: | 81 // NavigatorHost methods: |
| 97 void RequestNavigate(mojo::Target target, | 82 void RequestNavigate(mojo::Target target, |
| 98 mojo::URLRequestPtr request) override; | 83 mojo::URLRequestPtr request) override; |
| 99 void DidNavigateLocally(const mojo::String& url) override; | 84 void DidNavigateLocally(const mojo::String& url) override; |
| 100 void RequestNavigateHistory(int32_t delta) override; | 85 void RequestNavigateHistory(int32_t delta) override; |
| 101 | 86 |
| 102 void RunFromLibrary(const mojo::String& name); | 87 void RunFromLibrary(const mojo::String& name); |
| 103 void CloseWebViewIfNeeded(); | |
| 104 void LoadUsingWebView(const mojo::String& mojo_url); | |
| 105 | 88 |
| 106 void UpdateSkyViewSize(); | 89 void UpdateSkyViewSize(); |
| 107 void UpdateWebViewSize(); | |
| 108 | 90 |
| 109 Config config_; | 91 Config config_; |
| 110 scoped_ptr<Animator> animator_; | 92 scoped_ptr<Animator> animator_; |
| 111 | 93 |
| 112 scoped_ptr<blink::DartLibraryProvider> dart_library_provider_; | 94 scoped_ptr<blink::DartLibraryProvider> dart_library_provider_; |
| 113 std::unique_ptr<blink::SkyView> sky_view_; | 95 std::unique_ptr<blink::SkyView> sky_view_; |
| 114 blink::WebView* web_view_; | |
| 115 | 96 |
| 116 float device_pixel_ratio_; | 97 float device_pixel_ratio_; |
| 117 gfx::Size physical_size_; | 98 gfx::Size physical_size_; |
| 118 mojo::Binding<ViewportObserver> viewport_observer_binding_; | 99 mojo::Binding<ViewportObserver> viewport_observer_binding_; |
| 119 | 100 |
| 120 base::WeakPtrFactory<Engine> weak_factory_; | 101 base::WeakPtrFactory<Engine> weak_factory_; |
| 121 | 102 |
| 122 DISALLOW_COPY_AND_ASSIGN(Engine); | 103 DISALLOW_COPY_AND_ASSIGN(Engine); |
| 123 }; | 104 }; |
| 124 | 105 |
| 125 } // namespace shell | 106 } // namespace shell |
| 126 } // namespace sky | 107 } // namespace sky |
| 127 | 108 |
| 128 #endif // SKY_SHELL_UI_ENGINE_H_ | 109 #endif // SKY_SHELL_UI_ENGINE_H_ |
| OLD | NEW |