[M108 Migration][Accessibility] Bringup Accessibility.
[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 "browser/selectpicker/popup_picker.h"
25 #include "content/browser/date_time_chooser_efl.h"
26 #include "content/browser/renderer_host/event_with_latency_info.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   void set_magnifier(bool status);
315
316   // ewk_view api
317   void SetURL(const GURL& url, bool from_api = false);
318   const GURL& GetURL() const;
319   const GURL& GetOriginalURL() const;
320   void Reload();
321   void ReloadBypassingCache();
322   Eina_Bool CanGoBack();
323   Eina_Bool CanGoForward();
324   Eina_Bool HasFocus() const;
325   void SetFocus(Eina_Bool focus);
326   Eina_Bool GoBack();
327   Eina_Bool GoForward();
328   void Suspend();
329   void Resume();
330   void Stop();
331   void SetSessionTimeout(uint64_t timeout);
332   double GetTextZoomFactor() const;
333   void SetTextZoomFactor(double text_zoom_factor);
334   double GetPageZoomFactor() const;
335   void SetPageZoomFactor(double page_zoom_factor);
336   void ExecuteEditCommand(const char* command, const char* value);
337   void SetOrientation(int orientation);
338   int GetOrientation();
339   bool TouchEventsEnabled() const;
340   void SetTouchEventsEnabled(bool enabled);
341   bool MouseEventsEnabled() const;
342   void SetMouseEventsEnabled(bool enabled);
343   void HandleTouchEvents(Ewk_Touch_Event_Type type,
344                          const Eina_List* points,
345                          const Evas_Modifier* modifiers);
346   void Show();
347   void Hide();
348   bool ExecuteJavaScript(const char* script,
349                          Ewk_View_Script_Execute_Callback callback,
350                          void* userdata);
351   bool SetUserAgent(const char* userAgent);
352   bool SetUserAgentAppName(const char* application_name);
353 #if BUILDFLAG(IS_TIZEN)
354   bool SetPrivateBrowsing(bool incognito);
355   bool GetPrivateBrowsing() const;
356 #endif
357   const char* GetUserAgent() const;
358   const char* GetUserAgentAppName() const;
359   const char* CacheSelectedText();
360   Ewk_Settings* GetSettings() { return settings_.get(); }
361   _Ewk_Frame* GetMainFrame();
362   void UpdateWebKitPreferences();
363   void LoadHTMLString(const char* html,
364                       const char* base_uri,
365                       const char* unreachable_uri);
366   void LoadPlainTextString(const char* plain_text);
367   void LoadData(const char* data,
368                 size_t size,
369                 const char* mime_type,
370                 const char* encoding,
371                 const char* base_uri,
372                 const char* unreachable_uri = NULL);
373
374   void InvokeLoadError(const GURL& url, int error_code, bool is_cancellation);
375
376   void SetViewAuthCallback(Ewk_View_Authentication_Callback callback,
377                            void* user_data);
378   void InvokeAuthCallback(LoginDelegateEfl* login_delegate,
379                           const GURL& url,
380                           const std::string& realm);
381   void Find(const char* text, Ewk_Find_Options);
382   void InvokeAuthCallbackOnUI(_Ewk_Auth_Challenge* auth_challenge);
383   void SetContentSecurityPolicy(const char* policy, Ewk_CSP_Header_Type type);
384   void HandlePopupMenu(std::vector<blink::mojom::MenuItemPtr> items,
385                        int selectedIndex,
386                        bool multiple);
387   void HidePopupMenu();
388   void UpdateFormNavigation(int formElementCount,
389                             int currentNodeIndex,
390                             bool prevState,
391                             bool nextState);
392   void FormNavigate(bool direction);
393   bool FormIsNavigating() const { return formIsNavigating_; }
394   void SetFormIsNavigating(bool formIsNavigating);
395   Eina_Bool PopupMenuUpdate(Eina_List* items, int selectedIndex);
396   Eina_Bool DidSelectPopupMenuItem(int selectedIndex);
397   Eina_Bool DidMultipleSelectPopupMenuItem(std::vector<int>& selectedIndices);
398   void PopupMenuClose();
399   void HandleLongPressGesture(const content::ContextMenuParams&);
400   void ShowContextMenu(const content::ContextMenuParams&);
401   void CancelContextMenu(int request_id);
402   void SetScale(double scale_factor);
403   void SetScaleChangedCallback(Ewk_View_Scale_Changed_Callback callback,
404                                void* user_data);
405
406   bool GetScrollPosition(int* x, int* y) const;
407   void SetScroll(int x, int y);
408   void UrlRequestSet(const char* url,
409                      content::NavigationController::LoadURLType loadtype,
410                      Eina_Hash* headers,
411                      const char* body);
412
413   content::SelectionControllerEfl* GetSelectionController() const;
414   content::PopupControllerEfl* GetPopupController() const {
415     return popup_controller_.get();
416   }
417   ScrollDetector* GetScrollDetector() const { return scroll_detector_.get(); }
418   void MoveCaret(const gfx::Point& point);
419   void SelectLinkText(const gfx::Point& touch_point);
420   bool GetSelectionRange(Eina_Rectangle* left_rect, Eina_Rectangle* right_rect);
421   Eina_Bool ClearSelection();
422
423   // Callback OnCopyFromBackingStore will be called once we get the snapshot
424   // from render
425   void OnCopyFromBackingStore(bool success, const SkBitmap& bitmap);
426
427   void OnFocusIn();
428   void OnFocusOut();
429
430   void RenderViewReady();
431
432   /**
433    * Creates a snapshot of given rectangle from EWebView
434    *
435    * @param rect rectangle of EWebView which will be taken into snapshot
436    * @param scale_factor scale factor
437    * @return created snapshot or NULL if error occured.
438    * @note ownership of snapshot is passed to caller
439    */
440   Evas_Object* GetSnapshot(Eina_Rectangle rect, float scale_factor);
441
442   bool GetSnapshotAsync(Eina_Rectangle rect,
443                         Ewk_Web_App_Screenshot_Captured_Callback callback,
444                         void* user_data,
445                         float scale_factor);
446   void InvokePolicyResponseCallback(_Ewk_Policy_Decision* policy_decision,
447                                     bool* defer);
448   void InvokePolicyNavigationCallback(const NavigationPolicyParams& params,
449                                       bool* handled);
450   void UseSettingsFont();
451
452   _Ewk_Hit_Test* RequestHitTestDataAt(int x, int y, Ewk_Hit_Test_Mode mode);
453   Eina_Bool AsyncRequestHitTestDataAt(int x,
454                                       int y,
455                                       Ewk_Hit_Test_Mode mode,
456                                       Ewk_View_Hit_Test_Request_Callback,
457                                       void* user_data);
458   _Ewk_Hit_Test* RequestHitTestDataAtBlinkCoords(int x,
459                                                  int y,
460                                                  Ewk_Hit_Test_Mode mode);
461   Eina_Bool AsyncRequestHitTestDataAtBlinkCords(
462       int x,
463       int y,
464       Ewk_Hit_Test_Mode mode,
465       Ewk_View_Hit_Test_Request_Callback,
466       void* user_data);
467   void DispatchAsyncHitTestData(const Hit_Test_Params& params,
468                                 int64_t request_id);
469   void UpdateHitTestData(const Hit_Test_Params& params);
470
471   int current_find_request_id() const { return current_find_request_id_; }
472   bool PlainTextGet(Ewk_View_Plain_Text_Get_Callback callback, void* user_data);
473   void InvokePlainTextGetCallback(const std::string& content_text,
474                                   int plain_text_get_callback_id);
475   int SetEwkViewPlainTextGetCallback(Ewk_View_Plain_Text_Get_Callback callback,
476                                      void* user_data);
477   void SetViewGeolocationPermissionCallback(
478       Ewk_View_Geolocation_Permission_Callback callback,
479       void* user_data);
480   bool InvokeViewGeolocationPermissionCallback(
481       _Ewk_Geolocation_Permission_Request*
482           geolocation_permission_request_context,
483       Eina_Bool* result);
484   void SetViewUserMediaPermissionCallback(
485       Ewk_View_User_Media_Permission_Callback callback,
486       void* user_data);
487   bool InvokeViewUserMediaPermissionCallback(
488       _Ewk_User_Media_Permission_Request* user_media_permission_request_context,
489       Eina_Bool* result);
490   void SetViewUserMediaPermissionQueryCallback(
491       Ewk_View_User_Media_Permission_Query_Callback callback,
492       void* user_data);
493   Ewk_User_Media_Permission_Query_Result
494   InvokeViewUserMediaPermissionQueryCallback(
495       _Ewk_User_Media_Permission_Query* user_media_permission_query_context);
496   void SetViewUnfocusAllowCallback(Ewk_View_Unfocus_Allow_Callback callback,
497                                    void* user_data);
498   bool InvokeViewUnfocusAllowCallback(Ewk_Unfocus_Direction direction,
499                                       Eina_Bool* result);
500   void DidChangeContentsSize(int width, int height);
501   const Eina_Rectangle GetContentsSize() const;
502   void GetScrollSize(int* w, int* h);
503   void StopFinding();
504   void SetProgressValue(double progress);
505   double GetProgressValue();
506   const char* GetTitle();
507   bool SaveAsPdf(int width, int height, const std::string& file_name);
508   void BackForwardListClear();
509   _Ewk_Back_Forward_List* GetBackForwardList() const;
510   void InvokeBackForwardListChangedCallback();
511   _Ewk_History* GetBackForwardHistory() const;
512   bool WebAppCapableGet(Ewk_Web_App_Capable_Get_Callback callback,
513                         void* userData);
514   bool WebAppIconUrlGet(Ewk_Web_App_Icon_URL_Get_Callback callback,
515                         void* userData);
516   bool WebAppIconUrlsGet(Ewk_Web_App_Icon_URLs_Get_Callback callback,
517                          void* userData);
518   void InvokeWebAppCapableGetCallback(bool capable, int callbackId);
519   void InvokeWebAppIconUrlGetCallback(const std::string& iconUrl,
520                                       int callbackId);
521   void InvokeWebAppIconUrlsGetCallback(
522       const std::map<std::string, std::string>& iconUrls,
523       int callbackId);
524   void SetNotificationPermissionCallback(
525       Ewk_View_Notification_Permission_Callback callback,
526       void* user_data);
527   bool IsNotificationPermissionCallbackSet() const;
528   bool InvokeNotificationPermissionCallback(
529       Ewk_Notification_Permission_Request* request);
530
531   bool GetMHTMLData(Ewk_View_MHTML_Data_Get_Callback callback, void* user_data);
532   void OnMHTMLContentGet(const std::string& mhtml_content, int callback_id);
533   bool SavePageAsMHTML(const std::string& path,
534                        Ewk_View_Save_Page_Callback callback,
535                        void* user_data);
536   bool IsFullscreen();
537   void ExitFullscreen();
538   double GetScale();
539   void DidChangePageScaleFactor(double scale_factor);
540   void SetScaledContentsSize();
541   void SetJavaScriptAlertCallback(Ewk_View_JavaScript_Alert_Callback callback,
542                                   void* user_data);
543   void JavaScriptAlertReply();
544   void SetJavaScriptConfirmCallback(
545       Ewk_View_JavaScript_Confirm_Callback callback,
546       void* user_data);
547   void JavaScriptConfirmReply(bool result);
548   void SetJavaScriptPromptCallback(Ewk_View_JavaScript_Prompt_Callback callback,
549                                    void* user_data);
550   void JavaScriptPromptReply(const char* result);
551   void set_renderer_crashed();
552   void GetPageScaleRange(double* min_scale, double* max_scale);
553   void SetDrawsTransparentBackground(bool enabled);
554   bool GetBackgroundColor(Ewk_View_Background_Color_Get_Callback callback,
555                           void* user_data);
556   void OnGetBackgroundColor(int callback_id, SkColor bg_color);
557
558   void GetSessionData(const char** data, unsigned* length) const;
559   bool RestoreFromSessionData(const char* data, unsigned length);
560   void ShowFileChooser(content::RenderFrameHost* render_frame_host,
561                        const blink::mojom::FileChooserParams&);
562   void SetBrowserFont();
563   bool IsDragging() const;
564
565   void RequestColorPicker(int r, int g, int b, int a);
566   bool SetColorPickerColor(int r, int g, int b, int a);
567   void InputPickerShow(ui::TextInputType input_type,
568                        double input_value,
569                        content::DateTimeChooserEfl* date_time_chooser);
570
571   void ShowContentsDetectedPopup(const char*);
572
573   // Returns TCP port number with Inspector, or 0 if error.
574   int StartInspectorServer(int port = 0);
575   bool StopInspectorServer();
576
577   void LoadNotFoundErrorPage(const std::string& invalidUrl);
578   static std::string GetPlatformLocale();
579   bool GetLinkMagnifierEnabled() const;
580   void SetLinkMagnifierEnabled(bool enabled);
581
582   bool GetHorizontalPanningHold() const;
583   void SetHorizontalPanningHold(bool hold);
584   bool GetVerticalPanningHold() const;
585   void SetVerticalPanningHold(bool hold);
586
587   void SetQuotaPermissionRequestCallback(
588       Ewk_Quota_Permission_Request_Callback callback,
589       void* user_data);
590   void InvokeQuotaPermissionRequest(
591       _Ewk_Quota_Permission_Request* request,
592       content::QuotaPermissionContext::PermissionCallback cb);
593   void QuotaRequestReply(const _Ewk_Quota_Permission_Request* request,
594                          bool allow);
595   void QuotaRequestCancel(const _Ewk_Quota_Permission_Request* request);
596 #if !defined(EWK_BRINGUP)  // FIXME: m67 bringup
597   void SetViewMode(blink::WebViewMode view_mode);
598 #endif
599   gfx::Point GetContextMenuPosition() const;
600
601   content::ContextMenuControllerEfl* GetContextMenuController() {
602     return context_menu_.get();
603   }
604   void ResetContextMenuController();
605   Eina_Bool AddJavaScriptMessageHandler(Evas_Object* view,
606                                         Ewk_View_Script_Message_Cb callback,
607                                         std::string name);
608
609   content::GinNativeBridgeDispatcherHost* GetGinNativeBridgeDispatcherHost()
610       const {
611     return gin_native_bridge_dispatcher_host_.get();
612   }
613   bool SetPageVisibility(Ewk_Page_Visibility_State page_visibility_state);
614
615   void SetExceededIndexedDatabaseQuotaCallback(
616       Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback,
617       void* user_data);
618   void InvokeExceededIndexedDatabaseQuotaCallback(const GURL& origin,
619                                                   int64_t current_quota);
620   void ExceededIndexedDatabaseQuotaReply(bool allow);
621
622   /// ---- Event handling
623   bool HandleShow();
624   bool HandleHide();
625   bool HandleMove(int x, int y);
626   bool HandleResize(int width, int height);
627   bool HandleTextSelectionDown(int x, int y);
628   bool HandleTextSelectionUp(int x, int y);
629
630   void HandleRendererProcessCrash();
631   void InvokeWebProcessCrashedCallback();
632
633   void HandleTapGestureForSelection(bool is_content_editable);
634   void HandleZoomGesture(blink::WebGestureEvent& event);
635   void ClosePage();
636
637   void RequestManifest(Ewk_View_Request_Manifest_Callback callback,
638                        void* user_data);
639   void DidRespondRequestManifest(_Ewk_View_Request_Manifest* manifest,
640                                  Ewk_View_Request_Manifest_Callback callback,
641                                  void* user_data);
642
643   void SyncAcceptLanguages(const std::string& accept_languages);
644
645   void OnOverscrolled(const gfx::Vector2dF& accumulated_overscroll,
646                       const gfx::Vector2dF& latest_overscroll_delta);
647
648   bool SetVisibility(bool enable);
649
650 #if defined(TIZEN_ATK_SUPPORT)
651   void UpdateSpatialNavigationStatus(Eina_Bool enable);
652   void UpdateAccessibilityStatus(Eina_Bool enable);
653
654   bool CheckLazyInitializeAtk() {
655     return is_initialized_ && lazy_initialize_atk_;
656   }
657   void InitAtk();
658   bool GetAtkStatus();
659 #endif
660
661   content::DateTimeChooserEfl* GetDateTimeChooser() {
662     return date_time_chooser_;
663   }
664
665   bool ShouldIgnoreNavigation(content::NavigationHandle* navigation_handle);
666
667 #if BUILDFLAG(IS_TIZEN_TV)
668   void DrawLabel(Evas_Object* image, Eina_Rectangle rect);
669   void ClearLabels();
670 #endif  // IS_TIZEN_TV
671
672   void SetDidChangeThemeColorCallback(
673       Ewk_View_Did_Change_Theme_Color_Callback callback,
674       void* user_data);
675   void DidChangeThemeColor(const SkColor& color);
676
677  private:
678   void InitializeContent();
679   void InitializeWindowTreeHost();
680   void SendDelayedMessages(content::RenderViewHost* render_view_host);
681
682   void EvasToBlinkCords(int x, int y, int* view_x, int* view_y);
683   Eina_Bool AsyncRequestHitTestDataAtBlinkCords(
684       int x,
685       int y,
686       Ewk_Hit_Test_Mode mode,
687       WebViewAsyncRequestHitTestDataCallback* cb);
688 #if BUILDFLAG(IS_TIZEN) && !defined(EWK_BRINGUP)
689   static void cameraResultCb(service_h request,
690                              service_h reply,
691                              service_result_e result,
692                              void* data);
693 #endif
694
695 #if BUILDFLAG(IS_TIZEN) && !defined(EWK_BRINGUP)
696   bool LaunchCamera(std::u16string mimetype);
697 #endif
698 #if !defined(USE_AURA)
699   content::RenderWidgetHostViewEfl* rwhv() const;
700 #endif
701   JavaScriptDialogManagerEfl* GetJavaScriptDialogManagerEfl();
702
703   void ReleasePopupMenuList();
704   // Changes viewport without resizing Evas_Object representing webview
705   // and its corresponding RWHV to let Blink renders custom viewport
706   // while showing picker.
707   void AdjustViewPortHeightToPopupMenu(bool is_popup_menu_visible);
708
709   void ShowContextMenuInternal(const content::ContextMenuParams&);
710
711   void UpdateWebkitPreferencesEfl(content::RenderViewHost*);
712
713   void ChangeScroll(int& x, int& y);
714   void ScrollFocusedNodeIntoView();
715
716   void GenerateMHTML(Ewk_View_Save_Page_Callback callback,
717                      void* user_data,
718                      const base::FilePath& file_path);
719   void MHTMLGenerated(Ewk_View_Save_Page_Callback callback,
720                       void* user_data,
721                       const base::FilePath& file_path,
722                       int64_t file_size);
723
724   static void OnViewFocusIn(void* data, Evas*, Evas_Object*, void*);
725   static void OnViewFocusOut(void* data, Evas*, Evas_Object*, void*);
726
727   scoped_refptr<WebViewEvasEventHandler> evas_event_handler_;
728   scoped_refptr<Ewk_Context> context_;
729   std::unique_ptr<content::WebContents> web_contents_;
730   std::unique_ptr<content::WebContentsDelegateEfl> web_contents_delegate_;
731   std::string pending_url_request_;
732   std::unique_ptr<Ewk_Settings> settings_;
733   std::unique_ptr<_Ewk_Frame> frame_;
734   std::unique_ptr<_Ewk_Policy_Decision> window_policy_;
735   Evas_Object* evas_object_;
736   Evas_Object* native_view_;
737   bool touch_events_enabled_;
738   bool mouse_events_enabled_;
739   double text_zoom_factor_;
740   mutable std::string user_agent_;
741   mutable std::string user_agent_app_name_;
742   std::unique_ptr<_Ewk_Auth_Challenge> auth_challenge_;
743   std::string selected_text_cached_;
744
745   Eina_List* popupMenuItems_;
746   Popup_Picker* popupPicker_;
747   bool formIsNavigating_;
748   typedef struct {
749     int count;
750     int position;
751     bool prevState;
752     bool nextState;
753   } formNavigation;
754   formNavigation formNavigation_;
755   std::unique_ptr<content::ContextMenuControllerEfl> context_menu_;
756 #if !defined(EWK_BRINGUP)  // FIXME: m71 bringup
757   std::unique_ptr<content::FileChooserControllerEfl> file_chooser_;
758 #endif
759   std::unique_ptr<content::PopupControllerEfl> popup_controller_;
760   std::u16string previous_text_;
761   int current_find_request_id_;
762   static int find_request_id_counter_;
763
764   typedef WebViewCallback<Ewk_View_Plain_Text_Get_Callback, const char*>
765       EwkViewPlainTextGetCallback;
766   base::IDMap<EwkViewPlainTextGetCallback*> plain_text_get_callback_map_;
767
768   typedef WebViewCallback<Ewk_View_MHTML_Data_Get_Callback, const char*>
769       MHTMLCallbackDetails;
770   base::IDMap<MHTMLCallbackDetails*> mhtml_callback_map_;
771
772   typedef WebViewCallback<Ewk_View_Main_Frame_Scrollbar_Visible_Get_Callback,
773                           bool>
774       MainFrameScrollbarVisibleGetCallback;
775   base::IDMap<MainFrameScrollbarVisibleGetCallback*>
776       main_frame_scrollbar_visible_callback_map_;
777
778   base::IDMap<BackgroundColorGetCallback*> background_color_get_callback_map_;
779
780   gfx::Size contents_size_;
781   double progress_;
782   mutable std::string title_;
783   Hit_Test_Params hit_test_params_;
784   base::WaitableEvent hit_test_completion_;
785   double page_scale_factor_;
786   double x_delta_;
787   double y_delta_;
788
789   WebViewCallback<Ewk_View_Geolocation_Permission_Callback,
790                   _Ewk_Geolocation_Permission_Request*>
791       geolocation_permission_cb_;
792   WebViewCallback<Ewk_View_User_Media_Permission_Callback,
793                   _Ewk_User_Media_Permission_Request*>
794       user_media_permission_cb_;
795   WebViewCallbackWithReturnValue<Ewk_User_Media_Permission_Query_Result,
796                                  Ewk_View_User_Media_Permission_Query_Callback,
797                                  _Ewk_User_Media_Permission_Query*>
798       user_media_permission_query_cb_;
799   WebViewCallback<Ewk_View_Unfocus_Allow_Callback, Ewk_Unfocus_Direction>
800       unfocus_allow_cb_;
801   WebViewCallback<Ewk_View_Notification_Permission_Callback,
802                   Ewk_Notification_Permission_Request*>
803       notification_permission_callback_;
804   WebViewCallback<Ewk_Quota_Permission_Request_Callback,
805                   const _Ewk_Quota_Permission_Request*>
806       quota_request_callback_;
807   WebViewCallback<Ewk_View_Authentication_Callback, _Ewk_Auth_Challenge*>
808       authentication_cb_;
809   WebViewCallback<Ewk_View_Scale_Changed_Callback, double> scale_changed_cb_;
810
811   std::unique_ptr<content::InputPicker> input_picker_;
812
813   DidChangeThemeColorCallback did_change_theme_color_callback_;
814
815   base::IDMap<WebApplicationIconUrlGetCallback*>
816       web_app_icon_url_get_callback_map_;
817   base::IDMap<WebApplicationIconUrlsGetCallback*>
818       web_app_icon_urls_get_callback_map_;
819   base::IDMap<WebApplicationCapableGetCallback*>
820       web_app_capable_get_callback_map_;
821   std::unique_ptr<PermissionPopupManager> permission_popup_manager_;
822   std::unique_ptr<ScrollDetector> scroll_detector_;
823
824   // Manages injecting native objects.
825   std::unique_ptr<content::GinNativeBridgeDispatcherHost>
826       gin_native_bridge_dispatcher_host_;
827
828   WebViewExceededQuotaCallback<
829       Ewk_View_Exceeded_Indexed_Database_Quota_Callback,
830       Ewk_Security_Origin*,
831       long long>
832       exceeded_indexed_db_quota_callback_;
833   std::unique_ptr<Ewk_Security_Origin> exceeded_indexed_db_quota_origin_;
834
835 #if BUILDFLAG(IS_TIZEN)
836   blink::mojom::FileChooserParams::Mode filechooser_mode_;
837 #endif
838   std::map<const _Ewk_Quota_Permission_Request*,
839            content::QuotaPermissionContext::PermissionCallback>
840       quota_permission_request_map_;
841
842   bool is_initialized_;
843
844   std::unique_ptr<_Ewk_Back_Forward_List> back_forward_list_;
845
846   static content::WebContentsEflDelegate::WebContentsCreateCallback
847       create_new_window_web_contents_cb_;
848
849  private:
850   gfx::Vector2d previous_scroll_position_;
851
852   gfx::Point context_menu_position_;
853
854   std::vector<IPC::Message*> delayed_messages_;
855
856   std::map<int64_t, WebViewAsyncRequestHitTestDataCallback*> hit_test_callback_;
857
858   content::AcceptLanguagesHelper::AcceptLangsChangedCallback
859       accept_langs_changed_callback_;
860
861   std::unique_ptr<aura::WindowTreeHost> host_;
862   std::unique_ptr<aura::client::FocusClient> focus_client_;
863   std::unique_ptr<aura::client::WindowParentingClient> window_parenting_client_;
864   content::DateTimeChooserEfl* date_time_chooser_ = nullptr;
865
866 #if defined(TIZEN_ATK_SUPPORT)
867   std::unique_ptr<EWebAccessibility> eweb_accessibility_;
868   bool lazy_initialize_atk_ = false;
869 #endif
870 };
871
872 const unsigned int g_default_tilt_motion_sensitivity = 3;
873
874 #endif