[M108 Migration][VD] Support floating video window 96/290296/3
authorqiang.ji <qiang.ji@samsung.com>
Thu, 23 Mar 2023 02:17:01 +0000 (10:17 +0800)
committerBot Blink <blinkbot@samsung.com>
Mon, 27 Mar 2023 05:02:03 +0000 (05:02 +0000)
Support the new requirement of floating video window for WebBrowser.

- Provide an api of ewk_view_floating_window_state_changed.
  Notify WebEngine the status that floating video window is on/off.
  If floating video window existed, but not current webView,
  For tabs switching case, in order to keep floating video window,
  need to prevent media resume.

- Provide "notify,video,resized" for video rect notification.
  WebEngine notify WebBrowser playing video dimension in normal webview
  through which mini tab button is displayed at correct location on video.

- Appended the document url to the paramater of "video,playing,url".
  In case video is playing inside an iframe, document URL provides
  URL loaded in iFrame to identify which document is playing video.

- Allow to run the insecure content from localhost,
  that are http://127.0.0.1 and http://localhost.

refs:
https://review.tizen.org/gerrit/283144/

Change-Id: I3c8c0f4c2279e4cadcba471250a2e6e1c67729c6
Signed-off-by: qiang.ji <qiang.ji@samsung.com>
20 files changed:
content/browser/renderer_host/render_widget_host_impl.cc
content/browser/renderer_host/render_widget_host_impl.h
content/public/renderer/content_renderer_client.h
third_party/blink/public/mojom/widget/platform_widget.mojom
third_party/blink/public/web/web_view.h
third_party/blink/public/web/web_view_client.h
third_party/blink/renderer/core/exported/web_view_impl.cc
third_party/blink/renderer/core/exported/web_view_impl.h
third_party/blink/renderer/core/frame/web_frame_widget_impl.cc
third_party/blink/renderer/core/frame/web_frame_widget_impl.h
third_party/blink/renderer/core/html/media/html_media_element.cc
third_party/blink/renderer/core/html/media/html_media_element.h
third_party/blink/renderer/core/page/page.h
third_party/blink/renderer/platform/widget/widget_base.cc
third_party/blink/renderer/platform/widget/widget_base.h
third_party/blink/renderer/platform/widget/widget_base_client.h
tizen_src/ewk/efl_integration/eweb_view.cc
tizen_src/ewk/efl_integration/eweb_view.h
tizen_src/ewk/efl_integration/public/ewk_view.cc
tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.h

