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