Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / html_viewer / html_widget.h
blob37074ce1c7ab25a65d848ade5dbf12bd6da260e1
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_HTML_VIEWER_HTML_WIDGET_H_
6 #define COMPONENTS_HTML_VIEWER_HTML_WIDGET_H_
8 #include "third_party/WebKit/public/web/WebViewClient.h"
9 #include "third_party/WebKit/public/web/WebWidgetClient.h"
11 namespace blink {
12 class WebFrameWidget;
15 namespace mojo {
16 class ApplicationImpl;
19 namespace mus {
20 class View;
23 namespace html_viewer {
25 class GlobalState;
26 class ImeController;
27 class WebLayerTreeViewImpl;
29 // 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.
31 class HTMLWidget {
32 public:
33 virtual ~HTMLWidget() {}
35 virtual blink::WebWidget* GetWidget() = 0;
37 virtual void OnViewBoundsChanged(mus::View* view) = 0;
40 // Used for the root frame when the root frame is remote.
41 class HTMLWidgetRootRemote : public HTMLWidget {
42 public:
43 HTMLWidgetRootRemote();
44 ~HTMLWidgetRootRemote() override;
46 private:
47 // HTMLWidget:
48 blink::WebWidget* GetWidget() override;
49 void OnViewBoundsChanged(mus::View* view) override;
51 blink::WebView* web_view_;
53 DISALLOW_COPY_AND_ASSIGN(HTMLWidgetRootRemote);
56 // 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.
58 class HTMLWidgetRootLocal : public HTMLWidget, public blink::WebViewClient {
59 public:
60 struct CreateParams {
61 CreateParams(mojo::ApplicationImpl* app,
62 GlobalState* global_state,
63 mus::View* view);
64 ~CreateParams();
66 mojo::ApplicationImpl* app;
67 GlobalState* global_state;
68 mus::View* view;
71 HTMLWidgetRootLocal(CreateParams* create_params);
72 ~HTMLWidgetRootLocal() override;
74 blink::WebView* web_view() { return web_view_; }
76 protected:
77 // WebViewClient methods:
78 virtual blink::WebStorageNamespace* createSessionStorageNamespace();
79 virtual void initializeLayerTreeView();
80 virtual blink::WebLayerTreeView* layerTreeView();
81 virtual void didFirstVisuallyNonEmptyLayout();
82 virtual void resetInputMethod();
83 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event,
84 bool event_cancelled);
85 virtual void didUpdateTextOfFocusedElementByNonUserInput();
86 virtual void showImeIfNeeded();
88 private:
89 // HTMLWidget:
90 blink::WebWidget* GetWidget() override;
91 void OnViewBoundsChanged(mus::View* view) override;
93 mojo::ApplicationImpl* app_;
94 GlobalState* global_state_;
95 mus::View* view_;
96 blink::WebView* web_view_;
97 scoped_ptr<WebLayerTreeViewImpl> web_layer_tree_view_impl_;
98 scoped_ptr<ImeController> ime_controller_;
100 DISALLOW_COPY_AND_ASSIGN(HTMLWidgetRootLocal);
103 // Used for frames other than the root that are local.
104 class HTMLWidgetLocalRoot : public HTMLWidget, public blink::WebWidgetClient {
105 public:
106 HTMLWidgetLocalRoot(mojo::ApplicationImpl* app,
107 GlobalState* global_state,
108 mus::View* view,
109 blink::WebLocalFrame* web_local_frame);
110 ~HTMLWidgetLocalRoot() override;
112 private:
113 // HTMLWidget:
114 blink::WebWidget* GetWidget() override;
115 void OnViewBoundsChanged(mus::View* view) override;
117 // WebWidgetClient:
118 virtual void initializeLayerTreeView();
119 virtual blink::WebLayerTreeView* layerTreeView();
120 virtual void resetInputMethod();
121 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event,
122 bool event_cancelled);
123 virtual void didUpdateTextOfFocusedElementByNonUserInput();
124 virtual void showImeIfNeeded();
126 mojo::ApplicationImpl* app_;
127 GlobalState* global_state_;
128 blink::WebFrameWidget* web_frame_widget_;
129 scoped_ptr<WebLayerTreeViewImpl> web_layer_tree_view_impl_;
130 scoped_ptr<ImeController> ime_controller_;
132 DISALLOW_COPY_AND_ASSIGN(HTMLWidgetLocalRoot);
135 } // namespace html_viewer
137 #endif // COMPONENTS_HTML_VIEWER_HTML_WIDGET_H_