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