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