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/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
9 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
10 #include "mojo/public/cpp/application/lazy_interface_ptr.h" | 11 #include "mojo/public/cpp/application/lazy_interface_ptr.h" |
11 #include "mojo/public/cpp/application/service_provider_impl.h" | 12 #include "mojo/public/cpp/application/service_provider_impl.h" |
12 #include "mojo/public/cpp/bindings/interface_impl.h" | 13 #include "mojo/public/cpp/bindings/interface_impl.h" |
13 #include "mojo/public/interfaces/application/application.mojom.h" | 14 #include "mojo/public/interfaces/application/application.mojom.h" |
14 #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h" | 15 #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h" |
15 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" | 16 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" |
16 #include "mojo/services/public/cpp/view_manager/view_observer.h" | 17 #include "mojo/services/public/cpp/view_manager/view_observer.h" |
17 #include "mojo/services/public/interfaces/content_handler/content_handler.mojom.
h" | 18 #include "mojo/services/public/interfaces/content_handler/content_handler.mojom.
h" |
(...skipping 10 matching lines...) Expand all Loading... |
28 | 29 |
29 namespace mojo { | 30 namespace mojo { |
30 class ViewManager; | 31 class ViewManager; |
31 class View; | 32 class View; |
32 } | 33 } |
33 | 34 |
34 namespace sky { | 35 namespace sky { |
35 class ScriptRunner; | 36 class ScriptRunner; |
36 class WebLayerTreeViewImpl; | 37 class WebLayerTreeViewImpl; |
37 | 38 |
38 class DocumentView : public mojo::InterfaceImpl<mojo::Application>, | 39 class DocumentView : public blink::ServiceProvider, |
39 public blink::ServiceProvider, | |
40 public blink::WebViewClient, | 40 public blink::WebViewClient, |
41 public blink::WebFrameClient, | 41 public blink::WebFrameClient, |
42 public mojo::ViewManagerDelegate, | 42 public mojo::ViewManagerDelegate, |
43 public mojo::ViewObserver { | 43 public mojo::ViewObserver { |
44 public: | 44 public: |
45 // Load a new HTMLDocument with |response|. | 45 // Load a new HTMLDocument with |response|. |
46 // | 46 // |
47 // |shell| is the Shell connection for this mojo::Application. | 47 // |shell| is the Shell connection for this mojo::Application. |
48 DocumentView(mojo::URLResponsePtr response, | 48 DocumentView(const base::Closure& destruction_callback, |
49 mojo::ShellPtr shell, | 49 mojo::ServiceProviderPtr provider, |
| 50 mojo::URLResponsePtr response, |
| 51 mojo::Shell* shell, |
50 scoped_refptr<base::MessageLoopProxy> compositor_thread); | 52 scoped_refptr<base::MessageLoopProxy> compositor_thread); |
51 virtual ~DocumentView(); | 53 virtual ~DocumentView(); |
52 | 54 |
53 base::WeakPtr<DocumentView> GetWeakPtr(); | 55 base::WeakPtr<DocumentView> GetWeakPtr(); |
54 | 56 |
55 blink::WebView* web_view() const { return web_view_; } | 57 blink::WebView* web_view() const { return web_view_; } |
56 mojo::ServiceProvider* imported_services() const { | 58 mojo::ServiceProvider* imported_services() const { |
57 return imported_services_.get(); | 59 return imported_services_.get(); |
58 } | 60 } |
59 | 61 |
60 mojo::Shell* shell() const { return shell_.get(); } | 62 mojo::Shell* shell() const { return shell_; } |
61 | 63 |
62 private: | 64 private: |
63 // Application methods: | |
64 void AcceptConnection(const mojo::String& requestor_url, | |
65 mojo::ServiceProviderPtr provider) override; | |
66 void Initialize(mojo::Array<mojo::String> args) override; | |
67 | |
68 // WebWidgetClient methods: | 65 // WebWidgetClient methods: |
69 virtual blink::WebLayerTreeView* initializeLayerTreeView(); | 66 virtual blink::WebLayerTreeView* initializeLayerTreeView(); |
70 | 67 |
71 // WebFrameClient methods: | 68 // WebFrameClient methods: |
72 mojo::View* createChildFrame(const blink::WebURL& url) override; | 69 mojo::View* createChildFrame(const blink::WebURL& url) override; |
73 void frameDetached(blink::WebFrame*) override; | 70 void frameDetached(blink::WebFrame*) override; |
74 blink::WebNavigationPolicy decidePolicyForNavigation( | 71 blink::WebNavigationPolicy decidePolicyForNavigation( |
75 const blink::WebFrameClient::NavigationPolicyInfo& info) override; | 72 const blink::WebFrameClient::NavigationPolicyInfo& info) override; |
76 void didAddMessageToConsole( | 73 void didAddMessageToConsole( |
77 const blink::WebConsoleMessage& message, | 74 const blink::WebConsoleMessage& message, |
(...skipping 24 matching lines...) Expand all Loading... |
102 void OnViewBoundsChanged(mojo::View* view, | 99 void OnViewBoundsChanged(mojo::View* view, |
103 const mojo::Rect& old_bounds, | 100 const mojo::Rect& old_bounds, |
104 const mojo::Rect& new_bounds) override; | 101 const mojo::Rect& new_bounds) override; |
105 void OnViewFocusChanged(mojo::View* gained_focus, | 102 void OnViewFocusChanged(mojo::View* gained_focus, |
106 mojo::View* lost_focus) override; | 103 mojo::View* lost_focus) override; |
107 void OnViewDestroyed(mojo::View* view) override; | 104 void OnViewDestroyed(mojo::View* view) override; |
108 void OnViewInputEvent(mojo::View* view, const mojo::EventPtr& event) override; | 105 void OnViewInputEvent(mojo::View* view, const mojo::EventPtr& event) override; |
109 | 106 |
110 void Load(mojo::URLResponsePtr response); | 107 void Load(mojo::URLResponsePtr response); |
111 | 108 |
| 109 base::Closure destruction_callback_; |
112 mojo::URLResponsePtr response_; | 110 mojo::URLResponsePtr response_; |
113 mojo::ServiceProviderImpl exported_services_; | 111 mojo::ServiceProviderImpl exported_services_; |
114 scoped_ptr<mojo::ServiceProvider> imported_services_; | 112 scoped_ptr<mojo::ServiceProvider> imported_services_; |
115 mojo::ShellPtr shell_; | 113 mojo::Shell* shell_; |
116 mojo::LazyInterfacePtr<mojo::NavigatorHost> navigator_host_; | 114 mojo::LazyInterfacePtr<mojo::NavigatorHost> navigator_host_; |
117 blink::WebView* web_view_; | 115 blink::WebView* web_view_; |
118 mojo::View* root_; | 116 mojo::View* root_; |
119 mojo::ViewManagerClientFactory view_manager_client_factory_; | 117 mojo::ViewManagerClientFactory view_manager_client_factory_; |
120 InspectorServiceFactory inspector_service_factory_; | 118 InspectorServiceFactory inspector_service_factory_; |
121 scoped_ptr<WebLayerTreeViewImpl> web_layer_tree_view_impl_; | 119 scoped_ptr<WebLayerTreeViewImpl> web_layer_tree_view_impl_; |
122 scoped_refptr<base::MessageLoopProxy> compositor_thread_; | 120 scoped_refptr<base::MessageLoopProxy> compositor_thread_; |
123 scoped_ptr<ScriptRunner> script_runner_; | 121 scoped_ptr<ScriptRunner> script_runner_; |
124 | 122 |
125 base::WeakPtrFactory<DocumentView> weak_factory_; | 123 base::WeakPtrFactory<DocumentView> weak_factory_; |
126 DISALLOW_COPY_AND_ASSIGN(DocumentView); | 124 DISALLOW_COPY_AND_ASSIGN(DocumentView); |
127 }; | 125 }; |
128 | 126 |
129 } // namespace sky | 127 } // namespace sky |
130 | 128 |
131 #endif // SKY_VIEWER_DOCUMENT_VIEW_H_ | 129 #endif // SKY_VIEWER_DOCUMENT_VIEW_H_ |
OLD | NEW |