| 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 #ifndef SKY_VIEWER_DOCUMENT_VIEW_H_ | 5 #ifndef SKY_VIEWER_DOCUMENT_VIEW_H_ |
| 6 #define SKY_VIEWER_DOCUMENT_VIEW_H_ | 6 #define SKY_VIEWER_DOCUMENT_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "mojo/public/cpp/application/lazy_interface_ptr.h" | 10 #include "mojo/public/cpp/application/lazy_interface_ptr.h" |
| 11 #include "mojo/public/cpp/application/service_provider_impl.h" | 11 #include "mojo/public/cpp/application/service_provider_impl.h" |
| 12 #include "mojo/public/cpp/bindings/interface_impl.h" | 12 #include "mojo/public/cpp/bindings/interface_impl.h" |
| 13 #include "mojo/public/interfaces/application/application.mojom.h" | 13 #include "mojo/public/interfaces/application/application.mojom.h" |
| 14 #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h" | 14 #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h" |
| 15 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" | 15 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" |
| 16 #include "mojo/services/public/cpp/view_manager/view_observer.h" | 16 #include "mojo/services/public/cpp/view_manager/view_observer.h" |
| 17 #include "mojo/services/public/interfaces/content_handler/content_handler.mojom.
h" | 17 #include "mojo/services/public/interfaces/content_handler/content_handler.mojom.
h" |
| 18 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h" | 18 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h" |
| 19 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" | 19 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" |
| 20 #include "sky/compositor/layer_client.h" | 20 #include "sky/compositor/layer_client.h" |
| 21 #include "sky/compositor/layer_host_client.h" | 21 #include "sky/compositor/layer_host_client.h" |
| 22 #include "sky/engine/public/platform/ServiceProvider.h" | 22 #include "sky/engine/public/platform/ServiceProvider.h" |
| 23 #include "sky/engine/public/web/WebFrameClient.h" | 23 #include "sky/engine/public/web/WebFrameClient.h" |
| 24 #include "sky/engine/public/web/WebViewClient.h" | 24 #include "sky/engine/public/web/WebViewClient.h" |
| 25 #include "sky/viewer/services/inspector_impl.h" | 25 #include "sky/viewer/services/inspector_impl.h" |
| 26 | 26 |
| 27 // You can try enabling the Sky compositor, but it's a bit buggy. | |
| 28 #define ENABLE_SKY_COMPOSITOR 1 | |
| 29 | |
| 30 namespace base { | |
| 31 class MessageLoopProxy; | |
| 32 } | |
| 33 | |
| 34 namespace mojo { | 27 namespace mojo { |
| 35 class ViewManager; | 28 class ViewManager; |
| 36 class View; | 29 class View; |
| 37 } | 30 } |
| 38 | 31 |
| 39 namespace inspector { | 32 namespace inspector { |
| 40 class InspectorBackendMojo; | 33 class InspectorBackendMojo; |
| 41 } | 34 } |
| 42 | 35 |
| 43 namespace sky { | 36 namespace sky { |
| 44 class InspectorHostImpl; | 37 class InspectorHostImpl; |
| 45 class ScriptRunner; | 38 class ScriptRunner; |
| 46 class Layer; | 39 class Layer; |
| 47 class LayerHost; | 40 class LayerHost; |
| 48 class WebLayerTreeViewImpl; | |
| 49 | 41 |
| 50 class DocumentView : public blink::ServiceProvider, | 42 class DocumentView : public blink::ServiceProvider, |
| 51 public blink::WebViewClient, | 43 public blink::WebViewClient, |
| 52 public blink::WebFrameClient, | 44 public blink::WebFrameClient, |
| 53 #if ENABLE_SKY_COMPOSITOR | |
| 54 public sky::LayerClient, | 45 public sky::LayerClient, |
| 55 public sky::LayerHostClient, | 46 public sky::LayerHostClient, |
| 56 #endif | |
| 57 public mojo::ViewManagerDelegate, | 47 public mojo::ViewManagerDelegate, |
| 58 public mojo::ViewObserver { | 48 public mojo::ViewObserver { |
| 59 public: | 49 public: |
| 60 DocumentView(const base::Closure& destruction_callback, | 50 DocumentView(const base::Closure& destruction_callback, |
| 61 mojo::ServiceProviderPtr provider, | 51 mojo::ServiceProviderPtr provider, |
| 62 mojo::URLResponsePtr response, | 52 mojo::URLResponsePtr response, |
| 63 mojo::Shell* shell, | 53 mojo::Shell* shell); |
| 64 scoped_refptr<base::MessageLoopProxy> compositor_thread); | |
| 65 virtual ~DocumentView(); | 54 virtual ~DocumentView(); |
| 66 | 55 |
| 67 base::WeakPtr<DocumentView> GetWeakPtr(); | 56 base::WeakPtr<DocumentView> GetWeakPtr(); |
| 68 | 57 |
| 69 blink::WebView* web_view() const { return web_view_; } | 58 blink::WebView* web_view() const { return web_view_; } |
| 70 mojo::ServiceProvider* imported_services() const { | 59 mojo::ServiceProvider* imported_services() const { |
| 71 return imported_services_.get(); | 60 return imported_services_.get(); |
| 72 } | 61 } |
| 73 | 62 |
| 74 mojo::Shell* shell() const { return shell_; } | 63 mojo::Shell* shell() const { return shell_; } |
| 75 | 64 |
| 76 #if ENABLE_SKY_COMPOSITOR | |
| 77 // sky::LayerHostClient | 65 // sky::LayerHostClient |
| 78 mojo::Shell* GetShell() override; | 66 mojo::Shell* GetShell() override; |
| 79 void BeginFrame(base::TimeTicks frame_time) override; | 67 void BeginFrame(base::TimeTicks frame_time) override; |
| 80 void OnSurfaceIdAvailable(mojo::SurfaceIdPtr surface_id) override; | 68 void OnSurfaceIdAvailable(mojo::SurfaceIdPtr surface_id) override; |
| 81 // sky::LayerClient | 69 // sky::LayerClient |
| 82 void PaintContents(SkCanvas* canvas, const gfx::Rect& clip) override; | 70 void PaintContents(SkCanvas* canvas, const gfx::Rect& clip) override; |
| 83 #endif // ENABLE_SKY_COMPOSITOR | |
| 84 | 71 |
| 85 void StartDebuggerInspectorBackend(); | 72 void StartDebuggerInspectorBackend(); |
| 86 | 73 |
| 87 private: | 74 private: |
| 88 // WebWidgetClient methods: | 75 // WebWidgetClient methods: |
| 89 blink::WebLayerTreeView* initializeLayerTreeView() override; | 76 blink::WebLayerTreeView* initializeLayerTreeView() override; |
| 90 void scheduleAnimation() override; | 77 void scheduleAnimation() override; |
| 91 | 78 |
| 92 // WebFrameClient methods: | 79 // WebFrameClient methods: |
| 93 mojo::View* createChildFrame(const blink::WebURL& url) override; | 80 mojo::View* createChildFrame(const blink::WebURL& url) override; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 base::Closure destruction_callback_; | 121 base::Closure destruction_callback_; |
| 135 mojo::URLResponsePtr response_; | 122 mojo::URLResponsePtr response_; |
| 136 mojo::ServiceProviderImpl exported_services_; | 123 mojo::ServiceProviderImpl exported_services_; |
| 137 scoped_ptr<mojo::ServiceProvider> imported_services_; | 124 scoped_ptr<mojo::ServiceProvider> imported_services_; |
| 138 mojo::Shell* shell_; | 125 mojo::Shell* shell_; |
| 139 mojo::LazyInterfacePtr<mojo::NavigatorHost> navigator_host_; | 126 mojo::LazyInterfacePtr<mojo::NavigatorHost> navigator_host_; |
| 140 blink::WebView* web_view_; | 127 blink::WebView* web_view_; |
| 141 mojo::View* root_; | 128 mojo::View* root_; |
| 142 mojo::ViewManagerClientFactory view_manager_client_factory_; | 129 mojo::ViewManagerClientFactory view_manager_client_factory_; |
| 143 InspectorServiceFactory inspector_service_factory_; | 130 InspectorServiceFactory inspector_service_factory_; |
| 144 #if ENABLE_SKY_COMPOSITOR | |
| 145 scoped_ptr<LayerHost> layer_host_; | 131 scoped_ptr<LayerHost> layer_host_; |
| 146 scoped_refptr<Layer> root_layer_; | 132 scoped_refptr<Layer> root_layer_; |
| 147 #else | |
| 148 scoped_ptr<WebLayerTreeViewImpl> web_layer_tree_view_impl_; | |
| 149 #endif | |
| 150 scoped_refptr<base::MessageLoopProxy> compositor_thread_; | |
| 151 scoped_ptr<ScriptRunner> script_runner_; | 133 scoped_ptr<ScriptRunner> script_runner_; |
| 152 scoped_ptr<InspectorHostImpl> inspector_host_; | 134 scoped_ptr<InspectorHostImpl> inspector_host_; |
| 153 scoped_ptr<inspector::InspectorBackendMojo> inspector_backend_; | 135 scoped_ptr<inspector::InspectorBackendMojo> inspector_backend_; |
| 154 int debugger_id_; | 136 int debugger_id_; |
| 155 | 137 |
| 156 base::WeakPtrFactory<DocumentView> weak_factory_; | 138 base::WeakPtrFactory<DocumentView> weak_factory_; |
| 157 DISALLOW_COPY_AND_ASSIGN(DocumentView); | 139 DISALLOW_COPY_AND_ASSIGN(DocumentView); |
| 158 }; | 140 }; |
| 159 | 141 |
| 160 } // namespace sky | 142 } // namespace sky |
| 161 | 143 |
| 162 #endif // SKY_VIEWER_DOCUMENT_VIEW_H_ | 144 #endif // SKY_VIEWER_DOCUMENT_VIEW_H_ |
| OLD | NEW |