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