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 COMPONENTS_HTML_VIEWER_HTML_WIDGET_H_ | 5 #ifndef COMPONENTS_HTML_VIEWER_HTML_WIDGET_H_ |
6 #define COMPONENTS_HTML_VIEWER_HTML_WIDGET_H_ | 6 #define COMPONENTS_HTML_VIEWER_HTML_WIDGET_H_ |
7 | 7 |
8 #include "third_party/WebKit/public/web/WebViewClient.h" | 8 #include "third_party/WebKit/public/web/WebViewClient.h" |
9 #include "third_party/WebKit/public/web/WebWidgetClient.h" | 9 #include "third_party/WebKit/public/web/WebWidgetClient.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 class WebFrameWidget; | 12 class WebFrameWidget; |
13 } | 13 } |
14 | 14 |
15 namespace mojo { | 15 namespace mojo { |
16 class ApplicationImpl; | 16 class ApplicationImpl; |
| 17 } |
| 18 |
| 19 namespace mus { |
17 class View; | 20 class View; |
18 } | 21 } |
19 | 22 |
20 namespace html_viewer { | 23 namespace html_viewer { |
21 | 24 |
22 class GlobalState; | 25 class GlobalState; |
23 class ImeController; | 26 class ImeController; |
24 class WebLayerTreeViewImpl; | 27 class WebLayerTreeViewImpl; |
25 | 28 |
26 // HTMLWidget is responsible for creation of the WebWidget. Which WebWidget | 29 // HTMLWidget is responsible for creation of the WebWidget. Which WebWidget |
27 // and how it is created depends upon the frame the WebWidget is created for. | 30 // and how it is created depends upon the frame the WebWidget is created for. |
28 class HTMLWidget { | 31 class HTMLWidget { |
29 public: | 32 public: |
30 virtual ~HTMLWidget() {} | 33 virtual ~HTMLWidget() {} |
31 | 34 |
32 virtual blink::WebWidget* GetWidget() = 0; | 35 virtual blink::WebWidget* GetWidget() = 0; |
33 | 36 |
34 virtual void OnViewBoundsChanged(mojo::View* view) = 0; | 37 virtual void OnViewBoundsChanged(mus::View* view) = 0; |
35 }; | 38 }; |
36 | 39 |
37 // Used for the root frame when the root frame is remote. | 40 // Used for the root frame when the root frame is remote. |
38 class HTMLWidgetRootRemote : public HTMLWidget { | 41 class HTMLWidgetRootRemote : public HTMLWidget { |
39 public: | 42 public: |
40 HTMLWidgetRootRemote(); | 43 HTMLWidgetRootRemote(); |
41 ~HTMLWidgetRootRemote() override; | 44 ~HTMLWidgetRootRemote() override; |
42 | 45 |
43 private: | 46 private: |
44 // HTMLWidget: | 47 // HTMLWidget: |
45 blink::WebWidget* GetWidget() override; | 48 blink::WebWidget* GetWidget() override; |
46 void OnViewBoundsChanged(mojo::View* view) override; | 49 void OnViewBoundsChanged(mus::View* view) override; |
47 | 50 |
48 blink::WebView* web_view_; | 51 blink::WebView* web_view_; |
49 | 52 |
50 DISALLOW_COPY_AND_ASSIGN(HTMLWidgetRootRemote); | 53 DISALLOW_COPY_AND_ASSIGN(HTMLWidgetRootRemote); |
51 }; | 54 }; |
52 | 55 |
53 // Used for the root frame when the frame is local. If there is only one | 56 // Used for the root frame when the frame is local. If there is only one |
54 // frame in the document, this is the HTMLWidget type created. | 57 // frame in the document, this is the HTMLWidget type created. |
55 class HTMLWidgetRootLocal : public HTMLWidget, public blink::WebViewClient { | 58 class HTMLWidgetRootLocal : public HTMLWidget, public blink::WebViewClient { |
56 public: | 59 public: |
57 struct CreateParams { | 60 struct CreateParams { |
58 CreateParams(mojo::ApplicationImpl* app, | 61 CreateParams(mojo::ApplicationImpl* app, |
59 GlobalState* global_state, | 62 GlobalState* global_state, |
60 mojo::View* view); | 63 mus::View* view); |
61 ~CreateParams(); | 64 ~CreateParams(); |
62 | 65 |
63 mojo::ApplicationImpl* app; | 66 mojo::ApplicationImpl* app; |
64 GlobalState* global_state; | 67 GlobalState* global_state; |
65 mojo::View* view; | 68 mus::View* view; |
66 }; | 69 }; |
67 | 70 |
68 HTMLWidgetRootLocal(CreateParams* create_params); | 71 HTMLWidgetRootLocal(CreateParams* create_params); |
69 ~HTMLWidgetRootLocal() override; | 72 ~HTMLWidgetRootLocal() override; |
70 | 73 |
71 blink::WebView* web_view() { return web_view_; } | 74 blink::WebView* web_view() { return web_view_; } |
72 | 75 |
73 protected: | 76 protected: |
74 // WebViewClient methods: | 77 // WebViewClient methods: |
75 virtual blink::WebStorageNamespace* createSessionStorageNamespace(); | 78 virtual blink::WebStorageNamespace* createSessionStorageNamespace(); |
76 virtual void initializeLayerTreeView(); | 79 virtual void initializeLayerTreeView(); |
77 virtual blink::WebLayerTreeView* layerTreeView(); | 80 virtual blink::WebLayerTreeView* layerTreeView(); |
78 virtual void didFirstVisuallyNonEmptyLayout(); | 81 virtual void didFirstVisuallyNonEmptyLayout(); |
79 virtual void resetInputMethod(); | 82 virtual void resetInputMethod(); |
80 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event, | 83 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event, |
81 bool event_cancelled); | 84 bool event_cancelled); |
82 virtual void didUpdateTextOfFocusedElementByNonUserInput(); | 85 virtual void didUpdateTextOfFocusedElementByNonUserInput(); |
83 virtual void showImeIfNeeded(); | 86 virtual void showImeIfNeeded(); |
84 | 87 |
85 private: | 88 private: |
86 // HTMLWidget: | 89 // HTMLWidget: |
87 blink::WebWidget* GetWidget() override; | 90 blink::WebWidget* GetWidget() override; |
88 void OnViewBoundsChanged(mojo::View* view) override; | 91 void OnViewBoundsChanged(mus::View* view) override; |
89 | 92 |
90 mojo::ApplicationImpl* app_; | 93 mojo::ApplicationImpl* app_; |
91 GlobalState* global_state_; | 94 GlobalState* global_state_; |
92 mojo::View* view_; | 95 mus::View* view_; |
93 blink::WebView* web_view_; | 96 blink::WebView* web_view_; |
94 scoped_ptr<WebLayerTreeViewImpl> web_layer_tree_view_impl_; | 97 scoped_ptr<WebLayerTreeViewImpl> web_layer_tree_view_impl_; |
95 scoped_ptr<ImeController> ime_controller_; | 98 scoped_ptr<ImeController> ime_controller_; |
96 | 99 |
97 DISALLOW_COPY_AND_ASSIGN(HTMLWidgetRootLocal); | 100 DISALLOW_COPY_AND_ASSIGN(HTMLWidgetRootLocal); |
98 }; | 101 }; |
99 | 102 |
100 // Used for frames other than the root that are local. | 103 // Used for frames other than the root that are local. |
101 class HTMLWidgetLocalRoot : public HTMLWidget, public blink::WebWidgetClient { | 104 class HTMLWidgetLocalRoot : public HTMLWidget, public blink::WebWidgetClient { |
102 public: | 105 public: |
103 HTMLWidgetLocalRoot(mojo::ApplicationImpl* app, | 106 HTMLWidgetLocalRoot(mojo::ApplicationImpl* app, |
104 GlobalState* global_state, | 107 GlobalState* global_state, |
105 mojo::View* view, | 108 mus::View* view, |
106 blink::WebLocalFrame* web_local_frame); | 109 blink::WebLocalFrame* web_local_frame); |
107 ~HTMLWidgetLocalRoot() override; | 110 ~HTMLWidgetLocalRoot() override; |
108 | 111 |
109 private: | 112 private: |
110 // HTMLWidget: | 113 // HTMLWidget: |
111 blink::WebWidget* GetWidget() override; | 114 blink::WebWidget* GetWidget() override; |
112 void OnViewBoundsChanged(mojo::View* view) override; | 115 void OnViewBoundsChanged(mus::View* view) override; |
113 | 116 |
114 // WebWidgetClient: | 117 // WebWidgetClient: |
115 virtual void initializeLayerTreeView(); | 118 virtual void initializeLayerTreeView(); |
116 virtual blink::WebLayerTreeView* layerTreeView(); | 119 virtual blink::WebLayerTreeView* layerTreeView(); |
117 virtual void resetInputMethod(); | 120 virtual void resetInputMethod(); |
118 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event, | 121 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event, |
119 bool event_cancelled); | 122 bool event_cancelled); |
120 virtual void didUpdateTextOfFocusedElementByNonUserInput(); | 123 virtual void didUpdateTextOfFocusedElementByNonUserInput(); |
121 virtual void showImeIfNeeded(); | 124 virtual void showImeIfNeeded(); |
122 | 125 |
123 mojo::ApplicationImpl* app_; | 126 mojo::ApplicationImpl* app_; |
124 GlobalState* global_state_; | 127 GlobalState* global_state_; |
125 blink::WebFrameWidget* web_frame_widget_; | 128 blink::WebFrameWidget* web_frame_widget_; |
126 scoped_ptr<WebLayerTreeViewImpl> web_layer_tree_view_impl_; | 129 scoped_ptr<WebLayerTreeViewImpl> web_layer_tree_view_impl_; |
127 scoped_ptr<ImeController> ime_controller_; | 130 scoped_ptr<ImeController> ime_controller_; |
128 | 131 |
129 DISALLOW_COPY_AND_ASSIGN(HTMLWidgetLocalRoot); | 132 DISALLOW_COPY_AND_ASSIGN(HTMLWidgetLocalRoot); |
130 }; | 133 }; |
131 | 134 |
132 } // namespace html_viewer | 135 } // namespace html_viewer |
133 | 136 |
134 #endif // COMPONENTS_HTML_VIEWER_HTML_WIDGET_H_ | 137 #endif // COMPONENTS_HTML_VIEWER_HTML_WIDGET_H_ |
OLD | NEW |