2 * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef CONTENT_BROWSER_RENDERER_HOST_RWHV_AURA_COMMON_HELPER_EFL_H_
18 #define CONTENT_BROWSER_RENDERER_HOST_RWHV_AURA_COMMON_HELPER_EFL_H_
22 #include "base/containers/id_map.h"
23 #include "content/common/cursors/webcursor.h"
24 #include "third_party/blink/public/common/input/web_gesture_event.h"
25 #include "third_party/blink/public/common/input/web_input_event.h"
26 #include "ui/base/ime/mojom/text_input_state.mojom-forward.h"
27 #include "ui/events/event.h"
28 #include "ui/gfx/geometry/size_f.h"
29 #include "ui/gfx/range/range.h"
31 #if BUILDFLAG(IS_TIZEN_TV)
32 #define DEFAULT_MAX_LENGTH std::numeric_limits<int>::max()
36 class EflEventHandler;
38 struct DidOverscrollParams;
43 typedef void (*Screenshot_Captured_Callback)(Evas_Object* image,
46 class ScreenshotCapturedCallback {
48 ScreenshotCapturedCallback(Screenshot_Captured_Callback func, void* user_data)
49 : func_(func), user_data_(user_data) {}
50 void Run(void* image) {
52 (func_)((Evas_Object*)image, user_data_);
56 Screenshot_Captured_Callback func_;
60 class RenderWidgetHostHelper;
61 class RenderWidgetHostImpl;
62 class RenderWidgetHostViewAura;
63 class SelectionControllerEfl;
65 class WebContentsDelegate;
67 class CONTENT_EXPORT RWHVAuraCommonHelperEfl {
69 RWHVAuraCommonHelperEfl(
70 RenderWidgetHostViewAura* rwhva, WebContents* web_contents);
71 virtual ~RWHVAuraCommonHelperEfl();
73 virtual void SetAuraParentWindow(gfx::NativeView parent_view) {}
74 virtual void AuraChildWindowAdded() {}
75 virtual void NotifySwap(const size_t texture_id) {}
76 virtual void DidGetContentSnapshot(const SkBitmap& bitmap, int request_id);
77 virtual void Show() {}
78 virtual void Hide() {}
79 virtual void Focus(bool focus) {}
80 virtual bool HasFocus() { return false; }
81 virtual gfx::Size GetVisibleViewportSize() { return gfx::Size(); }
82 virtual gfx::Size GetPhysicalBackingSize() const { return gfx::Size(); }
83 virtual void HandleGestureBegin() {}
84 virtual void HandleGestureEnd() {}
85 virtual void HandleGesture(blink::WebGestureEvent& event);
86 virtual void DidOverscroll(const ui::DidOverscrollParams& params);
87 virtual gfx::Rect GetViewBounds() { return gfx::Rect(); }
89 bool IsOffscreenMode() { return is_offscreen_mode_; }
90 Evas_Object* ewk_view() const;
91 SelectionControllerEfl* GetSelectionController() const {
92 return selection_controller_.get();
94 RenderWidgetHostImpl* GetRenderWidgetHostImpl();
95 gfx::NativeView GetNativeView();
96 WebContents* GetWebContents() { return web_contents_; }
97 void SetPageVisibility(bool visible);
99 void RequestSnapshotAsyncOnscreen(const gfx::Rect& snapshot_area,
100 Screenshot_Captured_Callback callback,
102 float scale_factor = 1.0);
105 void MoveCaret(const gfx::Point& point);
106 void SetScaledContentSize(const gfx::SizeF& size) {
107 scaled_contents_size_ = size;
109 gfx::Point ConvertPointInViewPix(gfx::Point point);
110 void SetCustomViewportSize(const gfx::Size& size);
111 bool HasSelectableText();
112 void set_magnifier(bool status) { magnifier_ = status; }
113 bool IsTouchstartConsumed() const { return touchstart_consumed_; }
114 bool IsTouchendConsumed() const { return touchend_consumed_; }
115 void SetTouchStartConsumed(bool touchstart_consumed) {
116 touchstart_consumed_ = touchstart_consumed;
118 void SetTouchEndConsumed(bool touchend_consumed) {
119 touchend_consumed_ = touchend_consumed;
121 void SetTouchEventsEnabled(bool enabled);
122 bool TouchEventsEnabled();
123 void SendMouseDown(int button, int x, int y);
124 void SendMouseUp(int button, int x, int y);
125 void SendMouseMove(int x, int y);
126 void SendMouseWheel(bool y_direction, int step, int x, int y);
128 bool IsFocusedNodeContentEditable() const { return is_content_editable_; }
130 void SetKeyEventsEnabled(bool enabled);
131 void SendKeyEvent(Evas_Object* ewk_view, void* key_event, bool is_press);
133 void OnMouseOrTouchEvent(ui::Event* event);
134 void FocusedNodeChanged(bool editable,
135 #if BUILDFLAG(IS_TIZEN_TV)
136 bool is_radio_or_checkbox,
137 int password_input_minlength,
140 bool is_content_editable);
142 #if BUILDFLAG(IS_TIZEN_TV)
143 //Browser edge scroll
144 void DidEdgeScrollBy(const gfx::Point& offset, bool handled);
145 void MoveFocusToBrowser(int direction);
146 void SetPopupMenuVisible(const bool visible);
147 void SetPopupMenuBounds(const gfx::Rect& popup_bounds);
148 void SetCursorByClient(bool enable) { cursor_set_by_client_ = enable; }
149 // notify track info to browser process
150 void NotifyTrackInfoToBrowser(int active_track_id,
151 const std::string& url,
152 const std::string& lang);
153 void SetPreferSubtitleLang(std::string lang_list);
154 void SetIMERecommendedWords(const std::string& recommended_words);
155 void SetIMERecommendedWordsType(bool should_enable);
156 void SetMouseEventsEnabled(bool enabled);
157 void SetTranslatedURL(const std::string& url);
158 void SetParentalRatingResult(const std::string& url, bool is_pass);
159 // notify web browser video playing status
160 void RequestVideoPlaying(int callback_id);
161 void VideoPlayingStatusReceived(bool is_playing, int callback_id);
162 void SetMouseEventCallbacks(
163 const base::RepeatingCallback<void(int, int)>& on_mouse_down,
164 const base::RepeatingCallback<bool(void)>& on_mouse_up,
165 const base::RepeatingCallback<void(void)>& on_mouse_move);
166 void MouseDownCallback(int x, int y);
167 bool MouseUpCallback();
168 void MouseMoveCallback();
171 void CompositingCompleteSwapWithNewSize(const gfx::Size& size) {
172 frame_data_output_size_ = size;
174 gfx::Size GetFrameDateOutputSize() { return frame_data_output_size_; }
175 void SetOrientation(int orientation) { rotation_ = orientation; }
176 int GetOrientation() { return rotation_; }
178 void OnGestureEvent(ui::GestureEvent* event);
179 void DidChangeInputType(bool is_password_field);
180 void BackgroundColorReceived(int callback_id, SkColor bg_color);
181 void OnGetFocusedNodeBounds(const gfx::RectF& rect);
182 void DidHandleKeyEvent(
183 blink::WebInputEvent::Type input_event_type, bool processed);
184 void SelectionChanged(
185 const std::u16string& text, size_t offset, const gfx::Range& range);
186 void OnGetMainFrameScrollbarVisible(int callback_id, bool visible);
187 void TextInputStateChanged(const ui::mojom::TextInputState& params);
188 void OnSelectionRectReceived(const gfx::Rect& selection_rect);
189 void UpdateTooltipUnderCursor(const std::u16string&);
192 void SetOffscreenMode() { is_offscreen_mode_ = true; }
193 RenderWidgetHostViewAura* rwhva() { return rwhv_aura_; }
194 ui::IMContextEfl* GetIMContextEfl();
196 void SendGestureEvent(blink::WebGestureEvent& event);
198 float device_scale_factor_ = 1.0f;
199 gfx::SizeF scaled_contents_size_;
200 gfx::Size custom_viewport_size_;
201 base::IDMap<std::unique_ptr<ScreenshotCapturedCallback>>
202 screen_capture_cb_map_;
204 gfx::Size frame_data_output_size_;
207 ui::EflEventHandler* GetEventHandler();
209 bool is_focused_node_editable_ = false;
210 bool is_scrolling_needed_ = false;
211 bool touchstart_consumed_ = false;
212 bool touchend_consumed_ = false;
214 ui::IMContextEfl* im_context_efl_ = nullptr;
215 RenderWidgetHostViewAura* rwhv_aura_ = nullptr;
216 WebContents* web_contents_ = nullptr;
217 std::unique_ptr<SelectionControllerEfl> selection_controller_;
219 bool magnifier_ = false;
220 bool is_content_editable_ = false;
221 bool is_offscreen_mode_ = false;
223 #if BUILDFLAG(IS_TIZEN_TV)
224 bool radio_or_checkbox_focused_ = false;
225 int password_input_minlength_ = -1;
226 int input_maxlength_ = DEFAULT_MAX_LENGTH;
228 // When WebBrowser sets their own cursor, set the flag
229 // not to set the WebPage cursor
230 bool cursor_set_by_client_ = false;
231 base::RepeatingCallback<void(int, int)> on_mouse_down_callback_;
232 base::RepeatingCallback<bool(void)> on_mouse_up_callback_;
233 base::RepeatingCallback<void(void)> on_mouse_move_callback_;
236 std::unique_ptr<RenderWidgetHostHelper> rwh_helper_;
238 RWHVAuraCommonHelperEfl(const RWHVAuraCommonHelperEfl&) = delete;
239 RWHVAuraCommonHelperEfl& operator=(const RWHVAuraCommonHelperEfl&) = delete;
242 } // namespace content
244 #endif // CONTENT_BROWSER_RENDERER_HOST_RWHV_AURA_COMMON_HELPER_EFL_H_