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