From: Bakka Uday Kiran Date: Fri, 23 Dec 2022 09:49:09 +0000 (+0530) Subject: Merge WebContentsViewEflDelegate to WebContentsEflDelegate X-Git-Tag: submit/tizen/20230227.160252~184 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F78%2F285978%2F6;p=platform%2Fframework%2Fweb%2Fchromium-efl.git Merge WebContentsViewEflDelegate to WebContentsEflDelegate For AURA, WebContentsViewEfl is not used as it is replaced by WebContentsViewAura, hence its delegate WebContentsViewEflDelegate cannot be instantiated without it. So this patch moves the interfaces from WebContentsViewEflDelegate to WebContentsEflDelegate, and called via WebContentsImplEfl::GetDelegate(). As there are many delegate classes under tizen_src causing confusion sometimes; removing WebContentsViewEflDelegate improves code structure and understandability. Reference: https://review.tizen.org/gerrit/274379 Change-Id: I0f8e2220ece36594a710d179a4706878b14a9ab4 Signed-off-by: Bakka Uday Kiran --- diff --git a/tizen_src/chromium_impl/content/browser/browser_efl.gni b/tizen_src/chromium_impl/content/browser/browser_efl.gni index ed7da40..1ae5fbf 100644 --- a/tizen_src/chromium_impl/content/browser/browser_efl.gni +++ b/tizen_src/chromium_impl/content/browser/browser_efl.gni @@ -69,7 +69,6 @@ external_content_browser_efl_sources = [ "//tizen_src/chromium_impl/content/browser/javascript_dialog/javascript_modal_dialog.cc", "//tizen_src/chromium_impl/content/browser/javascript_dialog/javascript_modal_dialog.h", "//tizen_src/chromium_impl/content/browser/public/browser/web_contents_efl_delegate.h", - "//tizen_src/chromium_impl/content/browser/public/browser/web_contents_view_efl_delegate.h", "//tizen_src/chromium_impl/content/browser/renderer_host/edge_effect.cc", "//tizen_src/chromium_impl/content/browser/renderer_host/edge_effect.h", "//tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.cc", diff --git a/tizen_src/chromium_impl/content/browser/screen_orientation/screen_orientation_delegate_efl.cc b/tizen_src/chromium_impl/content/browser/screen_orientation/screen_orientation_delegate_efl.cc index 00c5594..4fcddbf 100644 --- a/tizen_src/chromium_impl/content/browser/screen_orientation/screen_orientation_delegate_efl.cc +++ b/tizen_src/chromium_impl/content/browser/screen_orientation/screen_orientation_delegate_efl.cc @@ -8,7 +8,7 @@ #include "chromium_impl/content/browser/web_contents/web_contents_impl_efl.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_delegate.h" -#include "ewk/efl_integration/web_contents_view_efl_delegate_ewk.h" +#include "ewk/efl_integration/web_contents_efl_delegate_ewk.h" namespace content { @@ -31,12 +31,9 @@ bool ScreenOrientationDelegateEfl::FullScreenRequired( void ScreenOrientationDelegateEfl::Lock( WebContents* web_contents, device::mojom::ScreenOrientationLockType lock_orientation) { -#if !defined(USE_AURA) - WebContentsImpl* wci = static_cast(web_contents); - WebContentsViewEfl* wcve = static_cast(wci->GetView()); - if (wcve->GetEflDelegate()) - wcve->GetEflDelegate()->OrientationLock(lock_orientation); -#endif + WebContentsImplEfl* wcie = static_cast(web_contents); + if (wcie->GetEflDelegate()) + wcie->GetEflDelegate()->OrientationLock(lock_orientation); } bool ScreenOrientationDelegateEfl::ScreenOrientationProviderSupported( @@ -46,12 +43,9 @@ bool ScreenOrientationDelegateEfl::ScreenOrientationProviderSupported( } void ScreenOrientationDelegateEfl::Unlock(WebContents* web_contents) { -#if !defined(USE_AURA) - WebContentsImpl* wci = static_cast(web_contents); - WebContentsViewEfl* wcve = static_cast(wci->GetView()); - if (wcve->GetEflDelegate()) - wcve->GetEflDelegate()->OrientationUnlock(); -#endif + WebContentsImplEfl* wcie = static_cast(web_contents); + if (wcie->GetEflDelegate()) + wcie->GetEflDelegate()->OrientationUnlock(); } } // namespace content diff --git a/tizen_src/chromium_impl/content/public/browser/web_contents_efl_delegate.h b/tizen_src/chromium_impl/content/public/browser/web_contents_efl_delegate.h index 1e808bd..75d3cc5 100644 --- a/tizen_src/chromium_impl/content/public/browser/web_contents_efl_delegate.h +++ b/tizen_src/chromium_impl/content/public/browser/web_contents_efl_delegate.h @@ -5,13 +5,22 @@ #ifndef CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_EFL_DELEGATE_H_ #define CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_EFL_DELEGATE_H_ +#include + #include "base/callback.h" #include "content/common/content_export.h" +#include "content/public/browser/context_menu_params.h" +#include "services/device/public/mojom/screen_orientation_lock_types.mojom.h" +#include "third_party/blink/public/common/context_menu_data/menu_item_info.h" +#include "third_party/blink/public/common/input/web_gesture_event.h" +#include "third_party/blink/public/common/input/web_input_event.h" +#include "ui/gfx/geometry/rect.h" class GURL; namespace content { +class RenderFrameHost; class WebContents; class CONTENT_EXPORT WebContentsEflDelegate { @@ -38,6 +47,28 @@ class CONTENT_EXPORT WebContentsEflDelegate { // This is needed when a window is created with window.open or target:_blank, // where RenderWidgetHostViewXXX objects are created earlier in the call chain. virtual void SetUpSmartObject(void* platform_data, void* native_view) = 0; + + virtual void ShowPopupMenu(RenderFrameHost* render_frame_host, + const gfx::Rect& bounds, + int item_height, + double item_font_size, + int selected_item, + const std::vector& items, + bool right_aligned, + bool allow_multiple_selection) = 0; + virtual void HidePopupMenu() = 0; + + virtual void CancelContextMenu(int request_id) = 0; + + virtual void QuerySelectionStyle() = 0; + virtual void HandleZoomGesture(blink::WebGestureEvent& event) = 0; + + virtual bool UseKeyPadWithoutUserAction() = 0; + + virtual void ShowContextMenu(const ContextMenuParams& params) = 0; + + virtual void OrientationLock(device::mojom::ScreenOrientationLockType) = 0; + virtual void OrientationUnlock() = 0; }; } // namespace content diff --git a/tizen_src/chromium_impl/content/public/browser/web_contents_view_efl_delegate.h b/tizen_src/chromium_impl/content/public/browser/web_contents_view_efl_delegate.h deleted file mode 100644 index 71bb716..0000000 --- a/tizen_src/chromium_impl/content/public/browser/web_contents_view_efl_delegate.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2015 Samsung Electronics. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_VIEW_EFL_DELEGATE_H_ -#define CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_VIEW_EFL_DELEGATE_H_ - -#include - -#include "content/common/content_export.h" -#include "content/public/browser/context_menu_params.h" -#include "services/device/public/mojom/screen_orientation_lock_types.mojom.h" -#include "third_party/blink/public/common/context_menu_data/menu_item_info.h" -#include "third_party/blink/public/common/input/web_gesture_event.h" -#include "third_party/blink/public/common/input/web_input_event.h" -#include "ui/gfx/geometry/rect.h" - -namespace content { - -class RenderFrameHost; - -class WebContentsViewEflDelegate { - public: - WebContentsViewEflDelegate() {}; - virtual ~WebContentsViewEflDelegate() {}; - - virtual void ShowPopupMenu(RenderFrameHost* render_frame_host, - const gfx::Rect& bounds, - int item_height, - double item_font_size, - int selected_item, - const std::vector& items, - bool right_aligned, - bool allow_multiple_selection) = 0; - virtual void HidePopupMenu() = 0; - - virtual void SetPageTitle(const std::u16string& title) = 0; - virtual void CancelContextMenu(int request_id) = 0; - - virtual void QuerySelectionStyle() = 0; - virtual void HandleZoomGesture(blink::WebGestureEvent& event) = 0; - - virtual bool UseKeyPadWithoutUserAction() = 0; - - virtual void ShowContextMenu(const ContextMenuParams& params) = 0; - - virtual void OrientationLock(device::mojom::ScreenOrientationLockType) = 0; - virtual void OrientationUnlock() = 0; - - virtual void OnOverscrolled( - const gfx::Vector2dF& accumulated_overscroll, - const gfx::Vector2dF& latest_overscroll_delta) = 0; -}; - -} // namespace content - -#endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_VIEW_EFL_DELEGATE_H_ diff --git a/tizen_src/ewk/efl_integration/BUILD.gn b/tizen_src/ewk/efl_integration/BUILD.gn index 7d5fdae..f774408 100644 --- a/tizen_src/ewk/efl_integration/BUILD.gn +++ b/tizen_src/ewk/efl_integration/BUILD.gn @@ -279,8 +279,6 @@ shared_library("chromium-ewk") { "web_contents_efl_delegate_ewk.h", "web_contents_view_delegate_ewk.cc", "web_contents_view_delegate_ewk.h", - "web_contents_view_efl_delegate_ewk.cc", - "web_contents_view_efl_delegate_ewk.h", # Make use of Android webview"s simplified pref class. "browser/autofill/autofill_client_efl.cc", diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index fbe8406..14e2880 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -62,7 +62,6 @@ #include "ui/platform_window/platform_window_init_properties.h" #include "web_contents_delegate_efl.h" #include "web_contents_efl_delegate_ewk.h" -#include "web_contents_view_efl_delegate_ewk.h" #include #include @@ -2298,10 +2297,6 @@ void EWebView::InitializeContent() { } web_contents_delegate_.reset(new WebContentsDelegateEfl(this)); web_contents_->SetDelegate(web_contents_delegate_.get()); -#if !defined(USE_AURA) - GetWebContentsViewEfl()->SetEflDelegate( - new WebContentsViewEflDelegateEwk(this)); -#endif WebContentsImplEfl* wc_efl = static_cast(web_contents_.get()); wc_efl->SetEflDelegate(new WebContentsEflDelegateEwk(this)); diff --git a/tizen_src/ewk/efl_integration/web_contents_efl_delegate_ewk.cc b/tizen_src/ewk/efl_integration/web_contents_efl_delegate_ewk.cc index d050fc8..d010dc8 100644 --- a/tizen_src/ewk/efl_integration/web_contents_efl_delegate_ewk.cc +++ b/tizen_src/ewk/efl_integration/web_contents_efl_delegate_ewk.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "web_contents_efl_delegate_ewk.h" +#include "ewk/efl_integration/private/webview_delegate_ewk.h" #include @@ -22,3 +23,70 @@ void WebContentsEflDelegateEwk::SetUpSmartObject(void* platform_data, void* nati Evas_Object* _native_view = static_cast(native_view); evas_object_smart_member_add(_native_view, new_web_view->evas_object()); } + +void WebContentsEflDelegateEwk::ShowPopupMenu( + content::RenderFrameHost* render_frame_host, + const gfx::Rect& bounds, + int item_height, + double item_font_size, + int selected_item, + const std::vector& items, + bool right_aligned, + bool allow_multiple_selection) { + web_view_->ShowPopupMenu(items, selected_item, allow_multiple_selection); +} + +void WebContentsEflDelegateEwk::HidePopupMenu() { + web_view_->HidePopupMenu(); +} + +void WebContentsEflDelegateEwk::CancelContextMenu(int request_id) { + web_view_->CancelContextMenu(request_id); +} + +void WebContentsEflDelegateEwk::QuerySelectionStyle() { + web_view_->QuerySelectionStyle(); +} + +void WebContentsEflDelegateEwk::HandleZoomGesture( + blink::WebGestureEvent& event) { + web_view_->HandleZoomGesture(event); +} + +bool WebContentsEflDelegateEwk::UseKeyPadWithoutUserAction() { + return web_view_->GetSettings()->useKeyPadWithoutUserAction(); +} + +void WebContentsEflDelegateEwk::ShowContextMenu( + const content::ContextMenuParams& params) { + web_view_->ShowContextMenu(params); +} + +void WebContentsEflDelegateEwk::OrientationLock( + device::mojom::ScreenOrientationLockType orientation) { + // Conversion of WebScreenOrientationLockType to + // list of orientations. + // This is related to the commentary to the M42 version + // (currently non-existent) of prototype + // Eina_Bool (*orientation_lock)(Ewk_View_Smart_Data* sd, int orientations) + // InvalidOrientation = 0, + // OrientationPortraitPrimary = 1, + // OrientationLandscapePrimary = 1 << 1, + // OrientationPortraitSecondary = 1 << 2, + // OrientationLandscapeSecondary = 1 << 3, + // OrientationPortrait = + // OrientationPortraitPrimary | OrientationPortraitSecondary, + // OrientationLandscape = + // OrientationLandscapePrimary | OrientationLandscapeSecondary, + // OrientationNatural = + // OrientationPortraitPrimary | OrientationLandscapePrimary, + // OrientationAny = OrientationPortrait | OrientationLandscape + int orientation_convert[9] = {0, 1, 4, 2, 8, 15, 10, 5, 3}; + + WebViewDelegateEwk::GetInstance().RequestHandleOrientationLock( + web_view_, orientation_convert[static_cast(orientation)]); +} + +void WebContentsEflDelegateEwk::OrientationUnlock() { + WebViewDelegateEwk::GetInstance().RequestHandleOrientationUnlock(web_view_); +} \ No newline at end of file diff --git a/tizen_src/ewk/efl_integration/web_contents_efl_delegate_ewk.h b/tizen_src/ewk/efl_integration/web_contents_efl_delegate_ewk.h index a7d6905..0377cff 100644 --- a/tizen_src/ewk/efl_integration/web_contents_efl_delegate_ewk.h +++ b/tizen_src/ewk/efl_integration/web_contents_efl_delegate_ewk.h @@ -17,6 +17,30 @@ class WebContentsEflDelegateEwk : public content::WebContentsEflDelegate { void SetUpSmartObject(void*platform_data, void* native_view) override; + void ShowPopupMenu(content::RenderFrameHost* render_frame_host, + const gfx::Rect& bounds, + int item_height, + double item_font_size, + int selected_item, + const std::vector& items, + bool right_aligned, + bool allow_multiple_selection) override; + void HidePopupMenu() override; + + void CancelContextMenu(int request_id) override; + + void QuerySelectionStyle() override; + + void HandleZoomGesture(blink::WebGestureEvent& event) override; + + bool UseKeyPadWithoutUserAction() override; + + void ShowContextMenu(const content::ContextMenuParams& params) override; + + virtual void OrientationLock( + device::mojom::ScreenOrientationLockType) override; + virtual void OrientationUnlock() override; + private: EWebView* web_view_; diff --git a/tizen_src/ewk/efl_integration/web_contents_view_efl_delegate_ewk.cc b/tizen_src/ewk/efl_integration/web_contents_view_efl_delegate_ewk.cc deleted file mode 100644 index 1838af0..0000000 --- a/tizen_src/ewk/efl_integration/web_contents_view_efl_delegate_ewk.cc +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2015 Samsung Electronics. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "web_contents_view_efl_delegate_ewk.h" - -#include "eweb_view.h" -#include "ewk/efl_integration/private/webview_delegate_ewk.h" - -WebContentsViewEflDelegateEwk::WebContentsViewEflDelegateEwk(EWebView* wv) - : web_view_(wv) { -} - -void WebContentsViewEflDelegateEwk::ShowPopupMenu( - content::RenderFrameHost* render_frame_host, - const gfx::Rect& bounds, - int item_height, - double item_font_size, - int selected_item, - const std::vector& items, - bool right_aligned, - bool allow_multiple_selection) { - web_view_->ShowPopupMenu(items, selected_item, allow_multiple_selection); -} - -void WebContentsViewEflDelegateEwk::HidePopupMenu() { - web_view_->HidePopupMenu(); -} - -void WebContentsViewEflDelegateEwk::SetPageTitle(const std::u16string& title) { - web_view_->SmartCallback(). - call(base::UTF16ToUTF8(title).c_str()); -} - -void WebContentsViewEflDelegateEwk::CancelContextMenu(int request_id) { - web_view_->CancelContextMenu(request_id); -} - -void WebContentsViewEflDelegateEwk::QuerySelectionStyle() { - web_view_->QuerySelectionStyle(); -} - -void WebContentsViewEflDelegateEwk::HandleZoomGesture(blink::WebGestureEvent& event) { - web_view_->HandleZoomGesture(event); -} - -bool WebContentsViewEflDelegateEwk::UseKeyPadWithoutUserAction() { - return web_view_->GetSettings()->useKeyPadWithoutUserAction(); -} - -void WebContentsViewEflDelegateEwk::ShowContextMenu( - const content::ContextMenuParams& params) { - web_view_->ShowContextMenu(params); -} - -void WebContentsViewEflDelegateEwk::OrientationLock( - device::mojom::ScreenOrientationLockType orientation) { - // Conversion of WebScreenOrientationLockType to - // list of orientations. - // This is related to the commentary to the M42 version - // (currently non-existent) of prototype - // Eina_Bool (*orientation_lock)(Ewk_View_Smart_Data* sd, int orientations) - // InvalidOrientation = 0, - // OrientationPortraitPrimary = 1, - // OrientationLandscapePrimary = 1 << 1, - // OrientationPortraitSecondary = 1 << 2, - // OrientationLandscapeSecondary = 1 << 3, - // OrientationPortrait = - // OrientationPortraitPrimary | OrientationPortraitSecondary, - // OrientationLandscape = - // OrientationLandscapePrimary | OrientationLandscapeSecondary, - // OrientationNatural = - // OrientationPortraitPrimary | OrientationLandscapePrimary, - // OrientationAny = OrientationPortrait | OrientationLandscape - int orientation_convert[9] = { 0, 1, 4, 2, 8, 15, 10, 5, 3 }; - - WebViewDelegateEwk::GetInstance().RequestHandleOrientationLock( - web_view_, - orientation_convert[static_cast(orientation)]); -} - -void WebContentsViewEflDelegateEwk::OrientationUnlock() { - WebViewDelegateEwk::GetInstance().RequestHandleOrientationUnlock(web_view_); -} - -void WebContentsViewEflDelegateEwk::OnOverscrolled( - const gfx::Vector2dF& accumulated_overscroll, - const gfx::Vector2dF& latest_overscroll_delta) { - web_view_->OnOverscrolled(accumulated_overscroll, latest_overscroll_delta); -} diff --git a/tizen_src/ewk/efl_integration/web_contents_view_efl_delegate_ewk.h b/tizen_src/ewk/efl_integration/web_contents_view_efl_delegate_ewk.h deleted file mode 100644 index 6330b27..0000000 --- a/tizen_src/ewk/efl_integration/web_contents_view_efl_delegate_ewk.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2015 Samsung Electronics. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEB_CONTENTS_VIEW_EFL_DELEGATE_EWK -#define WEB_CONTENTS_VIEW_EFL_DELEGATE_EWK - -#include "content/public/browser/web_contents_view_efl_delegate.h" -#include "third_party/blink/public/common/context_menu_data/menu_item_info.h" - -class EWebView; - -namespace content { -class RenderFrameHost; -} - -class WebContentsViewEflDelegateEwk - : public content::WebContentsViewEflDelegate { - public: - WebContentsViewEflDelegateEwk(EWebView*); - - void ShowPopupMenu(content::RenderFrameHost* render_frame_host, - const gfx::Rect& bounds, - int item_height, - double item_font_size, - int selected_item, - const std::vector& items, - bool right_aligned, - bool allow_multiple_selection) override; - void HidePopupMenu() override; - - void SetPageTitle(const std::u16string& title) override; - - void CancelContextMenu(int request_id) override; - - void QuerySelectionStyle() override; - - void HandleZoomGesture(blink::WebGestureEvent& event) override; - - bool UseKeyPadWithoutUserAction() override; - - void ShowContextMenu(const content::ContextMenuParams& params) override; - - virtual void OrientationLock( - device::mojom::ScreenOrientationLockType) override; - virtual void OrientationUnlock() override; - - private: - void OnOverscrolled(const gfx::Vector2dF& accumulated_overscroll, - const gfx::Vector2dF& latest_overscroll_delta) override; - - EWebView* web_view_; -}; - -#endif // WEB_CONTENTS_VIEW_EFL_DELEGATE_EWK -