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