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/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
9 #include "mojo/public/cpp/application/lazy_interface_ptr.h" | 10 #include "mojo/public/cpp/application/lazy_interface_ptr.h" |
10 #include "mojo/public/cpp/application/service_provider_impl.h" | 11 #include "mojo/public/cpp/application/service_provider_impl.h" |
11 #include "mojo/public/cpp/bindings/interface_impl.h" | 12 #include "mojo/public/cpp/bindings/interface_impl.h" |
12 #include "mojo/public/interfaces/application/application.mojom.h" | 13 #include "mojo/public/interfaces/application/application.mojom.h" |
13 #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" |
14 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" | 15 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" |
15 #include "mojo/services/public/cpp/view_manager/view_observer.h" | 16 #include "mojo/services/public/cpp/view_manager/view_observer.h" |
16 #include "mojo/services/public/interfaces/content_handler/content_handler.mojom.
h" | 17 #include "mojo/services/public/interfaces/content_handler/content_handler.mojom.
h" |
17 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h" | 18 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h" |
(...skipping 21 matching lines...) Expand all Loading... |
39 class InspectorBackendMojo; | 40 class InspectorBackendMojo; |
40 } | 41 } |
41 | 42 |
42 namespace sky { | 43 namespace sky { |
43 class InspectorHostImpl; | 44 class InspectorHostImpl; |
44 class ScriptRunner; | 45 class ScriptRunner; |
45 class Layer; | 46 class Layer; |
46 class LayerHost; | 47 class LayerHost; |
47 class WebLayerTreeViewImpl; | 48 class WebLayerTreeViewImpl; |
48 | 49 |
49 class DocumentView : public mojo::InterfaceImpl<mojo::Application>, | 50 class DocumentView : public blink::ServiceProvider, |
50 public blink::ServiceProvider, | |
51 public blink::WebViewClient, | 51 public blink::WebViewClient, |
52 public blink::WebFrameClient, | 52 public blink::WebFrameClient, |
53 #if ENABLE_SKY_COMPOSITOR | 53 #if ENABLE_SKY_COMPOSITOR |
54 public sky::LayerClient, | 54 public sky::LayerClient, |
55 public sky::LayerHostClient, | 55 public sky::LayerHostClient, |
56 #endif | 56 #endif |
57 public mojo::ViewManagerDelegate, | 57 public mojo::ViewManagerDelegate, |
58 public mojo::ViewObserver { | 58 public mojo::ViewObserver { |
59 public: | 59 public: |
60 DocumentView(mojo::URLResponsePtr response, | 60 DocumentView(const base::Closure& destruction_callback, |
61 mojo::ShellPtr shell, | 61 mojo::ServiceProviderPtr provider, |
| 62 mojo::URLResponsePtr response, |
| 63 mojo::Shell* shell, |
62 scoped_refptr<base::MessageLoopProxy> compositor_thread); | 64 scoped_refptr<base::MessageLoopProxy> compositor_thread); |
63 virtual ~DocumentView(); | 65 virtual ~DocumentView(); |
64 | 66 |
65 base::WeakPtr<DocumentView> GetWeakPtr(); | 67 base::WeakPtr<DocumentView> GetWeakPtr(); |
66 | 68 |
67 blink::WebView* web_view() const { return web_view_; } | 69 blink::WebView* web_view() const { return web_view_; } |
68 mojo::ServiceProvider* imported_services() const { | 70 mojo::ServiceProvider* imported_services() const { |
69 return imported_services_.get(); | 71 return imported_services_.get(); |
70 } | 72 } |
71 | 73 |
72 mojo::Shell* shell() const { return shell_.get(); } | 74 mojo::Shell* shell() const { return shell_; } |
73 | 75 |
74 #if ENABLE_SKY_COMPOSITOR | 76 #if ENABLE_SKY_COMPOSITOR |
75 // sky::LayerHostClient | 77 // sky::LayerHostClient |
76 mojo::Shell* GetShell() override; | 78 mojo::Shell* GetShell() override; |
77 void BeginFrame(base::TimeTicks frame_time) override; | 79 void BeginFrame(base::TimeTicks frame_time) override; |
78 void OnSurfaceIdAvailable(mojo::SurfaceIdPtr surface_id) override; | 80 void OnSurfaceIdAvailable(mojo::SurfaceIdPtr surface_id) override; |
79 // sky::LayerClient | 81 // sky::LayerClient |
80 void PaintContents(SkCanvas* canvas, const gfx::Rect& clip) override; | 82 void PaintContents(SkCanvas* canvas, const gfx::Rect& clip) override; |
81 #endif // ENABLE_SKY_COMPOSITOR | 83 #endif // ENABLE_SKY_COMPOSITOR |
82 | 84 |
83 void StartDebuggerInspectorBackend(); | 85 void StartDebuggerInspectorBackend(); |
84 | 86 |
85 private: | 87 private: |
86 // Application methods: | |
87 void AcceptConnection(const mojo::String& requestor_url, | |
88 mojo::ServiceProviderPtr provider) override; | |
89 void Initialize(mojo::Array<mojo::String> args) override; | |
90 | |
91 // WebWidgetClient methods: | 88 // WebWidgetClient methods: |
92 blink::WebLayerTreeView* initializeLayerTreeView() override; | 89 blink::WebLayerTreeView* initializeLayerTreeView() override; |
93 void scheduleAnimation() override; | 90 void scheduleAnimation() override; |
94 | 91 |
95 // WebFrameClient methods: | 92 // WebFrameClient methods: |
96 mojo::View* createChildFrame(const blink::WebURL& url) override; | 93 mojo::View* createChildFrame(const blink::WebURL& url) override; |
97 void frameDetached(blink::WebFrame*) override; | 94 void frameDetached(blink::WebFrame*) override; |
98 blink::WebNavigationPolicy decidePolicyForNavigation( | 95 blink::WebNavigationPolicy decidePolicyForNavigation( |
99 const blink::WebFrameClient::NavigationPolicyInfo& info) override; | 96 const blink::WebFrameClient::NavigationPolicyInfo& info) override; |
100 void didAddMessageToConsole( | 97 void didAddMessageToConsole( |
(...skipping 26 matching lines...) Expand all Loading... |
127 void OnViewBoundsChanged(mojo::View* view, | 124 void OnViewBoundsChanged(mojo::View* view, |
128 const mojo::Rect& old_bounds, | 125 const mojo::Rect& old_bounds, |
129 const mojo::Rect& new_bounds) override; | 126 const mojo::Rect& new_bounds) override; |
130 void OnViewFocusChanged(mojo::View* gained_focus, | 127 void OnViewFocusChanged(mojo::View* gained_focus, |
131 mojo::View* lost_focus) override; | 128 mojo::View* lost_focus) override; |
132 void OnViewDestroyed(mojo::View* view) override; | 129 void OnViewDestroyed(mojo::View* view) override; |
133 void OnViewInputEvent(mojo::View* view, const mojo::EventPtr& event) override; | 130 void OnViewInputEvent(mojo::View* view, const mojo::EventPtr& event) override; |
134 | 131 |
135 void Load(mojo::URLResponsePtr response); | 132 void Load(mojo::URLResponsePtr response); |
136 | 133 |
| 134 base::Closure destruction_callback_; |
137 mojo::URLResponsePtr response_; | 135 mojo::URLResponsePtr response_; |
138 mojo::ServiceProviderImpl exported_services_; | 136 mojo::ServiceProviderImpl exported_services_; |
139 scoped_ptr<mojo::ServiceProvider> imported_services_; | 137 scoped_ptr<mojo::ServiceProvider> imported_services_; |
140 mojo::ShellPtr shell_; | 138 mojo::Shell* shell_; |
141 mojo::LazyInterfacePtr<mojo::NavigatorHost> navigator_host_; | 139 mojo::LazyInterfacePtr<mojo::NavigatorHost> navigator_host_; |
142 blink::WebView* web_view_; | 140 blink::WebView* web_view_; |
143 mojo::View* root_; | 141 mojo::View* root_; |
144 mojo::ViewManagerClientFactory view_manager_client_factory_; | 142 mojo::ViewManagerClientFactory view_manager_client_factory_; |
145 InspectorServiceFactory inspector_service_factory_; | 143 InspectorServiceFactory inspector_service_factory_; |
146 #if ENABLE_SKY_COMPOSITOR | 144 #if ENABLE_SKY_COMPOSITOR |
147 scoped_ptr<LayerHost> layer_host_; | 145 scoped_ptr<LayerHost> layer_host_; |
148 scoped_refptr<Layer> root_layer_; | 146 scoped_refptr<Layer> root_layer_; |
149 #else | 147 #else |
150 scoped_ptr<WebLayerTreeViewImpl> web_layer_tree_view_impl_; | 148 scoped_ptr<WebLayerTreeViewImpl> web_layer_tree_view_impl_; |
151 #endif | 149 #endif |
152 scoped_refptr<base::MessageLoopProxy> compositor_thread_; | 150 scoped_refptr<base::MessageLoopProxy> compositor_thread_; |
153 scoped_ptr<ScriptRunner> script_runner_; | 151 scoped_ptr<ScriptRunner> script_runner_; |
154 scoped_ptr<InspectorHostImpl> inspector_host_; | 152 scoped_ptr<InspectorHostImpl> inspector_host_; |
155 scoped_ptr<inspector::InspectorBackendMojo> inspector_backend_; | 153 scoped_ptr<inspector::InspectorBackendMojo> inspector_backend_; |
156 int debugger_id_; | 154 int debugger_id_; |
157 | 155 |
158 base::WeakPtrFactory<DocumentView> weak_factory_; | 156 base::WeakPtrFactory<DocumentView> weak_factory_; |
159 DISALLOW_COPY_AND_ASSIGN(DocumentView); | 157 DISALLOW_COPY_AND_ASSIGN(DocumentView); |
160 }; | 158 }; |
161 | 159 |
162 } // namespace sky | 160 } // namespace sky |
163 | 161 |
164 #endif // SKY_VIEWER_DOCUMENT_VIEW_H_ | 162 #endif // SKY_VIEWER_DOCUMENT_VIEW_H_ |
OLD | NEW |