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"
16 class ApplicationImpl
;
23 namespace html_viewer
{
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.
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
{
43 HTMLWidgetRootRemote();
44 ~HTMLWidgetRootRemote() override
;
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
{
61 CreateParams(mojo::ApplicationImpl
* app
,
62 GlobalState
* global_state
,
66 mojo::ApplicationImpl
* app
;
67 GlobalState
* global_state
;
71 HTMLWidgetRootLocal(CreateParams
* create_params
);
72 ~HTMLWidgetRootLocal() override
;
74 blink::WebView
* web_view() { return web_view_
; }
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();
90 blink::WebWidget
* GetWidget() override
;
91 void OnViewBoundsChanged(mus::View
* view
) override
;
93 mojo::ApplicationImpl
* app_
;
94 GlobalState
* global_state_
;
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
{
106 HTMLWidgetLocalRoot(mojo::ApplicationImpl
* app
,
107 GlobalState
* global_state
,
109 blink::WebLocalFrame
* web_local_frame
);
110 ~HTMLWidgetLocalRoot() override
;
114 blink::WebWidget
* GetWidget() override
;
115 void OnViewBoundsChanged(mus::View
* view
) override
;
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_