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