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