[M108 Migration][VD] Fix FocusInOutCallbacks not handled issue
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / efl_integration / eweb_view.h
1 // Copyright 2014 Samsung Electronics. 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.
4
5 #ifndef EWEB_VIEW_H
6 #define EWEB_VIEW_H
7
8 #include <map>
9 #include <string>
10 #include <Evas.h>
11 #include <locale.h>
12 #include <vector>
13
14 #include "base/callback.h"
15 #include "base/containers/id_map.h"
16 #include "base/synchronization/waitable_event.h"
17 #include "browser/input_picker/input_picker.h"
18 #include "content/browser/renderer_host/event_with_latency_info.h"
19 #include "content/browser/select_picker/select_picker_base.h"
20 #include "content/browser/selection/selection_controller_efl.h"
21 #include "content/browser/web_contents/web_contents_view_aura.h"
22 #include "content/browser/web_contents/web_contents_view_aura_helper_efl.h"
23 #include "content/public/browser/context_menu_params.h"
24 #include "content/public/browser/navigation_controller.h"
25 #include "content/public/browser/quota_permission_context.h"
26 #include "content/public/browser/web_contents_delegate.h"
27 #include "content/public/browser/web_contents_efl_delegate.h"
28 #include "content/public/common/input_event_ack_state.h"
29 #include "content_browser_client_efl.h"
30 #include "context_menu_controller_efl.h"
31 #include "eweb_context.h"
32 #include "eweb_view_callbacks.h"
33 #include "file_chooser_controller_efl.h"
34 #include "permission_popup_manager.h"
35 #include "popup_controller_efl.h"
36 #include "private/ewk_auth_challenge_private.h"
37 #include "private/ewk_back_forward_list_private.h"
38 #include "private/ewk_history_private.h"
39 #include "private/ewk_hit_test_private.h"
40 #include "private/ewk_settings_private.h"
41 #include "private/ewk_web_application_icon_data_private.h"
42 #include "public/ewk_hit_test_internal.h"
43 #include "public/ewk_touch_internal.h"
44 #include "public/ewk_view_product.h"
45 #include "scroll_detector.h"
46 #include "third_party/blink/public/common/context_menu_data/menu_item_info.h"
47 #include "third_party/blink/public/mojom/choosers/file_chooser.mojom.h"
48 #include "third_party/blink/public/mojom/choosers/popup_menu.mojom.h"
49 #include "ui/aura/window_tree_host.h"
50 #include "ui/gfx/geometry/point.h"
51 #include "ui/gfx/geometry/size.h"
52 #include "web_contents_delegate_efl.h"
53
54 namespace aura {
55 namespace client {
56 class FocusClient;
57 class WindowParentingClient;
58 }  // namespace client
59 }  // namespace aura
60
61 namespace base {
62 class FilePath;
63 }
64
65 namespace content {
66 class RenderFrameHost;
67 class RenderViewHost;
68 class RenderWidgetHostViewAura;
69 class WebContentsDelegateEfl;
70 class WebContentsViewAura;
71 class ContextMenuControllerEfl;
72 class PopupControllerEfl;
73 class DateTimeChooserEfl;
74 class InputPicker;
75 class GinNativeBridgeDispatcherHost;
76 class NavigationHandle;
77 }
78
79 class ErrorParams;
80 class _Ewk_App_Control;
81 class _Ewk_Policy_Decision;
82 class _Ewk_Hit_Test;
83 class Ewk_Context;
84 class WebViewEvasEventHandler;
85 class _Ewk_Quota_Permission_Request;
86
87 #if defined(TIZEN_ATK_SUPPORT)
88 class EWebAccessibility;
89 #endif
90
91 template <typename CallbackPtr, typename CallbackParameter>
92 class WebViewCallback {
93  public:
94   WebViewCallback() { Set(nullptr, nullptr); }
95
96   void Set(CallbackPtr cb, void* data) {
97     callback_ = cb;
98     user_data_ = data;
99   }
100
101   bool IsCallbackSet() const { return callback_; }
102
103   Eina_Bool Run(Evas_Object* webview,
104                 CallbackParameter param,
105                 Eina_Bool* callback_result) {
106     CHECK(callback_result);
107     if (IsCallbackSet()) {
108       *callback_result = callback_(webview, param, user_data_);
109       return true;
110     }
111     return false;
112   }
113
114   void Run(Evas_Object* webview, CallbackParameter param) {
115     if (IsCallbackSet())
116       callback_(webview, param, user_data_);
117   }
118
119  private:
120   CallbackPtr callback_;
121   void* user_data_;
122 };
123
124 template <typename CallbackReturnValue,
125           typename CallbackPtr,
126           typename CallbackParameter>
127 class WebViewCallbackWithReturnValue {
128  public:
129   WebViewCallbackWithReturnValue() { Set(nullptr, nullptr); }
130
131   void Set(CallbackPtr cb, void* data) {
132     callback_ = cb;
133     user_data_ = data;
134   }
135
136   /* LCOV_EXCL_START */
137   bool IsCallbackSet() const { return callback_; }
138
139   CallbackReturnValue Run(Evas_Object* webview, CallbackParameter param) {
140     if (IsCallbackSet())
141       return callback_(webview, param, user_data_);
142
143     return {};
144   }
145   /* LCOV_EXCL_STOP */
146
147  private:
148   CallbackPtr callback_;
149   void* user_data_;
150 };
151
152 template <typename CallbackPtr, typename... CallbackParameter>
153 class WebViewErrorPageLoadCallback {
154  public:
155   WebViewErrorPageLoadCallback() { Set(nullptr, nullptr); }
156
157   void Set(CallbackPtr cb, void* data) {
158     callback_ = cb;
159     user_data_ = data;
160   }
161
162   bool IsCallbackSet() const { return callback_; }
163
164   void Run(Evas_Object* webview, CallbackParameter... param) {
165     if (IsCallbackSet())
166       callback_(webview, param..., user_data_);
167   }
168
169  private:
170   CallbackPtr callback_;
171   void* user_data_;
172 };
173
174 template <typename CallbackPtr, typename... CallbackParameter>
175 class WebViewExceededQuotaCallback {
176  public:
177   WebViewExceededQuotaCallback() { Set(nullptr, nullptr); }
178
179   void Set(CallbackPtr cb, void* data) {
180     callback_ = cb;
181     user_data_ = data;
182   }
183
184   bool IsCallbackSet() const { return callback_; }
185
186   /* LCOV_EXCL_START */
187   void Run(Evas_Object* webview, CallbackParameter... param) {
188     if (IsCallbackSet())
189       callback_(webview, param..., user_data_);
190   }
191   /* LCOV_EXCL_STOP */
192
193  private:
194   CallbackPtr callback_;
195   void* user_data_;
196 };
197
198 class BackgroundColorGetCallback {
199  public:
200   BackgroundColorGetCallback(Ewk_View_Background_Color_Get_Callback func,
201                              void* user_data)
202       : func_(func), user_data_(user_data) {}
203
204   void Run(Evas_Object* webview, int r, int g, int b, int a) {
205     if (func_)
206       func_(webview, r, g, b, a, user_data_);
207   }
208
209  private:
210   Ewk_View_Background_Color_Get_Callback func_;
211   void* user_data_;
212 };
213
214 class WebApplicationIconUrlGetCallback {
215  public:
216   WebApplicationIconUrlGetCallback(Ewk_Web_App_Icon_URL_Get_Callback func,
217                                    void* user_data)
218       : func_(func), user_data_(user_data) {}
219   void Run(const std::string& url) {
220     if (func_) {
221       (func_)(url.c_str(), user_data_);
222     }
223   }
224
225  private:
226   Ewk_Web_App_Icon_URL_Get_Callback func_;
227   void* user_data_;
228 };
229
230 class WebApplicationIconUrlsGetCallback {
231  public:
232   WebApplicationIconUrlsGetCallback(Ewk_Web_App_Icon_URLs_Get_Callback func,
233                                     void* user_data)
234       : func_(func), user_data_(user_data) {}
235   void Run(const std::map<std::string, std::string>& urls) {
236     if (func_) {
237       Eina_List* list = NULL;
238       for (std::map<std::string, std::string>::const_iterator it = urls.begin();
239            it != urls.end(); ++it) {
240         _Ewk_Web_App_Icon_Data* data =
241             ewkWebAppIconDataCreate(it->first, it->second);
242         list = eina_list_append(list, data);
243       }
244       (func_)(list, user_data_);
245     }
246   }
247
248  private:
249   Ewk_Web_App_Icon_URLs_Get_Callback func_;
250   void* user_data_;
251 };
252
253 class WebApplicationCapableGetCallback {
254  public:
255   WebApplicationCapableGetCallback(Ewk_Web_App_Capable_Get_Callback func,
256                                    void* user_data)
257       : func_(func), user_data_(user_data) {}
258   void Run(bool capable) {
259     if (func_) {
260       (func_)(capable ? EINA_TRUE : EINA_FALSE, user_data_);
261     }
262   }
263
264  private:
265   Ewk_Web_App_Capable_Get_Callback func_;
266   void* user_data_;
267 };
268
269 class DidChangeThemeColorCallback {
270  public:
271   DidChangeThemeColorCallback() : callback_(nullptr), user_data_(nullptr) {}
272   void Set(Ewk_View_Did_Change_Theme_Color_Callback callback, void* user_data) {
273     callback_ = callback;
274     user_data_ = user_data;
275   }
276   void Run(Evas_Object* o, const SkColor& color) {
277     if (callback_)
278       callback_(o, SkColorGetR(color), SkColorGetG(color), SkColorGetB(color),
279                 SkColorGetA(color), user_data_);
280   }
281
282  private:
283   Ewk_View_Did_Change_Theme_Color_Callback callback_;
284   void* user_data_;
285 };
286
287 class WebViewAsyncRequestHitTestDataCallback;
288 class JavaScriptDialogManagerEfl;
289 class PermissionPopupManager;
290
291 class EWebView {
292  public:
293   static EWebView* FromEvasObject(Evas_Object* eo);
294
295   EWebView(Ewk_Context*, Evas_Object* smart_object);
296   ~EWebView();
297
298   // initialize data members and activate event handlers.
299   // call this once after created and before use
300   void Initialize();
301
302   bool CreateNewWindow(
303       content::WebContentsEflDelegate::WebContentsCreateCallback);
304   static Evas_Object* GetHostWindowDelegate(const content::WebContents*);
305
306   content::WebContentsViewAura* wcva() const;
307   content::RenderWidgetHostViewAura* rwhva() const;
308   Ewk_Context* context() const { return context_.get(); }
309   Evas_Object* evas_object() const { return evas_object_; }
310   Evas_Object* native_view() const { return native_view_; }
311   Evas_Object* GetElmWindow() const;
312   Evas* GetEvas() const { return evas_object_evas_get(evas_object_); }
313   PermissionPopupManager* GetPermissionPopupManager() const {
314     return permission_popup_manager_.get();
315   }
316
317   content::WebContents& web_contents() const { return *web_contents_.get(); }
318
319 #if defined(TIZEN_ATK_SUPPORT)
320   EWebAccessibility& eweb_accessibility() const {
321     return *eweb_accessibility_.get();
322   }
323 #endif
324
325   template <EWebViewCallbacks::CallbackType callbackType>
326   EWebViewCallbacks::CallBack<callbackType> SmartCallback() const {
327     return EWebViewCallbacks::CallBack<callbackType>(evas_object_);
328   }
329
330   // ewk_view api
331   void SetURL(const GURL& url, bool from_api = false);
332   const GURL& GetURL() const;
333   const GURL& GetOriginalURL() const;
334   void Reload();
335   void ReloadBypassingCache();
336   Eina_Bool CanGoBack();
337   Eina_Bool CanGoForward();
338   Eina_Bool HasFocus() const;
339   void SetFocus(Eina_Bool focus);
340   Eina_Bool GoBack();
341   Eina_Bool GoForward();
342   void Suspend();
343   void Resume();
344   void Stop();
345   void SetSessionTimeout(uint64_t timeout);
346   double GetTextZoomFactor() const;
347   void SetTextZoomFactor(double text_zoom_factor);
348   double GetPageZoomFactor() const;
349   void SetPageZoomFactor(double page_zoom_factor);
350   void ExecuteEditCommand(const char* command, const char* value);
351 #if BUILDFLAG(IS_TIZEN)
352   void EnterDragState();
353 #endif
354   void SetOrientation(int orientation);
355   int GetOrientation();
356   bool TouchEventsEnabled() const;
357   void SetTouchEventsEnabled(bool enabled);
358   bool MouseEventsEnabled() const;
359   void SetMouseEventsEnabled(bool enabled);
360   void HandleTouchEvents(Ewk_Touch_Event_Type type,
361                          const Eina_List* points,
362                          const Evas_Modifier* modifiers);
363   void Show();
364   void Hide();
365   bool ExecuteJavaScript(const char* script,
366                          Ewk_View_Script_Execute_Callback callback,
367                          void* userdata);
368   bool SetUserAgent(const char* userAgent);
369   bool SetUserAgentAppName(const char* application_name);
370 #if BUILDFLAG(IS_TIZEN)
371   bool SetPrivateBrowsing(bool incognito);
372   bool GetPrivateBrowsing() const;
373 #endif
374   const char* GetUserAgent() const;
375   const char* GetUserAgentAppName() const;
376   const char* CacheSelectedText();
377   Ewk_Settings* GetSettings() { return settings_.get(); }
378   _Ewk_Frame* GetMainFrame();
379   void UpdateWebKitPreferences();
380   void LoadHTMLString(const char* html,
381                       const char* base_uri,
382                       const char* unreachable_uri);
383   void LoadPlainTextString(const char* plain_text);
384
385   void LoadHTMLStringOverridingCurrentEntry(const char* html,
386                                             const char* base_uri,
387                                             const char* unreachable_url);
388   void LoadData(const char* data,
389                 size_t size,
390                 const char* mime_type,
391                 const char* encoding,
392                 const char* base_uri,
393                 const char* unreachable_uri = NULL,
394                 bool should_replace_current_entry = false);
395   void InvokeLoadError(const GURL& url, int error_code, bool is_cancellation);
396
397   void SetViewAuthCallback(Ewk_View_Authentication_Callback callback,
398                            void* user_data);
399   void InvokeAuthCallback(LoginDelegateEfl* login_delegate,
400                           const GURL& url,
401                           const std::string& realm);
402   void Find(const char* text, Ewk_Find_Options);
403   void InvokeAuthCallbackOnUI(_Ewk_Auth_Challenge* auth_challenge);
404   void SetContentSecurityPolicy(const char* policy, Ewk_CSP_Header_Type type);
405   void HandlePopupMenu(std::vector<blink::mojom::MenuItemPtr> items,
406                        int selectedIndex,
407                        bool multiple,
408                        const gfx::Rect& bounds);
409   void HidePopupMenu();
410   void DidSelectPopupMenuItems(std::vector<int>& indices);
411   void DidCancelPopupMenu();
412   void HandleLongPressGesture(const content::ContextMenuParams&);
413   void ShowContextMenu(const content::ContextMenuParams&);
414   void CancelContextMenu(int request_id);
415   void SetScale(double scale_factor);
416   void SetScaleChangedCallback(Ewk_View_Scale_Changed_Callback callback,
417                                void* user_data);
418
419   bool GetScrollPosition(int* x, int* y) const;
420   void SetScroll(int x, int y);
421   void UrlRequestSet(const char* url,
422                      content::NavigationController::LoadURLType loadtype,
423                      Eina_Hash* headers,
424                      const char* body);
425
426   SelectPickerBase* GetSelectPicker() const { return select_picker_.get(); }
427   content::SelectionControllerEfl* GetSelectionController() const;
428   content::PopupControllerEfl* GetPopupController() const {
429     return popup_controller_.get();
430   }
431   ScrollDetector* GetScrollDetector() const { return scroll_detector_.get(); }
432   void MoveCaret(const gfx::Point& point);
433   void SelectFocusedLink();
434   bool GetSelectionRange(Eina_Rectangle* left_rect, Eina_Rectangle* right_rect);
435   Eina_Bool ClearSelection();
436
437   // Callback OnCopyFromBackingStore will be called once we get the snapshot
438   // from render
439   void OnCopyFromBackingStore(bool success, const SkBitmap& bitmap);
440
441   void OnFocusIn();
442   void OnFocusOut();
443
444   void UpdateContextMenu(bool is_password_input);
445   void RenderViewReady();
446
447   /**
448    * Creates a snapshot of given rectangle from EWebView
449    *
450    * @param rect rectangle of EWebView which will be taken into snapshot
451    * @param scale_factor scale factor
452    * @return created snapshot or NULL if error occured.
453    * @note ownership of snapshot is passed to caller
454    */
455   Evas_Object* GetSnapshot(Eina_Rectangle rect, float scale_factor);
456
457   bool GetSnapshotAsync(Eina_Rectangle rect,
458                         Ewk_Web_App_Screenshot_Captured_Callback callback,
459                         void* user_data,
460                         float scale_factor);
461   void InvokePolicyResponseCallback(_Ewk_Policy_Decision* policy_decision,
462                                     bool* defer);
463   void InvokePolicyNavigationCallback(const NavigationPolicyParams& params,
464                                       bool* handled);
465   void UseSettingsFont();
466
467   _Ewk_Hit_Test* RequestHitTestDataAt(int x, int y, Ewk_Hit_Test_Mode mode);
468   Eina_Bool AsyncRequestHitTestDataAt(int x,
469                                       int y,
470                                       Ewk_Hit_Test_Mode mode,
471                                       Ewk_View_Hit_Test_Request_Callback,
472                                       void* user_data);
473   _Ewk_Hit_Test* RequestHitTestDataAtBlinkCoords(int x,
474                                                  int y,
475                                                  Ewk_Hit_Test_Mode mode);
476   Eina_Bool AsyncRequestHitTestDataAtBlinkCords(
477       int x,
478       int y,
479       Ewk_Hit_Test_Mode mode,
480       Ewk_View_Hit_Test_Request_Callback,
481       void* user_data);
482   void DispatchAsyncHitTestData(const Hit_Test_Params& params,
483                                 int64_t request_id);
484   void UpdateHitTestData(const Hit_Test_Params& params);
485
486   int current_find_request_id() const { return current_find_request_id_; }
487   bool PlainTextGet(Ewk_View_Plain_Text_Get_Callback callback, void* user_data);
488   void InvokePlainTextGetCallback(const std::string& content_text,
489                                   int plain_text_get_callback_id);
490   int SetEwkViewPlainTextGetCallback(Ewk_View_Plain_Text_Get_Callback callback,
491                                      void* user_data);
492   void SetViewGeolocationPermissionCallback(
493       Ewk_View_Geolocation_Permission_Callback callback,
494       void* user_data);
495   bool InvokeViewGeolocationPermissionCallback(
496       _Ewk_Geolocation_Permission_Request*
497           geolocation_permission_request_context,
498       Eina_Bool* result);
499   void SetViewUserMediaPermissionCallback(
500       Ewk_View_User_Media_Permission_Callback callback,
501       void* user_data);
502   bool InvokeViewUserMediaPermissionCallback(
503       _Ewk_User_Media_Permission_Request* user_media_permission_request_context,
504       Eina_Bool* result);
505   void SetViewUserMediaPermissionQueryCallback(
506       Ewk_View_User_Media_Permission_Query_Callback callback,
507       void* user_data);
508   Ewk_User_Media_Permission_Query_Result
509   InvokeViewUserMediaPermissionQueryCallback(
510       _Ewk_User_Media_Permission_Query* user_media_permission_query_context);
511
512   void SetViewLoadErrorPageCallback(Ewk_View_Error_Page_Load_Callback callback,
513                                     void* user_data);
514   const char* InvokeViewLoadErrorPageCallback(
515       const GURL& url,
516       int error_code,
517       const std::string& error_description);
518   bool IsLoadErrorPageCallbackSet() const;
519   void SetViewUnfocusAllowCallback(Ewk_View_Unfocus_Allow_Callback callback,
520                                    void* user_data);
521   bool InvokeViewUnfocusAllowCallback(Ewk_Unfocus_Direction direction,
522                                       Eina_Bool* result);
523   void DidChangeContentsSize(int width, int height);
524   const Eina_Rectangle GetContentsSize() const;
525   void GetScrollSize(int* w, int* h);
526   void StopFinding();
527   void SetProgressValue(double progress);
528   double GetProgressValue();
529   const char* GetTitle();
530   bool SaveAsPdf(int width, int height, const std::string& file_name);
531   void BackForwardListClear();
532   _Ewk_Back_Forward_List* GetBackForwardList() const;
533   void InvokeBackForwardListChangedCallback();
534   _Ewk_History* GetBackForwardHistory() const;
535   bool WebAppCapableGet(Ewk_Web_App_Capable_Get_Callback callback,
536                         void* userData);
537   bool WebAppIconUrlGet(Ewk_Web_App_Icon_URL_Get_Callback callback,
538                         void* userData);
539   bool WebAppIconUrlsGet(Ewk_Web_App_Icon_URLs_Get_Callback callback,
540                          void* userData);
541   void InvokeWebAppCapableGetCallback(bool capable, int callbackId);
542   void InvokeWebAppIconUrlGetCallback(const std::string& iconUrl,
543                                       int callbackId);
544   void InvokeWebAppIconUrlsGetCallback(
545       const std::map<std::string, std::string>& iconUrls,
546       int callbackId);
547   void SetNotificationPermissionCallback(
548       Ewk_View_Notification_Permission_Callback callback,
549       void* user_data);
550   bool IsNotificationPermissionCallbackSet() const;
551   bool InvokeNotificationPermissionCallback(
552       Ewk_Notification_Permission_Request* request);
553
554   bool GetMHTMLData(Ewk_View_MHTML_Data_Get_Callback callback, void* user_data);
555   void OnMHTMLContentGet(const std::string& mhtml_content, int callback_id);
556   bool SavePageAsMHTML(const std::string& path,
557                        Ewk_View_Save_Page_Callback callback,
558                        void* user_data);
559   bool IsFullscreen();
560   void ExitFullscreen();
561   double GetScale();
562   void DidChangePageScaleFactor(double scale_factor);
563   void SetScaledContentsSize();
564   void SetJavaScriptAlertCallback(Ewk_View_JavaScript_Alert_Callback callback,
565                                   void* user_data);
566   void JavaScriptAlertReply();
567   void SetJavaScriptConfirmCallback(
568       Ewk_View_JavaScript_Confirm_Callback callback,
569       void* user_data);
570   void JavaScriptConfirmReply(bool result);
571   void SetJavaScriptPromptCallback(Ewk_View_JavaScript_Prompt_Callback callback,
572                                    void* user_data);
573   void JavaScriptPromptReply(const char* result);
574   void set_renderer_crashed();
575   void GetPageScaleRange(double* min_scale, double* max_scale);
576   void SetDrawsTransparentBackground(bool enabled);
577   bool GetBackgroundColor(Ewk_View_Background_Color_Get_Callback callback,
578                           void* user_data);
579   void OnGetBackgroundColor(int callback_id, SkColor bg_color);
580
581   void GetSessionData(const char** data, unsigned* length) const;
582   bool RestoreFromSessionData(const char* data, unsigned length);
583   void ShowFileChooser(content::RenderFrameHost* render_frame_host,
584                        const blink::mojom::FileChooserParams&);
585   void SetBrowserFont();
586   bool IsDragging() const;
587
588   void RequestColorPicker(int r, int g, int b, int a);
589   bool SetColorPickerColor(int r, int g, int b, int a);
590   void InputPickerShow(ui::TextInputType input_type,
591                        double input_value,
592                        content::DateTimeChooserEfl* date_time_chooser);
593
594   void ShowContentsDetectedPopup(const char*);
595
596   // Returns TCP port number with Inspector, or 0 if error.
597   int StartInspectorServer(int port = 0);
598   bool StopInspectorServer();
599
600   void LoadNotFoundErrorPage(const std::string& invalidUrl);
601   static std::string GetPlatformLocale();
602   bool GetLinkMagnifierEnabled() const;
603   void SetLinkMagnifierEnabled(bool enabled);
604
605   bool GetHorizontalPanningHold() const;
606   void SetHorizontalPanningHold(bool hold);
607   bool GetVerticalPanningHold() const;
608   void SetVerticalPanningHold(bool hold);
609
610   void SetQuotaPermissionRequestCallback(
611       Ewk_Quota_Permission_Request_Callback callback,
612       void* user_data);
613   void InvokeQuotaPermissionRequest(
614       _Ewk_Quota_Permission_Request* request,
615       content::QuotaPermissionContext::PermissionCallback cb);
616   void QuotaRequestReply(const _Ewk_Quota_Permission_Request* request,
617                          bool allow);
618   void QuotaRequestCancel(const _Ewk_Quota_Permission_Request* request);
619 #if !defined(EWK_BRINGUP)  // FIXME: m67 bringup
620   void SetViewMode(blink::WebViewMode view_mode);
621 #endif
622   gfx::Point GetContextMenuPosition() const;
623
624   content::ContextMenuControllerEfl* GetContextMenuController() {
625     return context_menu_.get();
626   }
627
628   bool SetMainFrameScrollbarVisible(bool visible);
629   bool GetMainFrameScrollbarVisible(
630       Ewk_View_Main_Frame_Scrollbar_Visible_Get_Callback callback,
631       void* user_data);
632   void InvokeMainFrameScrollbarVisibleCallback(int callback_id, bool visible);
633
634   void ResetContextMenuController();
635   Eina_Bool AddJavaScriptMessageHandler(Evas_Object* view,
636                                         Ewk_View_Script_Message_Cb callback,
637                                         std::string name);
638
639   content::GinNativeBridgeDispatcherHost* GetGinNativeBridgeDispatcherHost()
640       const {
641     return gin_native_bridge_dispatcher_host_.get();
642   }
643   bool SetPageVisibility(Ewk_Page_Visibility_State page_visibility_state);
644
645   void SetExceededIndexedDatabaseQuotaCallback(
646       Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback,
647       void* user_data);
648   void InvokeExceededIndexedDatabaseQuotaCallback(const GURL& origin,
649                                                   int64_t current_quota);
650   void ExceededIndexedDatabaseQuotaReply(bool allow);
651
652 #if defined(TIZEN_VIDEO_HOLE)
653   void SetVideoHoleSupport(bool enable);
654 #endif
655
656   /// ---- Event handling
657   bool HandleShow();
658   bool HandleHide();
659   bool HandleMove(int x, int y);
660   bool HandleResize(int width, int height);
661   bool HandleTextSelectionDown(int x, int y);
662   bool HandleTextSelectionUp(int x, int y);
663
664   void HandleRendererProcessCrash();
665   void InvokeWebProcessCrashedCallback();
666
667   void HandleTapGestureForSelection(bool is_content_editable);
668   void HandleZoomGesture(blink::WebGestureEvent& event);
669   void ClosePage();
670
671   void RequestManifest(Ewk_View_Request_Manifest_Callback callback,
672                        void* user_data);
673   void DidRespondRequestManifest(_Ewk_View_Request_Manifest* manifest,
674                                  Ewk_View_Request_Manifest_Callback callback,
675                                  void* user_data);
676
677   void SetBeforeUnloadConfirmPanelCallback(
678       Ewk_View_Before_Unload_Confirm_Panel_Callback callback,
679       void* user_data);
680   void ReplyBeforeUnloadConfirmPanel(Eina_Bool result);
681   void SyncAcceptLanguages(const std::string& accept_languages);
682
683   void OnOverscrolled(const gfx::Vector2dF& accumulated_overscroll,
684                       const gfx::Vector2dF& latest_overscroll_delta);
685
686   bool SetVisibility(bool enable);
687   void SetDoNotTrack(Eina_Bool);
688
689 #if defined(TIZEN_ATK_SUPPORT)
690   void UpdateSpatialNavigationStatus(Eina_Bool enable);
691   void UpdateAccessibilityStatus(Eina_Bool enable);
692
693   bool CheckLazyInitializeAtk() {
694     return is_initialized_ && lazy_initialize_atk_;
695   }
696   void InitAtk();
697   bool GetAtkStatus();
698 #endif
699
700   bool ShouldIgnoreNavigation(content::NavigationHandle* navigation_handle);
701
702 #if BUILDFLAG(IS_TIZEN_TV)
703   void DrawLabel(Evas_Object* image, Eina_Rectangle rect);
704   void DeactivateAtk(bool deactivated);
705   void ClearLabels();
706 #endif  // IS_TIZEN_TV
707
708   void SetDidChangeThemeColorCallback(
709       Ewk_View_Did_Change_Theme_Color_Callback callback,
710       void* user_data);
711   void DidChangeThemeColor(const SkColor& color);
712
713   void OnSelectionRectReceived(const gfx::Rect& selection_rect) const;
714
715 #if BUILDFLAG(IS_TIZEN_TV)
716   bool SetMixedContents(bool allow);
717   void ClearAllTilesResources();
718   bool UseEarlyRWI() { return use_early_rwi_; }
719   bool RWIInfoShowed() { return rwi_info_showed_; }
720   GURL RWIURL() { return rwi_gurl_; }
721   void OnDialogClosed();
722 #endif // OS_TIZEN_TV_PRODUCT
723
724  private:
725   static void NativeViewResize(void* data,
726                                Evas* e,
727                                Evas_Object* obj,
728                                void* event_info);
729   void InitializeContent();
730   void InitializeWindowTreeHost();
731   void SendDelayedMessages(content::RenderViewHost* render_view_host);
732
733   void EvasToBlinkCords(int x, int y, int* view_x, int* view_y);
734   Eina_Bool AsyncRequestHitTestDataAtBlinkCords(
735       int x,
736       int y,
737       Ewk_Hit_Test_Mode mode,
738       WebViewAsyncRequestHitTestDataCallback* cb);
739
740 #if BUILDFLAG(IS_TIZEN_TV)
741   void InitInspectorServer();
742 #endif
743
744 #if BUILDFLAG(IS_TIZEN) && !defined(EWK_BRINGUP)
745   static void cameraResultCb(service_h request,
746                              service_h reply,
747                              service_result_e result,
748                              void* data);
749 #endif
750
751 #if BUILDFLAG(IS_TIZEN) && !defined(EWK_BRINGUP)
752   bool LaunchCamera(std::u16string mimetype);
753 #endif
754   JavaScriptDialogManagerEfl* GetJavaScriptDialogManagerEfl();
755
756   // Changes viewport without resizing Evas_Object representing webview
757   // and its corresponding RWHV to let Blink renders custom viewport
758   // while showing picker.
759   void AdjustViewPortHeightToPopupMenu(bool is_popup_menu_visible);
760
761   void ShowContextMenuInternal(const content::ContextMenuParams&);
762
763   void UpdateWebkitPreferencesEfl(content::RenderViewHost*);
764
765   void ChangeScroll(int& x, int& y);
766   void ScrollFocusedNodeIntoView();
767
768   void GenerateMHTML(Ewk_View_Save_Page_Callback callback,
769                      void* user_data,
770                      const base::FilePath& file_path);
771   void MHTMLGenerated(Ewk_View_Save_Page_Callback callback,
772                       void* user_data,
773                       const base::FilePath& file_path,
774                       int64_t file_size);
775
776   static void OnViewFocusIn(void* data, Evas*, Evas_Object*, void*);
777   static void OnViewFocusOut(void* data, Evas*, Evas_Object*, void*);
778   static void VisibleContentChangedCallback(void* user_data,
779                                             Evas_Object* object,
780                                             void* event_info);
781
782   static void OnCustomScrollBeginCallback(void* user_data,
783                                           Evas_Object* object,
784                                           void* event_info);
785
786   static void OnCustomScrollEndCallback(void* user_data,
787                                         Evas_Object* object,
788                                         void* event_info);
789   void UpdateContextMenuWithParams(const content::ContextMenuParams& params);
790
791   static Eina_Bool DelayedPopulateAndShowContextMenu(void* data);
792 #if BUILDFLAG(IS_TIZEN_TV)
793   void RunPendingSetFocus(Eina_Bool focus);
794 #endif
795
796   scoped_refptr<WebViewEvasEventHandler> evas_event_handler_;
797   scoped_refptr<Ewk_Context> context_;
798   std::unique_ptr<content::WebContents> web_contents_;
799   std::unique_ptr<content::WebContentsDelegateEfl> web_contents_delegate_;
800   std::string pending_url_request_;
801   std::unique_ptr<Ewk_Settings> settings_;
802   std::unique_ptr<_Ewk_Frame> frame_;
803   std::unique_ptr<_Ewk_Policy_Decision> window_policy_;
804   Evas_Object* evas_object_;
805   Evas_Object* native_view_;
806   bool mouse_events_enabled_;
807   double text_zoom_factor_;
808   mutable std::string user_agent_;
809   mutable std::string user_agent_app_name_;
810   std::unique_ptr<_Ewk_Auth_Challenge> auth_challenge_;
811   std::string selected_text_cached_;
812
813   std::unique_ptr<content::ContextMenuControllerEfl> context_menu_;
814 #if !defined(EWK_BRINGUP)  // FIXME: m71 bringup
815   std::unique_ptr<content::FileChooserControllerEfl> file_chooser_;
816 #endif
817   std::unique_ptr<content::PopupControllerEfl> popup_controller_;
818   std::u16string previous_text_;
819   int current_find_request_id_;
820   static int find_request_id_counter_;
821
822   typedef WebViewCallback<Ewk_View_Plain_Text_Get_Callback, const char*>
823       EwkViewPlainTextGetCallback;
824   base::IDMap<EwkViewPlainTextGetCallback*> plain_text_get_callback_map_;
825
826   typedef WebViewCallback<Ewk_View_MHTML_Data_Get_Callback, const char*>
827       MHTMLCallbackDetails;
828   base::IDMap<MHTMLCallbackDetails*> mhtml_callback_map_;
829
830   typedef WebViewCallback<Ewk_View_Main_Frame_Scrollbar_Visible_Get_Callback,
831                           bool>
832       MainFrameScrollbarVisibleGetCallback;
833   base::IDMap<MainFrameScrollbarVisibleGetCallback*>
834       main_frame_scrollbar_visible_callback_map_;
835
836   base::IDMap<BackgroundColorGetCallback*> background_color_get_callback_map_;
837
838   gfx::Size contents_size_;
839   double progress_;
840   mutable std::string title_;
841   Hit_Test_Params hit_test_params_;
842   base::WaitableEvent hit_test_completion_;
843   double page_scale_factor_;
844   double x_delta_;
845   double y_delta_;
846
847   WebViewCallback<Ewk_View_Geolocation_Permission_Callback,
848                   _Ewk_Geolocation_Permission_Request*>
849       geolocation_permission_cb_;
850   WebViewCallback<Ewk_View_User_Media_Permission_Callback,
851                   _Ewk_User_Media_Permission_Request*>
852       user_media_permission_cb_;
853   WebViewCallbackWithReturnValue<Ewk_User_Media_Permission_Query_Result,
854                                  Ewk_View_User_Media_Permission_Query_Callback,
855                                  _Ewk_User_Media_Permission_Query*>
856       user_media_permission_query_cb_;
857   WebViewErrorPageLoadCallback<Ewk_View_Error_Page_Load_Callback,
858                                Ewk_Error*,
859                                Ewk_Error_Page*>
860       load_error_page_cb_;
861   WebViewCallback<Ewk_View_Unfocus_Allow_Callback, Ewk_Unfocus_Direction>
862       unfocus_allow_cb_;
863   WebViewCallback<Ewk_View_Notification_Permission_Callback,
864                   Ewk_Notification_Permission_Request*>
865       notification_permission_callback_;
866   WebViewCallback<Ewk_Quota_Permission_Request_Callback,
867                   const _Ewk_Quota_Permission_Request*>
868       quota_request_callback_;
869   WebViewCallback<Ewk_View_Authentication_Callback, _Ewk_Auth_Challenge*>
870       authentication_cb_;
871   WebViewCallback<Ewk_View_Scale_Changed_Callback, double> scale_changed_cb_;
872
873   std::unique_ptr<content::InputPicker> input_picker_;
874
875   DidChangeThemeColorCallback did_change_theme_color_callback_;
876
877   base::IDMap<WebApplicationIconUrlGetCallback*>
878       web_app_icon_url_get_callback_map_;
879   base::IDMap<WebApplicationIconUrlsGetCallback*>
880       web_app_icon_urls_get_callback_map_;
881   base::IDMap<WebApplicationCapableGetCallback*>
882       web_app_capable_get_callback_map_;
883   std::unique_ptr<PermissionPopupManager> permission_popup_manager_;
884   std::unique_ptr<ScrollDetector> scroll_detector_;
885
886   // Manages injecting native objects.
887   std::unique_ptr<content::GinNativeBridgeDispatcherHost>
888       gin_native_bridge_dispatcher_host_;
889
890   WebViewExceededQuotaCallback<
891       Ewk_View_Exceeded_Indexed_Database_Quota_Callback,
892       Ewk_Security_Origin*,
893       long long>
894       exceeded_indexed_db_quota_callback_;
895   std::unique_ptr<Ewk_Security_Origin> exceeded_indexed_db_quota_origin_;
896
897 #if BUILDFLAG(IS_TIZEN)
898   blink::mojom::FileChooserParams::Mode filechooser_mode_;
899 #endif
900   std::map<const _Ewk_Quota_Permission_Request*,
901            content::QuotaPermissionContext::PermissionCallback>
902       quota_permission_request_map_;
903
904 #if BUILDFLAG(IS_TIZEN)
905   Ecore_Event_Handler* window_rotate_handler_ = nullptr;
906 #endif
907
908   bool is_initialized_;
909
910 #if BUILDFLAG(IS_TIZEN_TV)
911   bool use_early_rwi_;
912   bool rwi_info_showed_;
913   GURL rwi_gurl_;
914 #endif
915
916   std::unique_ptr<_Ewk_Back_Forward_List> back_forward_list_;
917
918   static content::WebContentsEflDelegate::WebContentsCreateCallback
919       create_new_window_web_contents_cb_;
920
921  private:
922   gfx::Vector2d previous_scroll_position_;
923
924   gfx::Point context_menu_position_;
925
926   content::ContextMenuParams saved_context_menu_params_;
927
928   std::vector<IPC::Message*> delayed_messages_;
929
930   std::map<int64_t, WebViewAsyncRequestHitTestDataCallback*> hit_test_callback_;
931
932   content::AcceptLanguagesHelper::AcceptLangsChangedCallback
933       accept_langs_changed_callback_;
934
935   std::unique_ptr<SelectPickerBase> select_picker_;
936   std::unique_ptr<aura::WindowTreeHost> host_;
937   std::unique_ptr<aura::client::FocusClient> focus_client_;
938   std::unique_ptr<aura::client::WindowParentingClient> window_parenting_client_;
939   std::unique_ptr<ui::CompositorObserver> compositor_observer_;
940
941 #if defined(TIZEN_ATK_SUPPORT)
942   std::unique_ptr<EWebAccessibility> eweb_accessibility_;
943   bool lazy_initialize_atk_ = false;
944 #endif
945 #if defined(TIZEN_VIDEO_HOLE)
946   bool pending_video_hole_setting_ = false;
947 #endif
948
949   Ecore_Timer* delayed_show_context_menu_timer_ = nullptr;
950
951 #if BUILDFLAG(IS_TIZEN_TV)
952   base::OnceClosure pending_setfocus_closure_;
953 #endif
954 };
955
956 const unsigned int g_default_tilt_motion_sensitivity = 3;
957
958 #endif