| 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 resetInputMethod(); | 81 virtual void resetInputMethod(); |
| 79 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event, | 82 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event, |
| 80 bool event_cancelled); | 83 bool event_cancelled); |
| 81 virtual void didUpdateTextOfFocusedElementByNonUserInput(); | 84 virtual void didUpdateTextOfFocusedElementByNonUserInput(); |
| 82 virtual void showImeIfNeeded(); | 85 virtual void showImeIfNeeded(); |
| 83 | 86 |
| 84 private: | 87 private: |
| 85 // HTMLWidget: | 88 // HTMLWidget: |
| 86 blink::WebWidget* GetWidget() override; | 89 blink::WebWidget* GetWidget() override; |
| 87 void OnViewBoundsChanged(mojo::View* view) override; | 90 void OnViewBoundsChanged(mus::View* view) override; |
| 88 | 91 |
| 89 mojo::ApplicationImpl* app_; | 92 mojo::ApplicationImpl* app_; |
| 90 GlobalState* global_state_; | 93 GlobalState* global_state_; |
| 91 mojo::View* view_; | 94 mus::View* view_; |
| 92 blink::WebView* web_view_; | 95 blink::WebView* web_view_; |
| 93 scoped_ptr<WebLayerTreeViewImpl> web_layer_tree_view_impl_; | 96 scoped_ptr<WebLayerTreeViewImpl> web_layer_tree_view_impl_; |
| 94 scoped_ptr<ImeController> ime_controller_; | 97 scoped_ptr<ImeController> ime_controller_; |
| 95 | 98 |
| 96 DISALLOW_COPY_AND_ASSIGN(HTMLWidgetRootLocal); | 99 DISALLOW_COPY_AND_ASSIGN(HTMLWidgetRootLocal); |
| 97 }; | 100 }; |
| 98 | 101 |
| 99 // Used for frames other than the root that are local. | 102 // Used for frames other than the root that are local. |
| 100 class HTMLWidgetLocalRoot : public HTMLWidget, public blink::WebWidgetClient { | 103 class HTMLWidgetLocalRoot : public HTMLWidget, public blink::WebWidgetClient { |
| 101 public: | 104 public: |
| 102 HTMLWidgetLocalRoot(mojo::ApplicationImpl* app, | 105 HTMLWidgetLocalRoot(mojo::ApplicationImpl* app, |
| 103 GlobalState* global_state, | 106 GlobalState* global_state, |
| 104 mojo::View* view, | 107 mus::View* view, |
| 105 blink::WebLocalFrame* web_local_frame); | 108 blink::WebLocalFrame* web_local_frame); |
| 106 ~HTMLWidgetLocalRoot() override; | 109 ~HTMLWidgetLocalRoot() override; |
| 107 | 110 |
| 108 private: | 111 private: |
| 109 // HTMLWidget: | 112 // HTMLWidget: |
| 110 blink::WebWidget* GetWidget() override; | 113 blink::WebWidget* GetWidget() override; |
| 111 void OnViewBoundsChanged(mojo::View* view) override; | 114 void OnViewBoundsChanged(mus::View* view) override; |
| 112 | 115 |
| 113 // WebWidgetClient: | 116 // WebWidgetClient: |
| 114 virtual void initializeLayerTreeView(); | 117 virtual void initializeLayerTreeView(); |
| 115 virtual blink::WebLayerTreeView* layerTreeView(); | 118 virtual blink::WebLayerTreeView* layerTreeView(); |
| 116 virtual void resetInputMethod(); | 119 virtual void resetInputMethod(); |
| 117 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event, | 120 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event, |
| 118 bool event_cancelled); | 121 bool event_cancelled); |
| 119 virtual void didUpdateTextOfFocusedElementByNonUserInput(); | 122 virtual void didUpdateTextOfFocusedElementByNonUserInput(); |
| 120 virtual void showImeIfNeeded(); | 123 virtual void showImeIfNeeded(); |
| 121 | 124 |
| 122 mojo::ApplicationImpl* app_; | 125 mojo::ApplicationImpl* app_; |
| 123 GlobalState* global_state_; | 126 GlobalState* global_state_; |
| 124 blink::WebFrameWidget* web_frame_widget_; | 127 blink::WebFrameWidget* web_frame_widget_; |
| 125 scoped_ptr<WebLayerTreeViewImpl> web_layer_tree_view_impl_; | 128 scoped_ptr<WebLayerTreeViewImpl> web_layer_tree_view_impl_; |
| 126 scoped_ptr<ImeController> ime_controller_; | 129 scoped_ptr<ImeController> ime_controller_; |
| 127 | 130 |
| 128 DISALLOW_COPY_AND_ASSIGN(HTMLWidgetLocalRoot); | 131 DISALLOW_COPY_AND_ASSIGN(HTMLWidgetLocalRoot); |
| 129 }; | 132 }; |
| 130 | 133 |
| 131 } // namespace html_viewer | 134 } // namespace html_viewer |
| 132 | 135 |
| 133 #endif // COMPONENTS_HTML_VIEWER_HTML_WIDGET_H_ | 136 #endif // COMPONENTS_HTML_VIEWER_HTML_WIDGET_H_ |
| OLD | NEW |