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.
14 #include "base/containers/id_map.h"
15 #include "base/functional/callback.h"
16 #include "base/synchronization/waitable_event.h"
17 #include "browser/input_picker/input_picker.h"
18 #include "content/browser/select_picker/select_picker_base.h"
19 #include "content/browser/selection/selection_controller_efl.h"
20 #include "content/browser/web_contents/web_contents_view_aura.h"
21 #include "content/browser/web_contents/web_contents_view_aura_helper_efl.h"
22 #include "content/common/input/event_with_latency_info.h"
23 #include "content/public/browser/context_menu_params.h"
24 #include "content/public/browser/navigation_controller.h"
25 #include "content/public/browser/web_contents_delegate.h"
26 #include "content/public/browser/webview_delegate.h"
27 #include "content/public/common/input_event_ack_state.h"
28 #include "content_browser_client_efl.h"
29 #include "context_menu_controller_efl.h"
30 #include "eweb_context.h"
31 #include "eweb_view_callbacks.h"
32 #include "file_chooser_controller_efl.h"
33 #include "permission_popup_manager.h"
34 #include "popup_controller_efl.h"
35 #include "private/ewk_auth_challenge_private.h"
36 #include "private/ewk_back_forward_list_private.h"
37 #include "private/ewk_history_private.h"
38 #include "private/ewk_hit_test_private.h"
39 #include "private/ewk_settings_private.h"
40 #include "private/ewk_web_application_icon_data_private.h"
41 #include "public/ewk_hit_test_internal.h"
42 #include "public/ewk_touch_internal.h"
43 #include "public/ewk_view_product.h"
44 #include "scroll_detector.h"
45 #include "third_party/blink/public/common/context_menu_data/menu_item_info.h"
46 #include "third_party/blink/public/mojom/choosers/file_chooser.mojom.h"
47 #include "third_party/blink/public/mojom/choosers/popup_menu.mojom.h"
48 #include "ui/aura/window_tree_host.h"
49 #include "ui/gfx/geometry/point.h"
50 #include "ui/gfx/geometry/size.h"
51 #include "web_contents_delegate_efl.h"
52 #if defined(TIZEN_PEPPER_EXTENSIONS)
53 #include "ewk_extension_system_delegate.h"
54 #include "public/ewk_value_product.h"
57 #if BUILDFLAG(IS_TIZEN_TV)
58 #include "third_party/blink/public/common/mediastream/media_devices.h"
64 class WindowParentingClient;
73 class RenderFrameHost;
75 class RenderWidgetHostViewAura;
76 class WebContentsDelegateEfl;
77 class WebContentsViewAura;
78 class ContextMenuControllerEfl;
79 class PopupControllerEfl;
80 class DateTimeChooserEfl;
82 class GinNativeBridgeDispatcherHost;
83 class NavigationHandle;
87 class _Ewk_App_Control;
88 class _Ewk_Policy_Decision;
91 class _Ewk_Quota_Permission_Request;
93 #if BUILDFLAG(IS_TIZEN_TV)
94 struct _Ewk_File_Chooser_Request;
97 #if defined(TIZEN_ATK_SUPPORT)
98 class EWebAccessibility;
101 template <typename CallbackPtr, typename CallbackParameter>
102 class WebViewCallback {
104 WebViewCallback() { Set(nullptr, nullptr); }
106 void Set(CallbackPtr cb, void* data) {
111 bool IsCallbackSet() const { return callback_; }
113 Eina_Bool Run(Evas_Object* webview,
114 CallbackParameter param,
115 Eina_Bool* callback_result) {
116 CHECK(callback_result);
117 if (IsCallbackSet()) {
118 *callback_result = callback_(webview, param, user_data_);
124 void Run(Evas_Object* webview, CallbackParameter param) {
126 callback_(webview, param, user_data_);
130 CallbackPtr callback_;
134 template <typename CallbackReturnValue,
135 typename CallbackPtr,
136 typename CallbackParameter>
137 class WebViewCallbackWithReturnValue {
139 WebViewCallbackWithReturnValue() { Set(nullptr, nullptr); }
141 void Set(CallbackPtr cb, void* data) {
146 /* LCOV_EXCL_START */
147 bool IsCallbackSet() const { return callback_; }
149 CallbackReturnValue Run(Evas_Object* webview, CallbackParameter param) {
151 return callback_(webview, param, user_data_);
158 CallbackPtr callback_;
162 template <typename CallbackPtr, typename... CallbackParameter>
163 class WebViewErrorPageLoadCallback {
165 WebViewErrorPageLoadCallback() { Set(nullptr, nullptr); }
167 void Set(CallbackPtr cb, void* data) {
172 bool IsCallbackSet() const { return callback_; }
174 void Run(Evas_Object* webview, CallbackParameter... param) {
176 callback_(webview, param..., user_data_);
180 CallbackPtr callback_;
184 template <typename CallbackPtr, typename... CallbackParameter>
185 class WebViewExceededQuotaCallback {
187 WebViewExceededQuotaCallback() { Set(nullptr, nullptr); }
189 void Set(CallbackPtr cb, void* data) {
194 bool IsCallbackSet() const { return callback_; }
196 /* LCOV_EXCL_START */
197 void Run(Evas_Object* webview, CallbackParameter... param) {
199 callback_(webview, param..., user_data_);
204 CallbackPtr callback_;
208 class BackgroundColorGetCallback {
210 BackgroundColorGetCallback(Ewk_View_Background_Color_Get_Callback func,
212 : func_(func), user_data_(user_data) {}
214 void Run(Evas_Object* webview, int r, int g, int b, int a) {
216 func_(webview, r, g, b, a, user_data_);
220 Ewk_View_Background_Color_Get_Callback func_;
224 class WebApplicationIconUrlGetCallback {
226 WebApplicationIconUrlGetCallback(Ewk_Web_App_Icon_URL_Get_Callback func,
228 : func_(func), user_data_(user_data) {}
229 void Run(const std::string& url) {
231 (func_)(url.c_str(), user_data_);
236 Ewk_Web_App_Icon_URL_Get_Callback func_;
240 class WebApplicationIconUrlsGetCallback {
242 WebApplicationIconUrlsGetCallback(Ewk_Web_App_Icon_URLs_Get_Callback func,
244 : func_(func), user_data_(user_data) {}
245 void Run(const std::map<std::string, std::string>& urls) {
247 Eina_List* list = NULL;
248 for (std::map<std::string, std::string>::const_iterator it = urls.begin();
249 it != urls.end(); ++it) {
250 _Ewk_Web_App_Icon_Data* data =
251 ewkWebAppIconDataCreate(it->first, it->second);
252 list = eina_list_append(list, data);
254 (func_)(list, user_data_);
259 Ewk_Web_App_Icon_URLs_Get_Callback func_;
263 class WebApplicationCapableGetCallback {
265 WebApplicationCapableGetCallback(Ewk_Web_App_Capable_Get_Callback func,
267 : func_(func), user_data_(user_data) {}
268 void Run(bool capable) {
270 (func_)(capable ? EINA_TRUE : EINA_FALSE, user_data_);
275 Ewk_Web_App_Capable_Get_Callback func_;
279 class DidChangeThemeColorCallback {
281 DidChangeThemeColorCallback() : callback_(nullptr), user_data_(nullptr) {}
282 void Set(Ewk_View_Did_Change_Theme_Color_Callback callback, void* user_data) {
283 callback_ = callback;
284 user_data_ = user_data;
286 void Run(Evas_Object* o, const SkColor& color) {
288 callback_(o, SkColorGetR(color), SkColorGetG(color), SkColorGetB(color),
289 SkColorGetA(color), user_data_);
293 Ewk_View_Did_Change_Theme_Color_Callback callback_;
297 #if BUILDFLAG(IS_TIZEN_TV)
298 class GetMediaDeviceCallback {
300 GetMediaDeviceCallback() : func_(nullptr), user_data_(nullptr) {}
302 void Set(Ewk_Media_Device_List_Get_Callback func, void* user_data) {
304 user_data_ = user_data;
307 void Run(EwkMediaDeviceInfo* device_list, int size) {
309 (func_)(device_list, size, user_data_);
314 Ewk_Media_Device_List_Get_Callback func_;
319 class WebViewAsyncRequestHitTestDataCallback;
320 class JavaScriptDialogManagerEfl;
321 class PermissionPopupManager;
325 static EWebView* FromEwkView(Evas_Object* ewk_view);
327 EWebView(Ewk_Context*, Evas_Object* smart_object);
330 // initialize data members and activate event handlers.
331 // call this once after created and before use
334 bool CreateNewWindow(content::WebViewDelegate::WebContentsCreateCallback);
335 static Evas_Object* GetHostWindowDelegate(const content::WebContents*);
337 content::WebContentsViewAura* wcva() const;
338 content::RenderWidgetHostViewAura* rwhva() const;
339 Ewk_Context* context() const { return context_.get(); }
340 Evas_Object* ewk_view() const { return ewk_view_; }
341 Evas_Object* efl_main_layout() const { return efl_main_layout_; }
342 Evas_Object* GetElmWindow() const;
343 Evas* GetEvas() const { return evas_object_evas_get(ewk_view_); }
344 PermissionPopupManager* GetPermissionPopupManager() const {
345 return permission_popup_manager_.get();
348 content::WebContents& web_contents() const { return *web_contents_.get(); }
349 content::WebContentsViewAura* GetWebContentsViewAura() const;
351 #if defined(TIZEN_ATK_SUPPORT)
352 EWebAccessibility& eweb_accessibility() const {
353 return *eweb_accessibility_.get();
357 template <EWebViewCallbacks::CallbackType callbackType>
358 EWebViewCallbacks::CallBack<callbackType> SmartCallback() const {
359 return EWebViewCallbacks::CallBack<callbackType>(ewk_view_);
363 void SetURL(const GURL& url, bool from_api = false);
364 const GURL& GetURL() const;
365 const GURL& GetOriginalURL() const;
367 void ReloadBypassingCache();
368 Eina_Bool CanGoBack();
369 Eina_Bool CanGoForward();
370 Eina_Bool HasFocus() const;
371 void SetFocus(Eina_Bool focus);
373 Eina_Bool GoForward();
377 #if BUILDFLAG(IS_TIZEN_TV)
378 void SetFloatVideoWindowState(bool enabled);
379 void NotifyDownloadableFontInfo(const char* scheme_id_uri,
383 std::vector<std::string> NotifyPlaybackState(int state,
386 const char* mime_type);
387 void SuspendNetworkLoading();
388 void ResumeNetworkLoading();
389 #endif // IS_TIZEN_TV
390 void SetSessionTimeout(uint64_t timeout);
391 double GetTextZoomFactor() const;
392 void SetTextZoomFactor(double text_zoom_factor);
393 double GetPageZoomFactor() const;
394 void SetPageZoomFactor(double page_zoom_factor);
395 void ExecuteEditCommand(const char* command, const char* value);
396 #if BUILDFLAG(IS_TIZEN)
397 void EnterDragState();
399 void SetOrientation(int orientation);
400 int GetOrientation();
401 bool TouchEventsEnabled() const;
402 void SetTouchEventsEnabled(bool enabled);
403 bool MouseEventsEnabled() const;
404 void SetMouseEventsEnabled(bool enabled);
405 void SendKeyEvent(Evas_Object* ewk_view, void* key_event, bool is_press);
406 bool SetKeyEventsEnabled(bool enabled);
407 void HandleTouchEvents(Ewk_Touch_Event_Type type,
408 const Eina_List* points,
409 const Evas_Modifier* modifiers);
412 bool ExecuteJavaScript(const char* script,
413 Ewk_View_Script_Execute_Callback callback,
415 bool SetUserAgent(const char* userAgent);
416 bool SetUserAgentAppName(const char* application_name);
417 #if BUILDFLAG(IS_TIZEN)
418 bool SetPrivateBrowsing(bool incognito);
419 bool GetPrivateBrowsing() const;
421 const char* GetUserAgent() const;
422 const char* GetUserAgentAppName() const;
423 const char* CacheSelectedText();
424 Ewk_Settings* GetSettings() { return settings_.get(); }
425 _Ewk_Frame* GetMainFrame();
426 void UpdateWebKitPreferences();
427 void LoadHTMLString(const char* html,
428 const char* base_uri,
429 const char* unreachable_uri);
430 void LoadPlainTextString(const char* plain_text);
432 void LoadHTMLStringOverridingCurrentEntry(const char* html,
433 const char* base_uri,
434 const char* unreachable_url);
435 void LoadData(const char* data,
437 const char* mime_type,
438 const char* encoding,
439 const char* base_uri,
440 const char* unreachable_uri = NULL,
441 bool should_replace_current_entry = false);
442 void InvokeLoadError(const GURL& url, int error_code, bool is_cancellation);
444 void SetViewAuthCallback(Ewk_View_Authentication_Callback callback,
446 void InvokeAuthCallback(LoginDelegateEfl* login_delegate,
448 const std::string& realm);
449 void Find(const char* text, Ewk_Find_Options);
450 void InvokeAuthCallbackOnUI(_Ewk_Auth_Challenge* auth_challenge);
451 void SetContentSecurityPolicy(const char* policy, Ewk_CSP_Header_Type type);
452 void HandlePopupMenu(std::vector<blink::mojom::MenuItemPtr> items,
455 const gfx::Rect& bounds);
456 void HidePopupMenu();
457 void DidSelectPopupMenuItems(std::vector<int>& indices);
458 void DidCancelPopupMenu();
459 void HandleLongPressGesture(const content::ContextMenuParams&);
460 void ShowContextMenu(const content::ContextMenuParams&);
461 void CancelContextMenu(int request_id);
462 void SetScale(double scale_factor);
463 void SetScaleChangedCallback(Ewk_View_Scale_Changed_Callback callback,
466 bool GetScrollPosition(int* x, int* y) const;
467 void SetScroll(int x, int y);
468 void UrlRequestSet(const char* url,
469 content::NavigationController::LoadURLType loadtype,
473 SelectPickerBase* GetSelectPicker() const { return select_picker_.get(); }
474 content::SelectionControllerEfl* GetSelectionController() const;
475 content::PopupControllerEfl* GetPopupController() const {
476 return popup_controller_.get();
478 ScrollDetector* GetScrollDetector() const { return scroll_detector_.get(); }
479 void MoveCaret(const gfx::Point& point);
480 void SelectFocusedLink();
481 bool GetSelectionRange(Eina_Rectangle* left_rect, Eina_Rectangle* right_rect);
482 Eina_Bool ClearSelection();
484 // Callback OnCopyFromBackingStore will be called once we get the snapshot
486 void OnCopyFromBackingStore(bool success, const SkBitmap& bitmap);
491 void UpdateContextMenu(bool is_password_input);
492 void RenderViewReady();
495 * Creates a snapshot of given rectangle from EWebView
497 * @param rect rectangle of EWebView which will be taken into snapshot
498 * @param scale_factor scale factor
499 * @return created snapshot or NULL if error occured.
500 * @note ownership of snapshot is passed to caller
502 Evas_Object* GetSnapshot(Eina_Rectangle rect, float scale_factor);
504 bool GetSnapshotAsync(Eina_Rectangle rect,
505 Ewk_Web_App_Screenshot_Captured_Callback callback,
508 void InvokePolicyResponseCallback(_Ewk_Policy_Decision* policy_decision,
510 void InvokePolicyNavigationCallback(const NavigationPolicyParams& params,
512 void UseSettingsFont();
514 _Ewk_Hit_Test* RequestHitTestDataAt(int x, int y, Ewk_Hit_Test_Mode mode);
515 Eina_Bool AsyncRequestHitTestDataAt(int x,
517 Ewk_Hit_Test_Mode mode,
518 Ewk_View_Hit_Test_Request_Callback,
520 _Ewk_Hit_Test* RequestHitTestDataAtBlinkCoords(int x,
522 Ewk_Hit_Test_Mode mode);
523 Eina_Bool AsyncRequestHitTestDataAtBlinkCords(
526 Ewk_Hit_Test_Mode mode,
527 Ewk_View_Hit_Test_Request_Callback,
529 void DispatchAsyncHitTestData(const Hit_Test_Params& params,
531 void UpdateHitTestData(const Hit_Test_Params& params);
533 int current_find_request_id() const { return current_find_request_id_; }
534 bool PlainTextGet(Ewk_View_Plain_Text_Get_Callback callback, void* user_data);
535 void InvokePlainTextGetCallback(const std::string& content_text,
536 int plain_text_get_callback_id);
537 int SetEwkViewPlainTextGetCallback(Ewk_View_Plain_Text_Get_Callback callback,
539 void SetViewGeolocationPermissionCallback(
540 Ewk_View_Geolocation_Permission_Callback callback,
542 bool InvokeViewGeolocationPermissionCallback(
543 _Ewk_Geolocation_Permission_Request*
544 geolocation_permission_request_context,
546 void SetViewUserMediaPermissionCallback(
547 Ewk_View_User_Media_Permission_Callback callback,
549 bool InvokeViewUserMediaPermissionCallback(
550 _Ewk_User_Media_Permission_Request* user_media_permission_request_context,
552 void SetViewUserMediaPermissionQueryCallback(
553 Ewk_View_User_Media_Permission_Query_Callback callback,
555 Ewk_User_Media_Permission_Query_Result
556 InvokeViewUserMediaPermissionQueryCallback(
557 _Ewk_User_Media_Permission_Query* user_media_permission_query_context);
559 void SetViewLoadErrorPageCallback(Ewk_View_Error_Page_Load_Callback callback,
561 const char* InvokeViewLoadErrorPageCallback(
564 const std::string& error_description);
565 bool IsLoadErrorPageCallbackSet() const;
566 void SetViewUnfocusAllowCallback(Ewk_View_Unfocus_Allow_Callback callback,
568 bool InvokeViewUnfocusAllowCallback(Ewk_Unfocus_Direction direction,
570 void DidChangeContentsSize(int width, int height);
571 const Eina_Rectangle GetContentsSize() const;
572 void GetScrollSize(int* w, int* h);
574 void SetProgressValue(double progress);
575 double GetProgressValue();
576 const char* GetTitle();
577 bool SaveAsPdf(int width, int height, const std::string& file_name);
578 void BackForwardListClear();
579 _Ewk_Back_Forward_List* GetBackForwardList() const;
580 void InvokeBackForwardListChangedCallback();
581 _Ewk_History* GetBackForwardHistory() const;
582 bool WebAppCapableGet(Ewk_Web_App_Capable_Get_Callback callback,
584 bool WebAppIconUrlGet(Ewk_Web_App_Icon_URL_Get_Callback callback,
586 bool WebAppIconUrlsGet(Ewk_Web_App_Icon_URLs_Get_Callback callback,
588 void InvokeWebAppCapableGetCallback(bool capable, int callbackId);
589 void InvokeWebAppIconUrlGetCallback(const std::string& iconUrl,
591 void InvokeWebAppIconUrlsGetCallback(
592 const std::map<std::string, std::string>& iconUrls,
594 void SetNotificationPermissionCallback(
595 Ewk_View_Notification_Permission_Callback callback,
597 bool IsNotificationPermissionCallbackSet() const;
598 bool InvokeNotificationPermissionCallback(
599 Ewk_Notification_Permission_Request* request);
601 bool GetMHTMLData(Ewk_View_MHTML_Data_Get_Callback callback, void* user_data);
602 void OnMHTMLContentGet(const std::string& mhtml_content, int callback_id);
603 bool SavePageAsMHTML(const std::string& path,
604 Ewk_View_Save_Page_Callback callback,
607 void ExitFullscreen();
609 void DidChangePageScaleFactor(double scale_factor);
610 void SetScaledContentsSize();
611 void SetJavaScriptAlertCallback(Ewk_View_JavaScript_Alert_Callback callback,
613 void JavaScriptAlertReply();
614 void SetJavaScriptConfirmCallback(
615 Ewk_View_JavaScript_Confirm_Callback callback,
617 void JavaScriptConfirmReply(bool result);
618 void SetJavaScriptPromptCallback(Ewk_View_JavaScript_Prompt_Callback callback,
620 void JavaScriptPromptReply(const char* result);
621 void set_renderer_crashed();
622 void GetPageScaleRange(double* min_scale, double* max_scale);
623 bool SetDrawsTransparentBackground(bool enabled);
624 bool GetDrawsTransparentBackground();
625 bool SetBackgroundColor(int red, int green, int blue, int alpha);
626 bool GetBackgroundColor(Ewk_View_Background_Color_Get_Callback callback,
628 void OnGetBackgroundColor(int callback_id, SkColor bg_color);
630 void GetSessionData(const char** data, unsigned* length) const;
631 bool RestoreFromSessionData(const char* data, unsigned length);
632 void ShowFileChooser(scoped_refptr<content::FileSelectListener> listener,
633 const blink::mojom::FileChooserParams&);
634 void SetBrowserFont();
635 bool IsDragging() const;
637 void RequestColorPicker(int r, int g, int b, int a);
638 bool SetColorPickerColor(int r, int g, int b, int a);
639 void InputPickerShow(ui::TextInputType input_type,
641 content::DateTimeChooserEfl* date_time_chooser);
643 void ShowContentsDetectedPopup(const char*);
645 // Returns TCP port number with Inspector, or 0 if error.
646 int StartInspectorServer(int port = 0);
647 bool StopInspectorServer();
649 void LoadNotFoundErrorPage(const std::string& invalidUrl);
650 static std::string GetPlatformLocale();
651 bool GetLinkMagnifierEnabled() const;
652 void SetLinkMagnifierEnabled(bool enabled);
654 bool GetHorizontalPanningHold() const;
655 void SetHorizontalPanningHold(bool hold);
656 bool GetVerticalPanningHold() const;
657 void SetVerticalPanningHold(bool hold);
659 void SetQuotaPermissionRequestCallback(
660 Ewk_Quota_Permission_Request_Callback callback,
662 #if !defined(EWK_BRINGUP) // FIXME: m114 bringup
663 void InvokeQuotaPermissionRequest(
664 _Ewk_Quota_Permission_Request* request,
665 content::QuotaPermissionContext::PermissionCallback cb);
666 void QuotaRequestReply(const _Ewk_Quota_Permission_Request* request,
668 void QuotaRequestCancel(const _Ewk_Quota_Permission_Request* request);
669 void SetViewMode(blink::WebViewMode view_mode);
671 gfx::Point GetContextMenuPosition() const;
673 content::ContextMenuControllerEfl* GetContextMenuController() {
674 return context_menu_.get();
677 bool SetMainFrameScrollbarVisible(bool visible);
678 bool GetMainFrameScrollbarVisible(
679 Ewk_View_Main_Frame_Scrollbar_Visible_Get_Callback callback,
681 void InvokeMainFrameScrollbarVisibleCallback(int callback_id, bool visible);
683 void ResetContextMenuController();
684 Eina_Bool AddJavaScriptMessageHandler(Evas_Object* view,
685 Ewk_View_Script_Message_Cb callback,
688 content::GinNativeBridgeDispatcherHost* GetGinNativeBridgeDispatcherHost()
690 return gin_native_bridge_dispatcher_host_.get();
692 bool SetPageVisibility(Ewk_Page_Visibility_State page_visibility_state);
694 void SetExceededIndexedDatabaseQuotaCallback(
695 Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback,
697 void InvokeExceededIndexedDatabaseQuotaCallback(const GURL& origin,
698 int64_t current_quota);
699 void ExceededIndexedDatabaseQuotaReply(bool allow);
701 #if defined(TIZEN_VIDEO_HOLE)
702 void EnableVideoHoleSupport();
705 #if defined(TIZEN_TBM_SUPPORT)
706 void SetOffscreenRendering(bool enable);
709 /// ---- Event handling
712 bool HandleMove(int x, int y);
713 bool HandleResize(int width, int height);
714 bool HandleTextSelectionDown(int x, int y);
715 bool HandleTextSelectionUp(int x, int y);
717 void HandleRendererProcessCrash();
718 void InvokeWebProcessCrashedCallback();
720 void HandleTapGestureForSelection(bool is_content_editable);
721 void HandleZoomGesture(blink::WebGestureEvent& event);
724 void RequestManifest(Ewk_View_Request_Manifest_Callback callback,
726 void DidRespondRequestManifest(_Ewk_View_Request_Manifest* manifest,
727 Ewk_View_Request_Manifest_Callback callback,
730 void SetBeforeUnloadConfirmPanelCallback(
731 Ewk_View_Before_Unload_Confirm_Panel_Callback callback,
733 void ReplyBeforeUnloadConfirmPanel(Eina_Bool result);
734 void SyncAcceptLanguages(const std::string& accept_languages);
736 #if BUILDFLAG(IS_TIZEN_TV)
737 //Browser edge scroll
738 bool EdgeScrollBy(int delta_x, int delta_y);
739 void GetMousePosition(gfx::Point&);
740 void InvokeEdgeScrollByCallback(const gfx::Point&, bool);
743 void OnOverscrolled(const gfx::Vector2dF& accumulated_overscroll,
744 const gfx::Vector2dF& latest_overscroll_delta);
746 bool SetVisibility(bool enable);
747 void SetDoNotTrack(Eina_Bool);
749 #if defined(TIZEN_ATK_SUPPORT)
750 void UpdateSpatialNavigationStatus(Eina_Bool enable);
751 void UpdateAccessibilityStatus(Eina_Bool enable);
753 bool CheckLazyInitializeAtk() {
754 return is_initialized_ && lazy_initialize_atk_;
759 #if defined(TIZEN_PEPPER_EXTENSIONS)
760 void InitializePepperExtensionSystem();
761 EwkExtensionSystemDelegate* GetExtensionDelegate();
763 void SetPepperExtensionWidgetInfo(Ewk_Value widget_pepper_ext_info);
764 void SetPepperExtensionCallback(Generic_Sync_Call_Callback cb, void* data);
765 void RegisterPepperExtensionDelegate();
766 void UnregisterPepperExtensionDelegate();
769 bool ShouldIgnoreNavigation(content::NavigationHandle* navigation_handle);
771 #if BUILDFLAG(IS_TIZEN_TV)
772 void DrawLabel(Evas_Object* image, Eina_Rectangle rect);
773 void DeactivateAtk(bool deactivated);
775 void AddDynamicCertificatePath(const std::string& host,
776 const std::string& cert_path);
778 bool SetMixedContents(bool allow);
779 void ClearAllTilesResources();
780 bool UseEarlyRWI() { return use_early_rwi_; }
781 bool RWIInfoShowed() { return rwi_info_showed_; }
782 GURL RWIURL() { return rwi_gurl_; }
783 void OnDialogClosed();
784 void NotifyMediaStateChanged(uint32_t type,
787 void SetHighBitRate(Eina_Bool is_high_bitrate);
788 bool IsHighBitRate() const { return is_high_bitrate_; }
790 void GetMediaDeviceList(Ewk_Media_Device_List_Get_Callback callback,
792 using MediaDeviceEnumeration =
793 std::array<blink::WebMediaDeviceInfoArray, NUM_MEDIA_DEVICE_TYPES>;
794 void OnDeviceListed(const MediaDeviceEnumeration& devices);
795 void SetTranslatedURL(const char* url);
796 #endif // IS_TIZEN_TV
798 void SetDidChangeThemeColorCallback(
799 Ewk_View_Did_Change_Theme_Color_Callback callback,
801 void DidChangeThemeColor(const SkColor& color);
803 void OnSelectionRectReceived(const gfx::Rect& selection_rect) const;
806 static void NativeViewResize(void* data,
810 void InitializeContent();
811 void InitializeWindowTreeHost();
812 void SendDelayedMessages(content::RenderViewHost* render_view_host);
814 void EvasToBlinkCords(int x, int y, int* view_x, int* view_y);
815 Eina_Bool AsyncRequestHitTestDataAtBlinkCords(
818 Ewk_Hit_Test_Mode mode,
819 WebViewAsyncRequestHitTestDataCallback* cb);
821 #if BUILDFLAG(IS_TIZEN_TV)
822 void InitInspectorServer();
824 void RunPendingSetFocus(Eina_Bool focus);
825 void SetFocusInternal(Eina_Bool focus);
828 JavaScriptDialogManagerEfl* GetJavaScriptDialogManagerEfl();
830 // Changes viewport without resizing Evas_Object representing webview
831 // and its corresponding RWHV to let Blink renders custom viewport
832 // while showing picker.
833 void AdjustViewPortHeightToPopupMenu(bool is_popup_menu_visible);
835 void ShowContextMenuInternal(const content::ContextMenuParams&);
837 void UpdateWebkitPreferencesEfl(content::RenderViewHost*);
839 void ChangeScroll(int& x, int& y);
840 void ScrollFocusedNodeIntoView();
842 void GenerateMHTML(Ewk_View_Save_Page_Callback callback,
844 const base::FilePath& file_path);
845 void MHTMLGenerated(Ewk_View_Save_Page_Callback callback,
847 const base::FilePath& file_path,
850 static void VisibleContentChangedCallback(void* user_data,
854 static void OnCustomScrollBeginCallback(void* user_data,
858 static void OnCustomScrollEndCallback(void* user_data,
861 void UpdateContextMenuWithParams(const content::ContextMenuParams& params);
863 static Eina_Bool DelayedPopulateAndShowContextMenu(void* data);
865 scoped_refptr<Ewk_Context> context_;
866 std::unique_ptr<content::WebContents> web_contents_;
867 std::unique_ptr<content::WebContentsDelegateEfl> web_contents_delegate_;
868 std::unique_ptr<content::WebViewDelegate> webview_delegate_;
869 std::string pending_url_request_;
870 std::unique_ptr<Ewk_Settings> settings_;
871 std::unique_ptr<_Ewk_Frame> frame_;
872 std::unique_ptr<_Ewk_Policy_Decision> window_policy_;
873 Evas_Object* ewk_view_;
874 Evas_Object* efl_main_layout_;
875 bool key_events_enabled_ = true;
876 bool mouse_events_enabled_;
877 double text_zoom_factor_;
878 mutable std::string user_agent_;
879 mutable std::string user_agent_app_name_;
880 std::unique_ptr<_Ewk_Auth_Challenge> auth_challenge_;
881 std::string selected_text_cached_;
883 std::unique_ptr<content::ContextMenuControllerEfl> context_menu_;
884 #if BUILDFLAG(IS_TIZEN_TV)
885 std::unique_ptr<_Ewk_File_Chooser_Request> file_chooser_request_;
887 std::unique_ptr<content::FileChooserControllerEfl> file_chooser_;
889 std::unique_ptr<content::PopupControllerEfl> popup_controller_;
890 std::u16string previous_text_;
891 int current_find_request_id_;
892 static int find_request_id_counter_;
894 typedef WebViewCallback<Ewk_View_Plain_Text_Get_Callback, const char*>
895 EwkViewPlainTextGetCallback;
896 base::IDMap<EwkViewPlainTextGetCallback*> plain_text_get_callback_map_;
898 typedef WebViewCallback<Ewk_View_MHTML_Data_Get_Callback, const char*>
899 MHTMLCallbackDetails;
900 base::IDMap<MHTMLCallbackDetails*> mhtml_callback_map_;
902 typedef WebViewCallback<Ewk_View_Main_Frame_Scrollbar_Visible_Get_Callback,
904 MainFrameScrollbarVisibleGetCallback;
905 base::IDMap<MainFrameScrollbarVisibleGetCallback*>
906 main_frame_scrollbar_visible_callback_map_;
908 base::IDMap<BackgroundColorGetCallback*> background_color_get_callback_map_;
910 #if BUILDFLAG(IS_TIZEN_TV)
911 GetMediaDeviceCallback device_cb_;
914 gfx::Size contents_size_;
916 mutable std::string title_;
917 Hit_Test_Params hit_test_params_;
918 base::WaitableEvent hit_test_completion_;
919 double page_scale_factor_;
923 WebViewCallback<Ewk_View_Geolocation_Permission_Callback,
924 _Ewk_Geolocation_Permission_Request*>
925 geolocation_permission_cb_;
926 WebViewCallback<Ewk_View_User_Media_Permission_Callback,
927 _Ewk_User_Media_Permission_Request*>
928 user_media_permission_cb_;
929 WebViewCallbackWithReturnValue<Ewk_User_Media_Permission_Query_Result,
930 Ewk_View_User_Media_Permission_Query_Callback,
931 _Ewk_User_Media_Permission_Query*>
932 user_media_permission_query_cb_;
933 WebViewErrorPageLoadCallback<Ewk_View_Error_Page_Load_Callback,
937 WebViewCallback<Ewk_View_Unfocus_Allow_Callback, Ewk_Unfocus_Direction>
939 WebViewCallback<Ewk_View_Notification_Permission_Callback,
940 Ewk_Notification_Permission_Request*>
941 notification_permission_callback_;
942 WebViewCallback<Ewk_Quota_Permission_Request_Callback,
943 const _Ewk_Quota_Permission_Request*>
944 quota_request_callback_;
945 WebViewCallback<Ewk_View_Authentication_Callback, _Ewk_Auth_Challenge*>
947 WebViewCallback<Ewk_View_Scale_Changed_Callback, double> scale_changed_cb_;
949 std::unique_ptr<content::InputPicker> input_picker_;
951 DidChangeThemeColorCallback did_change_theme_color_callback_;
953 base::IDMap<WebApplicationIconUrlGetCallback*>
954 web_app_icon_url_get_callback_map_;
955 base::IDMap<WebApplicationIconUrlsGetCallback*>
956 web_app_icon_urls_get_callback_map_;
957 base::IDMap<WebApplicationCapableGetCallback*>
958 web_app_capable_get_callback_map_;
959 std::unique_ptr<PermissionPopupManager> permission_popup_manager_;
960 std::unique_ptr<ScrollDetector> scroll_detector_;
962 // Manages injecting native objects.
963 std::unique_ptr<content::GinNativeBridgeDispatcherHost>
964 gin_native_bridge_dispatcher_host_;
966 WebViewExceededQuotaCallback<
967 Ewk_View_Exceeded_Indexed_Database_Quota_Callback,
968 Ewk_Security_Origin*,
970 exceeded_indexed_db_quota_callback_;
971 std::unique_ptr<Ewk_Security_Origin> exceeded_indexed_db_quota_origin_;
972 #if !defined(EWK_BRINGUP) // FIXME: m114 bringup
973 std::map<const _Ewk_Quota_Permission_Request*,
974 content::QuotaPermissionContext::PermissionCallback>
975 quota_permission_request_map_;
977 #if BUILDFLAG(IS_TIZEN)
978 blink::mojom::FileChooserParams::Mode filechooser_mode_ =
979 blink::mojom::FileChooserParams::Mode::kOpen;
980 Ecore_Event_Handler* window_rotate_handler_ = nullptr;
983 bool is_initialized_;
985 #if BUILDFLAG(IS_TIZEN_TV)
986 bool is_processing_edge_scroll_;
988 bool rwi_info_showed_;
990 bool is_high_bitrate_ = false;
992 base::OnceClosure pending_setfocus_closure_;
996 // kPlaybackReady: player with both audio and video starts prepare and will
997 // acquire audio and video resources (if they are not already taken)
1005 std::unique_ptr<_Ewk_Back_Forward_List> back_forward_list_;
1007 static content::WebViewDelegate::WebContentsCreateCallback
1008 create_new_window_web_contents_cb_;
1010 #if defined(TIZEN_VIDEO_HOLE)
1011 void EnableVideoHoleSupportInternal();
1013 gfx::Vector2d previous_scroll_position_;
1015 gfx::Point context_menu_position_;
1017 content::ContextMenuParams saved_context_menu_params_;
1019 std::vector<IPC::Message*> delayed_messages_;
1021 std::map<int64_t, WebViewAsyncRequestHitTestDataCallback*> hit_test_callback_;
1023 content::AcceptLanguagesHelper::AcceptLangsChangedCallback
1024 accept_langs_changed_callback_;
1026 std::unique_ptr<SelectPickerBase> select_picker_;
1027 std::unique_ptr<aura::WindowTreeHost> host_;
1028 std::unique_ptr<aura::client::FocusClient> focus_client_;
1029 std::unique_ptr<aura::client::WindowParentingClient> window_parenting_client_;
1030 std::unique_ptr<ui::CompositorObserver> compositor_observer_;
1032 #if defined(TIZEN_ATK_SUPPORT)
1033 std::unique_ptr<EWebAccessibility> eweb_accessibility_;
1034 bool lazy_initialize_atk_ = false;
1036 #if defined(TIZEN_PEPPER_EXTENSIONS)
1037 content::ExtensionSystemDelegateManager::RenderFrameID render_frame_id_;
1039 #if defined(TIZEN_VIDEO_HOLE)
1040 bool pending_video_hole_setting_ = false;
1043 Ecore_Timer* delayed_show_context_menu_timer_ = nullptr;
1044 base::WeakPtrFactory<EWebView> weak_factory_{this};
1047 const unsigned int g_default_tilt_motion_sensitivity = 3;