index 84f8aae40476caeee9065b7c0c635464db9ed7f7..02d615617acb67ab9f2c6a39223ae10b27db1454 100644 (file)
@@ -1074,6 +1074,12 @@ void RenderWidgetHostImpl::OnGetSelectionRect(const gfx::Rect& rect) {
 void RenderWidgetHostImpl::ResetLastInteractedElements() {
   blink_widget_->ResetLastInteractedElements();
 }
+
+#if BUILDFLAG(IS_TIZEN_TV)
+void RenderWidgetHostImpl::SetFloatVideoWindowState(bool enabled) {
+  blink_widget_->SetFloatVideoWindowState(enabled);
+}
+#endif
 #endif
 
 blink::VisualProperties RenderWidgetHostImpl::GetInitialVisualProperties() {
index b0696156e5b427de4e89ab73e765983b4da967d9..99f88c45953b47fc63dc672efc0ec453a0158bd8 100644 (file)
@@ -464,6 +464,9 @@ class CONTENT_EXPORT RenderWidgetHostImpl
   void RequestSelectionRect();
   void OnGetSelectionRect(const gfx::Rect& rect);
   void ResetLastInteractedElements();
+#if BUILDFLAG(IS_TIZEN_TV)
+  void SetFloatVideoWindowState(bool enabled);
+#endif
 #endif
 
   // Returns true if the RenderWidget is hidden.
index d31fc6b76ba6233f0fea6f7582f2afdac7e4f1a3..f89f2da4f7ac55b1cb8e5b09708a612ffbab34f5 100644 (file)
@@ -226,6 +226,9 @@ class CONTENT_EXPORT ContentRendererClient {
                                 blink::WebNavigationPolicy default_policy,
                                 bool is_redirect);
 #endif
+#if BUILDFLAG(IS_TIZEN_TV)
+  virtual bool HasFloatingVideoWindowOn() const { return false; }
+#endif
 
   // Notifies the embedder that the given frame is requesting the resource at
   // |url|. If the function returns a valid |new_url|, the request must be
index 50071a72ca6fc9615a097bb84e46749b285cb39a..b222ca4d82e38499cb42d0bc9d1b16c1fa27300b 100644 (file)
@@ -155,6 +155,9 @@ interface Widget {
   [EnableIf=is_efl]
   RequestSelectionRect() => (gfx.mojom.Rect rect);
 
+  [EnableIf=is_tizen_tv]
+  SetFloatVideoWindowState(bool enabled);
+
   // Informs the widget that it was hidden. This allows it to reduce its
   // resource utilization, and will cancel any pending
   // RecordContentToVisibleTimeRequest that was set with WasShown or
index 5a25218085cff1a3592000f4f1faa39e929d839f..608a2ee75767cfd758f9683ad2ee44735506d742 100644 (file)
@@ -513,6 +513,10 @@ class BLINK_EXPORT WebView {
   virtual gfx::Rect CurrentSelectionRect() const = 0;
 #endif
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  virtual void SetFloatVideoWindowState(bool enable) = 0;
+#endif
+
  protected:
   ~WebView() = default;
 };
index d551e78b7ce97702d46e98f2f099dfcc9c3b9432..2435c9c323d7d40fcbc938ab08e3e7b99d267044 100644 (file)
@@ -48,6 +48,11 @@ class WebViewClient {
   // the layers.
   virtual void InvalidateContainer() {}
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  // Floating Video Window
+  virtual bool HasFloatingVideoWindowOn() const { return false; }
+#endif
+
   // UI ------------------------------------------------------------------
 
   // Called when the View has changed size as a result of an auto-resize.
index 316ae20ff332e7152e320b922b0d02b868c0f312..ad878e574c30475e477b4dba4f5d8be97680fcc5 100644 (file)
@@ -3565,6 +3565,16 @@ void WebViewImpl::RemoveObserver(WebViewObserver* observer) {
   observers_.RemoveObserver(observer);
 }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+void WebViewImpl::SetFloatVideoWindowState(bool enable) {
+  if (!GetPage())
+    return;
+
+  LOG(INFO) << __FUNCTION__ << " enable : " << enable;
+  GetPage()->SetFloatVideoWindowState(enable);
+}
+#endif
+
 void WebViewImpl::SetIsActive(bool active) {
   if (GetPage())
     GetPage()->GetFocusController().SetActive(active);
index 952342be5ee9440ed0d4d46381408034e5ce26e3..18d4dd854ec414442633144d19f715b16b25eaab 100644 (file)
@@ -243,6 +243,10 @@ class CORE_EXPORT WebViewImpl final : public WebView,
   void AddObserver(WebViewObserver* observer);
   void RemoveObserver(WebViewObserver* observer);
 
+#if defined(OS_TIZEN_TV_PRODUCT)
+  void SetFloatVideoWindowState(bool) override;
+#endif // OS_TIZEN_TV_PRODUCT
+
   // `BaseBackgroundColor()` affects how the document is rendered.
   // `BackgroundColor()` is what the document computes as its background color
   // (with `BaseBackgroundColor()` as an input), or `BaseBackgroundColor()` if
index d6b30180ef63fc9d808ea929b64179e71e7a0f1c..3f8d61b7ae9e498df9477ed386500a887acda1ef 100644 (file)
@@ -4304,6 +4304,12 @@ bool WebFrameWidgetImpl::RequestMainFrameScrollbarVisible(bool& visible) {
             local_frame->HasVerticalScrollbar();
   return true;
 }
+
+#if BUILDFLAG(IS_TIZEN_TV)
+void WebFrameWidgetImpl::SetFloatVideoWindowState(bool enabled) {
+  View()->SetFloatVideoWindowState(enabled);
+}
+#endif
 #endif
 
 #if BUILDFLAG(IS_TIZEN)
index 80cc841cc2dcfff8b010546bf0d08bca01915e30..833586aec5f3ec157f24f4a878876270ef0a8592 100644 (file)
@@ -738,6 +738,9 @@ class CORE_EXPORT WebFrameWidgetImpl
   void SelectClosestWord(uint32_t x, uint32_t y) override;
   void SelectFocusedLink() override;
   gfx::Rect RequestSelectionRect() override;
+#if BUILDFLAG(IS_TIZEN_TV)
+  void SetFloatVideoWindowState(bool enabled) override;
+#endif
 #endif
 
   void OrientationChanged() override;
index c96a6d2e6ec68209d64a741ebae7789b647993bc..85b16380655cddc91c0372113d184cbad0b25af1 100644 (file)
@@ -501,6 +501,9 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tag_name,
       tracks_are_ready_(true),
       processing_preference_change_(false),
       was_always_muted_(true),
+#if BUILDFLAG(IS_TIZEN_TV)
+      is_deactivate_(false),
+#endif
 #if defined(TIZEN_MULTIMEDIA)
       suspended_by_player_(false),
 #endif
@@ -2742,6 +2745,9 @@ absl::optional<DOMExceptionCode> HTMLMediaElement::Play() {
 
   absl::optional<DOMExceptionCode> exception_code =
       autoplay_policy_->RequestPlay();
+#if BUILDFLAG(IS_TIZEN_TV)
+  is_deactivate_ = false;
+#endif
 
   if (exception_code == DOMExceptionCode::kNotAllowedError) {
     // If we're already playing, then this play would do nothing anyway.
@@ -4969,6 +4975,72 @@ void HTMLMediaElement::OpenerContextObserver::ContextDestroyed() {
   element_->AttachToNewFrame();
 }
 
+#if defined(TIZEN_MULTIMEDIA_SUPPORT)
+void HTMLMediaElement::MediaPlayerHidden() {
+  LOG(INFO) << "Media player hidden: " << this;
+  // TODO(m.debski): It should store periodic timers and restore on shown.
+  // Currently they will still fire, but will return immediately.
+  suppress_events_ = true;
+}
+
+void HTMLMediaElement::MediaPlayerShown() {
+  LOG(INFO) << "Media player shown: " << this;
+  suppress_events_ = false;
+}
+
+void HTMLMediaElement::Suspend() {
+  LOG(INFO) << "Suspend(" << (void*)this << ")";
+  if (!GetWebMediaPlayer())
+    return;
+
+#if defined(SAMSUNG_ELEMENTARY_MEDIA_STREAM_SOURCE)
+  if (media_source_attachment_) {
+    // Send suspend event to the source before WebMediaPlayer suspends backend.
+    media_source_attachment_->OnSuspend(media_source_tracer_);
+  }
+#endif  // SAMSUNG_ELEMENTARY_MEDIA_STREAM_SOURCE
+
+  GetWebMediaPlayer()->Suspend();
+}
+
+void HTMLMediaElement::Resume() {
+  LOG(INFO) << "Resume(" << (void*)this << ")";
+  if (!GetWebMediaPlayer())
+    return;
+
+#if BUILDFLAG(IS_TIZEN_TV)
+  // IsViewResumedByTabSwitching, return true on the tab which has no
+  // floatwindow, otherwise it is false
+  if (GetDocument().GetPage() &&
+      GetDocument().GetPage()->IsViewResumedByTabSwitching()) {
+    GetWebMediaPlayer()->Deactivate();
+    LOG(INFO) << "is_deactivate_ TRUE";
+    is_deactivate_ = true;
+  } else if (is_deactivate_) {
+    GetWebMediaPlayer()->Activate();
+    LOG(INFO) << "is_deactivate_ FALSE";
+    is_deactivate_ = false;
+  }
+#endif
+
+  GetWebMediaPlayer()->Resume();
+
+#if defined(SAMSUNG_ELEMENTARY_MEDIA_STREAM_SOURCE)
+  if (media_source_attachment_) {
+    // Send suspend event to the source after WebMediaPlayer resumes backend.
+    media_source_attachment_->OnResume(media_source_tracer_);
+  }
+#endif  // SAMSUNG_ELEMENTARY_MEDIA_STREAM_SOURCE
+}
+
+void HTMLMediaElement::ActivatePlayer() {
+  if (!GetWebMediaPlayer())
+    return;
+
+  GetWebMediaPlayer()->Activate();
+}
+#endif
+
 STATIC_ASSERT_ENUM(WebMediaPlayer::kReadyStateHaveNothing,
                    HTMLMediaElement::kHaveNothing);
 STATIC_ASSERT_ENUM(WebMediaPlayer::kReadyStateHaveMetadata,
index 0677124aa243c75102e2857064f68700499630f2..8a0e3cee1a9159a894347ff003b85e7e648cc0f8 100644 (file)
@@ -604,6 +604,14 @@ class CORE_EXPORT HTMLMediaElement
   void SetAudioSinkId(const String&) override;
   void SuspendForFrameClosed() override;
 
+#if defined(TIZEN_MULTIMEDIA_SUPPORT)
+  void MediaPlayerHidden() final;
+  void MediaPlayerShown() final;
+  void Suspend();
+  void Resume();
+  void NotifyPlayingUrl();
+#endif
+
   void LoadTimerFired(TimerBase*);
   void ProgressEventTimerFired();
   void PlaybackProgressTimerFired();
@@ -858,6 +866,15 @@ class CORE_EXPORT HTMLMediaElement
   // playback raters other than 1.0.
   bool preserves_pitch_ = true;
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  bool is_deactivate_ : 1;
+#endif
+
+#if defined(TIZEN_MULTIMEDIA_SUPPORT)
+  // This is to suppress stuff set to JS. Do not use it for other purposes.
+  bool suppress_events_ : 1;
+#endif
+
 #if defined(TIZEN_MULTIMEDIA)
   bool suspended_by_player_ : 1;
 #endif
index 3d0597b4b6cab952b3196ba15d7be9b7cad55cae..e165464f47ecf0d7fd8d5cfbbcc3033c8b6d5b8f 100644 (file)
@@ -402,6 +402,12 @@ class CORE_EXPORT Page final : public GarbageCollected<Page>,
   // with the 'persisted' property set to 'true'.
   bool DispatchedPagehidePersistedAndStillHidden();
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  // Floating Video Window: record the page that has floating video window.
+  void SetFloatVideoWindowState(bool enable) { is_floating_page_ = enable; }
+  bool HasFloatingVideoWindowOn() const { return is_floating_page_; }
+#endif
+
   static void PrepareForLeakDetection();
 
   // Fully invalidate paint of all local frames in this page.
@@ -507,6 +513,10 @@ class CORE_EXPORT Page final : public GarbageCollected<Page>,
   bool is_painting_ = false;
 #endif
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  bool is_floating_page_ = false;
+#endif
+
   int subframe_count_;
 
   HeapHashSet<WeakMember<PluginsChangedObserver>> plugins_changed_observers_;
index a699184c70953cd2ff591c5f82396062a55ae63a..63fdc2491a419616f1e06b6adda0ad521bdb9d57 100644 (file)
@@ -531,6 +531,12 @@ void WidgetBase::RequestSelectionRect(RequestSelectionRectCallback callback) {
 }
 #endif
 
+#if BUILDFLAG(IS_TIZEN_TV)
+void WidgetBase::SetFloatVideoWindowState(bool enabled) {
+  client_->SetFloatVideoWindowState(enabled);
+}
+#endif // IS_TIZEN_TV
+
 void WidgetBase::WasHidden() {
   // A provisional frame widget will never be hidden since that would require it
   // to be shown first. A frame must be attached to the frame tree before
index ad55f28e10d4a42215517204d4e24a92150aecf0..665bdcf41557e5e5d0f8717044a11ff35751335f 100644 (file)
@@ -150,6 +150,9 @@ class PLATFORM_EXPORT WidgetBase : public mojom::blink::Widget,
   void SetMainFrameScrollbarVisible(bool visible) override;
   void RequestMainFrameScrollbarVisible(
       RequestMainFrameScrollbarVisibleCallback callback) override;
+#if BUILDFLAG(IS_TIZEN_TV)
+  void SetFloatVideoWindowState(bool enabled) override;
+#endif // IS_TIZEN_TV
   void QueryInputType(QueryInputTypeCallback) override;
   void SelectClosestWord(uint32_t x, uint32_t y) override;
   void SelectFocusedLink() override;
index d17c30f0ec4d5b742b9ab7287ecac89150f87d33..4b4bd1e6d1639315f3f173f9404ad132b0ac78f9 100644 (file)
@@ -186,6 +186,15 @@ class WidgetBaseClient {
   virtual void SelectFocusedLink() {}
   virtual gfx::Rect RequestSelectionRect() { return gfx::Rect(); }
   virtual void ResetLastInteractedElements() {}
+
+#if BUILDFLAG(IS_TIZEN_TV)
+  virtual bool IsHitScrollbar() { return false; }
+  virtual bool IsMouseDownEventSwallowed() { return false; }
+  virtual void SuspendNetworkLoading() {}
+  virtual void ResumeNetworkLoading() {}
+  virtual void SetFloatVideoWindowState(bool enabled) {};
+#endif // IS_TIZEN_TV
+
 #endif
 
   // Convert screen coordinates to device emulated coordinates (scaled
index c0247ca8a9ae5c6b2158cea4b892e2fd0a0f0fda..6df07b9728401226513eddb6ec0140219d08c06f 100644 (file)
@@ -785,6 +785,15 @@ void EWebView::Resume() {
 #endif
 }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+void EWebView::SetFloatVideoWindowState(bool enabled) {
+  RenderWidgetHostImpl* rwhi = static_cast<RenderWidgetHostImpl*>(
+      web_contents_->GetRenderViewHost()->GetWidget());
+
+    rwhi->SetFloatVideoWindowState(enabled);
+}
+#endif // IS_TIZEN_TV
+
 double EWebView::GetTextZoomFactor() const {
   if (text_zoom_factor_ < 0.0)
     return -1.0;
index a5b33d5f94c6e2b31054ceb9967f912b02ae4fe1..981217e2027dbbed0a621b21bf6646b13250c3d9 100644 (file)
@@ -347,6 +347,9 @@ class EWebView {
   void Suspend();
   void Resume();
   void Stop();
+#if BUILDFLAG(IS_TIZEN_TV)
+  void SetFloatVideoWindowState(bool enabled);
+#endif // IS_TIZEN_TV
   void SetSessionTimeout(uint64_t timeout);
   double GetTextZoomFactor() const;
   void SetTextZoomFactor(double text_zoom_factor);
index af9ed6d9a5cfed46c26be73cab86382c1e983a8f..118651ad991da9f01a777131871f9aa277e5b662 100644 (file)
@@ -1772,10 +1772,12 @@ void ewk_view_voicemanager_labels_clear(Evas_Object* view) {
 #endif
 }
 
-void ewk_view_floating_window_state_changed(const Evas_Object *o, Eina_Bool status)
+void ewk_view_floating_window_state_changed(const Evas_Object *view, Eina_Bool status)
 {
 #if BUILDFLAG(IS_TIZEN_TV)
-  EWK_VIEW_IMPL_GET_OR_RETURN(o, impl);
+  EWK_VIEW_IMPL_GET_OR_RETURN(view, impl);
+  LOG(INFO) << __FUNCTION__ << ", view: "<< view << ", status: " << status;
+  impl->SetFloatVideoWindowState(status);
 #else
   LOG_EWK_API_MOCKUP();
 #endif
index 7ca20ad94fe32e0c94a1e50b2d073c65579eaf50..f3b57c3d4a537508d6bb33215e4394cc8c79854d 100644 (file)
@@ -63,6 +63,16 @@ class ContentRendererClientEfl : public content::ContentRendererClient {
                         blink::WebNavigationPolicy default_policy,
                         bool is_redirect) override;
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  // Floating Video Window
+  void SetFloatVideoWindowState(bool enable) {
+    floating_video_window_on_ = enable;
+  }
+  bool HasFloatingVideoWindowOn() const override {
+    return floating_video_window_on_;
+  }
+#endif
+
   void DidCreateScriptContext(content::RenderFrame* render_frame,
                               v8::Handle<v8::Context> context,
                               int world_id);
@@ -105,6 +115,10 @@ class ContentRendererClientEfl : public content::ContentRendererClient {
   std::unique_ptr<visitedlink::VisitedLinkReader> visited_link_reader_;
   bool javascript_can_open_windows_ = true;
   bool shutting_down_ = false;
+
+#if BUILDFLAG(IS_TIZEN_TV)
+  bool floating_video_window_on_ = false;
+#endif
 };
 
 #endif  // CONTENT_RENDERER_CLIENT_EFL_H