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