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