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 #if BUILDFLAG(IS_TIZEN_TV)
320 class IsVideoPlayingCallback {
322 IsVideoPlayingCallback(Ewk_Is_Video_Playing_Callback func, void* user_data)
323 : func_(func), user_data_(user_data) {}
324 void Run(Evas_Object* obj, bool isplaying) {
326 (func_)(obj, isplaying ? EINA_TRUE : EINA_FALSE, user_data_);
331 Ewk_Is_Video_Playing_Callback func_;
336 class WebViewAsyncRequestHitTestDataCallback;
337 class JavaScriptDialogManagerEfl;
338 class PermissionPopupManager;
342 static EWebView* FromEwkView(Evas_Object* ewk_view);
344 EWebView(Ewk_Context*, Evas_Object* smart_object);
347 // initialize data members and activate event handlers.
348 // call this once after created and before use
351 bool CreateNewWindow(content::WebViewDelegate::WebContentsCreateCallback);
352 static Evas_Object* GetHostWindowDelegate(const content::WebContents*);
354 content::WebContentsViewAura* wcva() const;
355 content::RenderWidgetHostViewAura* rwhva() const;
356 Ewk_Context* context() const { return context_.get(); }
357 Evas_Object* ewk_view() const { return ewk_view_; }
358 Evas_Object* efl_main_layout() const { return efl_main_layout_; }
359 Evas_Object* GetElmWindow() const;
360 Evas* GetEvas() const { return evas_object_evas_get(ewk_view_); }
361 PermissionPopupManager* GetPermissionPopupManager() const {
362 return permission_popup_manager_.get();
365 content::WebContents& web_contents() const { return *web_contents_.get(); }
366 content::WebContentsViewAura* GetWebContentsViewAura() const;
368 #if defined(TIZEN_ATK_SUPPORT)
369 EWebAccessibility& eweb_accessibility() const {
370 return *eweb_accessibility_.get();
374 template <EWebViewCallbacks::CallbackType callbackType>
375 EWebViewCallbacks::CallBack<callbackType> SmartCallback() const {
376 return EWebViewCallbacks::CallBack<callbackType>(ewk_view_);
380 void SetURL(const GURL& url, bool from_api = false);
381 const GURL& GetURL() const;
382 const GURL& GetOriginalURL() const;
384 void ReloadBypassingCache();
385 Eina_Bool CanGoBack();
386 Eina_Bool CanGoForward();
387 Eina_Bool HasFocus() const;
388 void SetFocus(Eina_Bool focus);
390 Eina_Bool GoForward();
394 #if BUILDFLAG(IS_TIZEN_TV)
395 void SetFloatVideoWindowState(bool enabled);
396 void NotifyDownloadableFontInfo(const char* scheme_id_uri,
400 std::vector<std::string> NotifyPlaybackState(int state,
403 const char* mime_type);
404 void SuspendNetworkLoading();
405 void ResumeNetworkLoading();
406 void NotifyAudioTracksCount(int player_id, unsigned audio_tracks_count);
407 #endif // IS_TIZEN_TV
408 void SetSessionTimeout(uint64_t timeout);
409 double GetTextZoomFactor() const;
410 void SetTextZoomFactor(double text_zoom_factor);
411 double GetPageZoomFactor() const;
412 void SetPageZoomFactor(double page_zoom_factor);
413 void ExecuteEditCommand(const char* command, const char* value);
414 #if BUILDFLAG(IS_TIZEN)
415 void EnterDragState();
417 void SetOrientation(int orientation);
418 int GetOrientation();
419 bool TouchEventsEnabled() const;
420 void SetTouchEventsEnabled(bool enabled);
421 bool MouseEventsEnabled() const;
422 void SetMouseEventsEnabled(bool enabled);
423 void SendKeyEvent(Evas_Object* ewk_view, void* key_event, bool is_press);
424 bool SetKeyEventsEnabled(bool enabled);
425 void HandleTouchEvents(Ewk_Touch_Event_Type type,
426 const Eina_List* points,
427 const Evas_Modifier* modifiers);
430 bool ExecuteJavaScript(const char* script,
431 Ewk_View_Script_Execute_Callback callback,
433 bool SetUserAgent(const char* userAgent);
434 bool SetUserAgentAppName(const char* application_name);
435 #if BUILDFLAG(IS_TIZEN)
436 bool SetPrivateBrowsing(bool incognito);
437 bool GetPrivateBrowsing() const;
439 const char* GetUserAgent() const;
440 const char* GetUserAgentAppName() const;
441 const char* CacheSelectedText();
442 Ewk_Settings* GetSettings() { return settings_.get(); }
443 _Ewk_Frame* GetMainFrame();
444 void UpdateWebKitPreferences();
445 void LoadHTMLString(const char* html,
446 const char* base_uri,
447 const char* unreachable_uri);
448 void LoadPlainTextString(const char* plain_text);
450 void LoadHTMLStringOverridingCurrentEntry(const char* html,
451 const char* base_uri,
452 const char* unreachable_url);
453 void LoadData(const char* data,
455 const char* mime_type,
456 const char* encoding,
457 const char* base_uri,
458 const char* unreachable_uri = NULL,
459 bool should_replace_current_entry = false);
460 void InvokeLoadError(const GURL& url, int error_code, bool is_cancellation);
462 void SetViewAuthCallback(Ewk_View_Authentication_Callback callback,
464 void InvokeAuthCallback(LoginDelegateEfl* login_delegate,
466 const std::string& realm);
467 void Find(const char* text, Ewk_Find_Options);
468 void InvokeAuthCallbackOnUI(_Ewk_Auth_Challenge* auth_challenge);
469 void SetContentSecurityPolicy(const char* policy, Ewk_CSP_Header_Type type);
470 void HandlePopupMenu(std::vector<blink::mojom::MenuItemPtr> items,
473 const gfx::Rect& bounds);
474 void HidePopupMenu();
475 void DidSelectPopupMenuItems(std::vector<int>& indices);
476 void DidCancelPopupMenu();
477 void HandleLongPressGesture(const content::ContextMenuParams&);
478 void ShowContextMenu(const content::ContextMenuParams&);
479 void CancelContextMenu(int request_id);
480 void SetScale(double scale_factor);
481 void SetScaleChangedCallback(Ewk_View_Scale_Changed_Callback callback,
484 bool GetScrollPosition(int* x, int* y) const;
485 void SetScroll(int x, int y);
486 void UrlRequestSet(const char* url,
487 content::NavigationController::LoadURLType loadtype,
491 SelectPickerBase* GetSelectPicker() const { return select_picker_.get(); }
492 content::SelectionControllerEfl* GetSelectionController() const;
493 content::PopupControllerEfl* GetPopupController() const {
494 return popup_controller_.get();
496 ScrollDetector* GetScrollDetector() const { return scroll_detector_.get(); }
497 void MoveCaret(const gfx::Point& point);
498 void SelectFocusedLink();
499 bool GetSelectionRange(Eina_Rectangle* left_rect, Eina_Rectangle* right_rect);
500 Eina_Bool ClearSelection();
502 // Callback OnCopyFromBackingStore will be called once we get the snapshot
504 void OnCopyFromBackingStore(bool success, const SkBitmap& bitmap);
509 void UpdateContextMenu(bool is_password_input);
510 void RenderViewReady();
513 * Creates a snapshot of given rectangle from EWebView
515 * @param rect rectangle of EWebView which will be taken into snapshot
516 * @param scale_factor scale factor
517 * @return created snapshot or NULL if error occured.
518 * @note ownership of snapshot is passed to caller
520 Evas_Object* GetSnapshot(Eina_Rectangle rect, float scale_factor);
522 bool GetSnapshotAsync(Eina_Rectangle rect,
523 Ewk_Web_App_Screenshot_Captured_Callback callback,
526 void InvokePolicyResponseCallback(_Ewk_Policy_Decision* policy_decision,
528 void InvokePolicyNavigationCallback(const NavigationPolicyParams& params,
530 void UseSettingsFont();
532 _Ewk_Hit_Test* RequestHitTestDataAt(int x, int y, Ewk_Hit_Test_Mode mode);
533 Eina_Bool AsyncRequestHitTestDataAt(int x,
535 Ewk_Hit_Test_Mode mode,
536 Ewk_View_Hit_Test_Request_Callback,
538 _Ewk_Hit_Test* RequestHitTestDataAtBlinkCoords(int x,
540 Ewk_Hit_Test_Mode mode);
541 Eina_Bool AsyncRequestHitTestDataAtBlinkCords(
544 Ewk_Hit_Test_Mode mode,
545 Ewk_View_Hit_Test_Request_Callback,
547 void DispatchAsyncHitTestData(const Hit_Test_Params& params,
549 void UpdateHitTestData(const Hit_Test_Params& params);
551 int current_find_request_id() const { return current_find_request_id_; }
552 bool PlainTextGet(Ewk_View_Plain_Text_Get_Callback callback, void* user_data);
553 void InvokePlainTextGetCallback(const std::string& content_text,
554 int plain_text_get_callback_id);
555 int SetEwkViewPlainTextGetCallback(Ewk_View_Plain_Text_Get_Callback callback,
557 void SetViewGeolocationPermissionCallback(
558 Ewk_View_Geolocation_Permission_Callback callback,
560 bool InvokeViewGeolocationPermissionCallback(
561 _Ewk_Geolocation_Permission_Request*
562 geolocation_permission_request_context,
564 void SetViewUserMediaPermissionCallback(
565 Ewk_View_User_Media_Permission_Callback callback,
567 bool InvokeViewUserMediaPermissionCallback(
568 _Ewk_User_Media_Permission_Request* user_media_permission_request_context,
570 void SetViewUserMediaPermissionQueryCallback(
571 Ewk_View_User_Media_Permission_Query_Callback callback,
573 Ewk_User_Media_Permission_Query_Result
574 InvokeViewUserMediaPermissionQueryCallback(
575 _Ewk_User_Media_Permission_Query* user_media_permission_query_context);
577 void SetViewLoadErrorPageCallback(Ewk_View_Error_Page_Load_Callback callback,
579 const char* InvokeViewLoadErrorPageCallback(const GURL& url,
581 bool is_cancellation);
582 bool IsLoadErrorPageCallbackSet() const;
583 void SetViewUnfocusAllowCallback(Ewk_View_Unfocus_Allow_Callback callback,
585 bool InvokeViewUnfocusAllowCallback(Ewk_Unfocus_Direction direction,
587 #if BUILDFLAG(IS_TIZEN_TV)
588 void SetViewSmartrcMicNotificationCallback(
589 Ewk_View_SmartRC_Mic_Notification_Callback callback,
591 void ShowMicOpenedNotification(bool show);
593 void DidChangeContentsSize(int width, int height);
594 const Eina_Rectangle GetContentsSize() const;
595 void GetScrollSize(int* w, int* h);
597 void SetProgressValue(double progress);
598 double GetProgressValue();
599 const char* GetTitle();
600 bool SaveAsPdf(int width, int height, const std::string& file_name);
601 void BackForwardListClear();
602 _Ewk_Back_Forward_List* GetBackForwardList() const;
603 void InvokeBackForwardListChangedCallback();
604 _Ewk_History* GetBackForwardHistory() const;
605 bool WebAppCapableGet(Ewk_Web_App_Capable_Get_Callback callback,
607 bool WebAppIconUrlGet(Ewk_Web_App_Icon_URL_Get_Callback callback,
609 bool WebAppIconUrlsGet(Ewk_Web_App_Icon_URLs_Get_Callback callback,
611 void InvokeWebAppCapableGetCallback(bool capable, int callbackId);
612 void InvokeWebAppIconUrlGetCallback(const std::string& iconUrl,
614 void InvokeWebAppIconUrlsGetCallback(
615 const std::map<std::string, std::string>& iconUrls,
617 void SetNotificationPermissionCallback(
618 Ewk_View_Notification_Permission_Callback callback,
620 bool IsNotificationPermissionCallbackSet() const;
621 bool InvokeNotificationPermissionCallback(
622 Ewk_Notification_Permission_Request* request);
624 bool GetMHTMLData(Ewk_View_MHTML_Data_Get_Callback callback, void* user_data);
625 void OnMHTMLContentGet(const std::string& mhtml_content, int callback_id);
626 bool SavePageAsMHTML(const std::string& path,
627 Ewk_View_Save_Page_Callback callback,
630 void ExitFullscreen();
632 void DidChangePageScaleFactor(double scale_factor);
633 void SetScaledContentsSize();
634 void SetJavaScriptAlertCallback(Ewk_View_JavaScript_Alert_Callback callback,
636 void JavaScriptAlertReply();
637 void SetJavaScriptConfirmCallback(
638 Ewk_View_JavaScript_Confirm_Callback callback,
640 void JavaScriptConfirmReply(bool result);
641 void SetJavaScriptPromptCallback(Ewk_View_JavaScript_Prompt_Callback callback,
643 void JavaScriptPromptReply(const char* result);
644 void set_renderer_crashed();
645 void GetPageScaleRange(double* min_scale, double* max_scale);
646 bool SetDrawsTransparentBackground(bool enabled);
647 bool GetDrawsTransparentBackground();
648 bool SetBackgroundColor(int red, int green, int blue, int alpha);
649 bool GetBackgroundColor(Ewk_View_Background_Color_Get_Callback callback,
651 void OnGetBackgroundColor(int callback_id, SkColor bg_color);
653 void GetSessionData(const char** data, unsigned* length) const;
654 bool RestoreFromSessionData(const char* data, unsigned length);
655 void ShowFileChooser(scoped_refptr<content::FileSelectListener> listener,
656 const blink::mojom::FileChooserParams&);
657 void SetBrowserFont();
658 bool IsDragging() const;
660 void RequestColorPicker(int r, int g, int b, int a);
661 bool SetColorPickerColor(int r, int g, int b, int a);
662 void InputPickerShow(ui::TextInputType input_type,
664 content::DateTimeChooserEfl* date_time_chooser);
666 void ShowContentsDetectedPopup(const char*);
668 // Returns TCP port number with Inspector, or 0 if error.
669 int StartInspectorServer(int port = 0);
670 bool StopInspectorServer();
672 void LoadNotFoundErrorPage(const std::string& invalidUrl);
673 static std::string GetPlatformLocale();
674 bool GetLinkMagnifierEnabled() const;
675 void SetLinkMagnifierEnabled(bool enabled);
677 bool GetHorizontalPanningHold() const;
678 void SetHorizontalPanningHold(bool hold);
679 bool GetVerticalPanningHold() const;
680 void SetVerticalPanningHold(bool hold);
682 bool GetRotationChanged() { return rotation_changed_; }
683 void SetRotationChanged(bool change) { rotation_changed_ = change; }
685 void SetQuotaPermissionRequestCallback(
686 Ewk_Quota_Permission_Request_Callback callback,
688 #if !defined(EWK_BRINGUP) // FIXME: m114 bringup
689 void InvokeQuotaPermissionRequest(
690 _Ewk_Quota_Permission_Request* request,
691 content::QuotaPermissionContext::PermissionCallback cb);
692 void QuotaRequestReply(const _Ewk_Quota_Permission_Request* request,
694 void QuotaRequestCancel(const _Ewk_Quota_Permission_Request* request);
695 void SetViewMode(blink::WebViewMode view_mode);
697 gfx::Point GetContextMenuPosition() const;
699 content::ContextMenuControllerEfl* GetContextMenuController() {
700 return context_menu_.get();
703 bool SetMainFrameScrollbarVisible(bool visible);
704 bool GetMainFrameScrollbarVisible(
705 Ewk_View_Main_Frame_Scrollbar_Visible_Get_Callback callback,
707 void InvokeMainFrameScrollbarVisibleCallback(int callback_id, bool visible);
709 void ResetContextMenuController();
710 Eina_Bool AddJavaScriptMessageHandler(Evas_Object* view,
711 Ewk_View_Script_Message_Cb callback,
714 content::GinNativeBridgeDispatcherHost* GetGinNativeBridgeDispatcherHost()
716 return gin_native_bridge_dispatcher_host_.get();
718 bool SetPageVisibility(Ewk_Page_Visibility_State page_visibility_state);
720 void SetExceededIndexedDatabaseQuotaCallback(
721 Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback,
723 void InvokeExceededIndexedDatabaseQuotaCallback(const GURL& origin,
724 int64_t current_quota);
725 void ExceededIndexedDatabaseQuotaReply(bool allow);
727 #if defined(TIZEN_VIDEO_HOLE)
728 void EnableVideoHoleSupport();
731 #if defined(TIZEN_TBM_SUPPORT)
732 void SetOffscreenRendering(bool enable);
735 /// ---- Event handling
738 bool HandleMove(int x, int y);
739 bool HandleResize(int width, int height);
740 bool HandleTextSelectionDown(int x, int y);
741 bool HandleTextSelectionUp(int x, int y);
743 void HandleRendererProcessCrash();
744 void InvokeWebProcessCrashedCallback();
746 void HandleTapGestureForSelection(bool is_content_editable);
747 void HandleZoomGesture(blink::WebGestureEvent& event);
750 void RequestManifest(Ewk_View_Request_Manifest_Callback callback,
752 void DidRespondRequestManifest(_Ewk_View_Request_Manifest* manifest,
753 Ewk_View_Request_Manifest_Callback callback,
756 void SetBeforeUnloadConfirmPanelCallback(
757 Ewk_View_Before_Unload_Confirm_Panel_Callback callback,
759 void ReplyBeforeUnloadConfirmPanel(Eina_Bool result);
760 void SyncAcceptLanguages(const std::string& accept_languages);
762 #if BUILDFLAG(IS_TIZEN_TV)
763 //Browser edge scroll
764 bool EdgeScrollBy(int delta_x, int delta_y);
765 void GetMousePosition(gfx::Point&);
766 void InvokeEdgeScrollByCallback(const gfx::Point&, bool);
767 // notify web browser video playing status
768 bool IsVideoPlaying(Ewk_Is_Video_Playing_Callback callback, void* user_data);
769 void InvokeIsVideoPlayingCallback(bool is_playing, int callback_id);
770 void InvokeScrollbarThumbFocusChangedCallback(
771 Ewk_Scrollbar_Orientation orientation,
775 void OnOverscrolled(const gfx::Vector2dF& accumulated_overscroll,
776 const gfx::Vector2dF& latest_overscroll_delta);
778 bool SetVisibility(bool enable);
779 void SetDoNotTrack(Eina_Bool);
781 #if defined(TIZEN_ATK_SUPPORT)
782 void UpdateSpatialNavigationStatus(Eina_Bool enable);
783 void UpdateAccessibilityStatus(Eina_Bool enable);
785 bool CheckLazyInitializeAtk() {
786 return is_initialized_ && lazy_initialize_atk_;
791 #if defined(TIZEN_PEPPER_EXTENSIONS)
792 void InitializePepperExtensionSystem();
793 EwkExtensionSystemDelegate* GetExtensionDelegate();
795 void SetPepperExtensionWidgetInfo(Ewk_Value widget_pepper_ext_info);
796 void SetPepperExtensionCallback(Generic_Sync_Call_Callback cb, void* data);
797 void RegisterPepperExtensionDelegate();
798 void UnregisterPepperExtensionDelegate();
801 bool ShouldIgnoreNavigation(content::NavigationHandle* navigation_handle);
803 #if BUILDFLAG(IS_TIZEN_TV)
804 void DrawLabel(Evas_Object* image, Eina_Rectangle rect);
805 void DeactivateAtk(bool deactivated);
807 void AddDynamicCertificatePath(const std::string& host,
808 const std::string& cert_path);
810 bool SetMixedContents(bool allow);
811 void ClearAllTilesResources();
812 bool UseEarlyRWI() { return use_early_rwi_; }
813 bool RWIInfoShowed() { return rwi_info_showed_; }
814 GURL RWIURL() { return rwi_gurl_; }
815 void OnDialogClosed();
816 void NotifyMediaStateChanged(uint32_t type,
819 void SetHighBitRate(Eina_Bool is_high_bitrate);
820 bool IsHighBitRate() const { return is_high_bitrate_; }
821 void NotifyFirstTimeStamp(unsigned long long timestamp,
824 void NotifyPESData(const std::string& buf,
827 void SetPreferSubtitleLang(const char* lang_list);
828 void NotifySubtitleState(int state, double time_stamp);
829 void NotifySubtitlePlay(int active_track_id,
832 void NotifySubtitleData(int track_id,
834 const std::string& data,
836 void UpdateCurrentTime(double current_time);
837 void UpdateEventData(void* data);
838 double GetCurrentTime() { return current_time_; }
839 void GetMediaDeviceList(Ewk_Media_Device_List_Get_Callback callback,
841 using MediaDeviceEnumeration =
842 std::array<blink::WebMediaDeviceInfoArray, NUM_MEDIA_DEVICE_TYPES>;
843 void OnDeviceListed(const MediaDeviceEnumeration& devices);
844 void SetTranslatedURL(const char* url);
845 void NotifyParentalRatingInfo(const char* info, const char* url);
846 void SetParentalRatingResult(const char* info, bool is_pass);
847 void OnMouseLongPressed(int x, int y);
848 void OnMouseDown(int x, int y);
851 #endif // IS_TIZEN_TV
853 void SetDidChangeThemeColorCallback(
854 Ewk_View_Did_Change_Theme_Color_Callback callback,
856 void DidChangeThemeColor(const SkColor& color);
858 void OnSelectionRectReceived(const gfx::Rect& selection_rect) const;
861 static void NativeViewResize(void* data,
865 void InitializeContent();
866 void InitializeWindowTreeHost();
867 void SendDelayedMessages(content::RenderViewHost* render_view_host);
869 void EvasToBlinkCords(int x, int y, int* view_x, int* view_y);
870 Eina_Bool AsyncRequestHitTestDataAtBlinkCords(
873 Ewk_Hit_Test_Mode mode,
874 WebViewAsyncRequestHitTestDataCallback* cb);
876 #if BUILDFLAG(IS_TIZEN_TV)
877 void InitInspectorServer();
879 void RunPendingSetFocus(Eina_Bool focus);
880 void SetFocusInternal(Eina_Bool focus);
883 JavaScriptDialogManagerEfl* GetJavaScriptDialogManagerEfl();
885 // Changes viewport without resizing Evas_Object representing webview
886 // and its corresponding RWHV to let Blink renders custom viewport
887 // while showing picker.
888 void AdjustViewPortHeightToPopupMenu(bool is_popup_menu_visible);
890 void ShowContextMenuInternal(const content::ContextMenuParams&);
892 void UpdateWebkitPreferencesEfl(content::RenderViewHost*);
894 void ChangeScroll(int& x, int& y);
895 void ScrollFocusedNodeIntoView();
897 void GenerateMHTML(Ewk_View_Save_Page_Callback callback,
899 const base::FilePath& file_path);
900 void MHTMLGenerated(Ewk_View_Save_Page_Callback callback,
902 const base::FilePath& file_path,
905 static void VisibleContentChangedCallback(void* user_data,
909 static void OnCustomScrollBeginCallback(void* user_data,
913 static void OnCustomScrollEndCallback(void* user_data,
916 void UpdateContextMenuWithParams(const content::ContextMenuParams& params);
918 static Eina_Bool DelayedPopulateAndShowContextMenu(void* data);
920 scoped_refptr<Ewk_Context> context_;
921 std::unique_ptr<content::WebContents> web_contents_;
922 std::unique_ptr<content::WebContentsDelegateEfl> web_contents_delegate_;
923 std::unique_ptr<content::WebViewDelegate> webview_delegate_;
924 std::string pending_url_request_;
925 std::unique_ptr<Ewk_Settings> settings_;
926 std::unique_ptr<_Ewk_Frame> frame_;
927 std::unique_ptr<_Ewk_Policy_Decision> window_policy_;
928 Evas_Object* ewk_view_;
929 Evas_Object* efl_main_layout_;
930 bool key_events_enabled_ = true;
931 bool rotation_changed_ = false;
932 bool mouse_events_enabled_;
933 double text_zoom_factor_;
934 mutable std::string user_agent_;
935 mutable std::string user_agent_app_name_;
936 std::unique_ptr<_Ewk_Auth_Challenge> auth_challenge_;
937 std::string selected_text_cached_;
939 std::unique_ptr<content::ContextMenuControllerEfl> context_menu_;
940 #if BUILDFLAG(IS_TIZEN_TV)
941 std::unique_ptr<_Ewk_File_Chooser_Request> file_chooser_request_;
943 std::unique_ptr<content::FileChooserControllerEfl> file_chooser_;
945 std::unique_ptr<content::PopupControllerEfl> popup_controller_;
946 std::u16string previous_text_;
947 int current_find_request_id_;
948 static int find_request_id_counter_;
950 typedef WebViewCallback<Ewk_View_Plain_Text_Get_Callback, const char*>
951 EwkViewPlainTextGetCallback;
952 base::IDMap<EwkViewPlainTextGetCallback*> plain_text_get_callback_map_;
954 typedef WebViewCallback<Ewk_View_MHTML_Data_Get_Callback, const char*>
955 MHTMLCallbackDetails;
956 base::IDMap<MHTMLCallbackDetails*> mhtml_callback_map_;
958 #if BUILDFLAG(IS_TIZEN_TV)
959 base::IDMap<IsVideoPlayingCallback*> is_video_playing_callback_map_;
962 typedef WebViewCallback<Ewk_View_Main_Frame_Scrollbar_Visible_Get_Callback,
964 MainFrameScrollbarVisibleGetCallback;
965 base::IDMap<MainFrameScrollbarVisibleGetCallback*>
966 main_frame_scrollbar_visible_callback_map_;
968 base::IDMap<BackgroundColorGetCallback*> background_color_get_callback_map_;
970 #if BUILDFLAG(IS_TIZEN_TV)
971 GetMediaDeviceCallback device_cb_;
974 gfx::Size contents_size_;
976 mutable std::string title_;
977 Hit_Test_Params hit_test_params_;
978 base::WaitableEvent hit_test_completion_;
979 double page_scale_factor_;
983 WebViewCallback<Ewk_View_Geolocation_Permission_Callback,
984 _Ewk_Geolocation_Permission_Request*>
985 geolocation_permission_cb_;
986 WebViewCallback<Ewk_View_User_Media_Permission_Callback,
987 _Ewk_User_Media_Permission_Request*>
988 user_media_permission_cb_;
989 WebViewCallbackWithReturnValue<Ewk_User_Media_Permission_Query_Result,
990 Ewk_View_User_Media_Permission_Query_Callback,
991 _Ewk_User_Media_Permission_Query*>
992 user_media_permission_query_cb_;
993 WebViewErrorPageLoadCallback<Ewk_View_Error_Page_Load_Callback,
997 WebViewCallback<Ewk_View_Unfocus_Allow_Callback, Ewk_Unfocus_Direction>
999 #if BUILDFLAG(IS_TIZEN_TV)
1000 WebViewCallback<Ewk_View_SmartRC_Mic_Notification_Callback, bool>
1001 smartrc_mic_notification_cb_;
1003 WebViewCallback<Ewk_View_Notification_Permission_Callback,
1004 Ewk_Notification_Permission_Request*>
1005 notification_permission_callback_;
1006 WebViewCallback<Ewk_Quota_Permission_Request_Callback,
1007 const _Ewk_Quota_Permission_Request*>
1008 quota_request_callback_;
1009 WebViewCallback<Ewk_View_Authentication_Callback, _Ewk_Auth_Challenge*>
1011 WebViewCallback<Ewk_View_Scale_Changed_Callback, double> scale_changed_cb_;
1013 std::unique_ptr<content::InputPicker> input_picker_;
1015 DidChangeThemeColorCallback did_change_theme_color_callback_;
1017 base::IDMap<WebApplicationIconUrlGetCallback*>
1018 web_app_icon_url_get_callback_map_;
1019 base::IDMap<WebApplicationIconUrlsGetCallback*>
1020 web_app_icon_urls_get_callback_map_;
1021 base::IDMap<WebApplicationCapableGetCallback*>
1022 web_app_capable_get_callback_map_;
1023 std::unique_ptr<PermissionPopupManager> permission_popup_manager_;
1024 std::unique_ptr<ScrollDetector> scroll_detector_;
1026 // Manages injecting native objects.
1027 std::unique_ptr<content::GinNativeBridgeDispatcherHost>
1028 gin_native_bridge_dispatcher_host_;
1030 WebViewExceededQuotaCallback<
1031 Ewk_View_Exceeded_Indexed_Database_Quota_Callback,
1032 Ewk_Security_Origin*,
1034 exceeded_indexed_db_quota_callback_;
1035 std::unique_ptr<Ewk_Security_Origin> exceeded_indexed_db_quota_origin_;
1036 #if !defined(EWK_BRINGUP) // FIXME: m114 bringup
1037 std::map<const _Ewk_Quota_Permission_Request*,
1038 content::QuotaPermissionContext::PermissionCallback>
1039 quota_permission_request_map_;
1041 #if BUILDFLAG(IS_TIZEN)
1042 blink::mojom::FileChooserParams::Mode filechooser_mode_ =
1043 blink::mojom::FileChooserParams::Mode::kOpen;
1044 Ecore_Event_Handler* window_rotate_handler_ = nullptr;
1047 bool is_initialized_;
1049 #if BUILDFLAG(IS_TIZEN_TV)
1050 bool is_processing_edge_scroll_;
1051 bool use_early_rwi_;
1052 bool rwi_info_showed_;
1054 bool is_high_bitrate_ = false;
1055 bool context_menu_show_;
1056 base::OneShotTimer mouse_long_press_timer_;
1057 base::OnceClosure pending_setfocus_closure_;
1059 enum PlaybackState {
1061 // kPlaybackReady: player with both audio and video starts prepare and will
1062 // acquire audio and video resources (if they are not already taken)
1068 double current_time_ = 0.0;
1071 std::unique_ptr<_Ewk_Back_Forward_List> back_forward_list_;
1073 static content::WebViewDelegate::WebContentsCreateCallback
1074 create_new_window_web_contents_cb_;
1076 #if defined(TIZEN_VIDEO_HOLE)
1077 void EnableVideoHoleSupportInternal();
1079 gfx::Vector2d previous_scroll_position_;
1081 gfx::Point context_menu_position_;
1083 content::ContextMenuParams saved_context_menu_params_;
1085 std::vector<IPC::Message*> delayed_messages_;
1087 std::map<int64_t, WebViewAsyncRequestHitTestDataCallback*> hit_test_callback_;
1089 content::AcceptLanguagesHelper::AcceptLangsChangedCallback
1090 accept_langs_changed_callback_;
1092 std::unique_ptr<SelectPickerBase> select_picker_;
1093 std::unique_ptr<aura::WindowTreeHost> host_;
1094 std::unique_ptr<aura::client::FocusClient> focus_client_;
1095 std::unique_ptr<aura::client::WindowParentingClient> window_parenting_client_;
1096 std::unique_ptr<ui::CompositorObserver> compositor_observer_;
1098 #if defined(TIZEN_ATK_SUPPORT)
1099 std::unique_ptr<EWebAccessibility> eweb_accessibility_;
1100 bool lazy_initialize_atk_ = false;
1102 #if defined(TIZEN_PEPPER_EXTENSIONS)
1103 content::ExtensionSystemDelegateManager::RenderFrameID render_frame_id_;
1105 #if defined(TIZEN_VIDEO_HOLE)
1106 bool pending_video_hole_setting_ = false;
1109 Ecore_Timer* delayed_show_context_menu_timer_ = nullptr;
1110 base::WeakPtrFactory<EWebView> weak_factory_{this};
1113 const unsigned int g_default_tilt_motion_sensitivity = 3;