[M120 Migration][MM][HBBTV] Support Parental rating feature 35/307435/10
authoryangzhiwen <zw714.yang@samsung.com>
Fri, 8 Mar 2024 08:03:45 +0000 (16:03 +0800)
committeryangzhiwen <zw714.yang@samsung.com>
Tue, 12 Mar 2024 02:06:42 +0000 (10:06 +0800)
1.implement ewk api ewk_media_set_parental_rating_result.
2.implement ewk callback api "on,parentalrating,info".

refer:
https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/293483/

Change-Id: If9727683890cddcdb8bfdabbd098d46eb773b4e7
Signed-off-by: yangzhiwen <zw714.yang@samsung.com>
49 files changed:
content/browser/renderer_host/render_widget_host_impl.cc
content/browser/renderer_host/render_widget_host_impl.h
content/public/browser/web_contents_delegate.h
media/base/pipeline.h
media/base/pipeline_impl.cc
media/base/pipeline_impl.h
media/base/renderer.h
media/filters/pipeline_controller.cc
media/filters/pipeline_controller.h
media/mojo/clients/mojo_renderer.cc
media/mojo/clients/mojo_renderer.h
media/mojo/clients/mojo_renderer_wrapper.cc
media/mojo/clients/mojo_renderer_wrapper.h
media/mojo/mojom/renderer.mojom
media/mojo/services/mojo_renderer_service.cc
media/mojo/services/mojo_renderer_service.h
third_party/blink/public/mojom/widget/platform_widget.mojom
third_party/blink/public/platform/web_media_player.h
third_party/blink/public/web/web_view.h
third_party/blink/renderer/core/dom/document.cc
third_party/blink/renderer/core/dom/document.h
third_party/blink/renderer/core/execution_context/execution_context.cc
third_party/blink/renderer/core/execution_context/execution_context.h
third_party/blink/renderer/core/execution_context/execution_context_lifecycle_state_observer.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/platform/media/web_media_player_impl.cc
third_party/blink/renderer/platform/media/web_media_player_impl.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/chromium_impl/content/browser/media/tizen_renderer_impl.cc
tizen_src/chromium_impl/content/browser/media/tizen_renderer_impl.h
tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.cc
tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.h
tizen_src/chromium_impl/media/filters/media_player_bridge_capi.h
tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.cc
tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.h
tizen_src/chromium_impl/media/filters/media_player_tizen.h
tizen_src/ewk/efl_integration/eweb_view.cc
tizen_src/ewk/efl_integration/eweb_view.h
tizen_src/ewk/efl_integration/eweb_view_callbacks.h
tizen_src/ewk/efl_integration/public/ewk_view.cc
tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc
tizen_src/ewk/efl_integration/web_contents_delegate_efl.h

index 542069d..a1d7a8e 100644 (file)
@@ -611,6 +611,17 @@ void RenderWidgetHostImpl::UnPauseScheduledTasks() {
 }
 #endif
 
+#if BUILDFLAG(IS_TIZEN_TV)
+void RenderWidgetHostImpl::SetParentalRatingResult(const std::string& url,
+                                                   bool is_pass) {
+  if (!blink_widget_){
+    LOG(ERROR) << "blink_widget_ is null";
+    return;
+  }
+  blink_widget_->SetParentalRatingResult(url, is_pass);
+}
+#endif
+
 // static
 const base::TimeDelta RenderWidgetHostImpl::kActivationNotificationExpireTime =
     base::Milliseconds(300);
index 32b8c5e..c1e2ec6 100644 (file)
@@ -381,6 +381,7 @@ class CONTENT_EXPORT RenderWidgetHostImpl
 
 #if BUILDFLAG(IS_TIZEN_TV)
   void SetTranslatedURL(const std::string& url);
+  void SetParentalRatingResult(const std::string& url, bool is_pass);
 #endif
 
   RenderWidgetHostDelegate* delegate() const { return delegate_; }
index 2bf3192..d3be49b 100644 (file)
@@ -747,6 +747,8 @@ class CONTENT_EXPORT WebContentsDelegate {
                                        uint32_t previous,
                                        uint32_t current) {}
   virtual bool IsHighBitRate() const { return false; }
+  virtual void NotifyParentalRatingInfo(const std::string& info,
+                                        const std::string& url) {}
   virtual void NotifyDownloadableFontInfo(const std::string& scheme_id_uri,
                                           const std::string& value,
                                           const std::string& data,
index a2e4554..aba0a73 100644 (file)
@@ -280,6 +280,7 @@ class MEDIA_EXPORT Pipeline {
 #endif
 #if BUILDFLAG(IS_TIZEN_TV)
   virtual void SetContentMimeType(const std::string& mime_type) = 0;
+  virtual void SetParentalRatingResult(bool is_pass) = 0;
 #endif
 };
 
index bfe9c8e..747ff15 100644 (file)
@@ -116,6 +116,7 @@ class PipelineImpl::RendererWrapper final : public DemuxerHost,
 #endif
 #if BUILDFLAG(IS_TIZEN_TV)
   void SetContentMimeType(const std::string& mime_type);
+  void SetParentalRatingResult(bool is_pass);
 #endif
 
   // |enabled_track_ids| contains track ids of enabled audio tracks.
@@ -703,6 +704,15 @@ void PipelineImpl::RendererWrapper::SetContentMimeType(
   if (shared_state_.renderer)
     shared_state_.renderer->SetContentMimeType(mime_type_);
 }
+
+void PipelineImpl::RendererWrapper::SetParentalRatingResult(bool is_pass) {
+  DCHECK(media_task_runner_->RunsTasksInCurrentSequence());
+
+  if (shared_state_.renderer)
+    shared_state_.renderer->SetParentalRatingResult(is_pass);
+  else
+    LOG(ERROR) << "renderer is null";
+}
 #endif
 
 #if BUILDFLAG(IS_TIZEN_TV)
@@ -1921,7 +1931,14 @@ void PipelineImpl::SetContentMimeType(const std::string& mime_type) {
       base::BindOnce(&RendererWrapper::SetContentMimeType,
                      base::Unretained(renderer_wrapper_.get()), mime_type));
 }
+
+void PipelineImpl::SetParentalRatingResult(bool is_pass) {
+  DVLOG(2) << __func__;
+  DCHECK(thread_checker_.CalledOnValidThread());
+  renderer_wrapper_->SetParentalRatingResult(is_pass);
+}
 #endif
+
 void PipelineImpl::OnDurationChange(base::TimeDelta duration) {
   DVLOG(2) << __func__;
   DCHECK(thread_checker_.CalledOnValidThread());
index cc738ac..93a56b6 100644 (file)
@@ -176,6 +176,7 @@ class MEDIA_EXPORT PipelineImpl : public Pipeline {
   void OnMetadata(const PipelineMetadata& metadata);
 #if BUILDFLAG(IS_TIZEN_TV)
   void SetContentMimeType(const std::string& mime_type) override;
+  void SetParentalRatingResult(bool is_pass) override;
 #endif
   void OnBufferingStateChange(BufferingState state,
                               BufferingStateChangeReason reason);
index 1dc4f6b..e1c5783 100644 (file)
@@ -109,6 +109,7 @@ class MEDIA_EXPORT Renderer {
 
 #if BUILDFLAG(IS_TIZEN_TV)
   virtual void SetContentMimeType(const std::string& mime_type) {}
+  virtual void SetParentalRatingResult(bool is_pass) {}
 #endif
 
   // Starts rendering from |time|.
index 32cd7d5..1bb647a 100644 (file)
@@ -5,6 +5,7 @@
 #include "media/filters/pipeline_controller.h"
 
 #include "base/functional/bind.h"
+#include "base/logging.h"
 #include "media/base/demuxer.h"
 
 namespace media {
@@ -481,5 +482,12 @@ void PipelineController::SetContentMimeType(const std::string& mime_type) {
   if (pipeline_)
     pipeline_->SetContentMimeType(mime_type);
 }
+
+void PipelineController::SetParentalRatingResult(bool is_pass) {
+  if (pipeline_)
+    pipeline_->SetParentalRatingResult(is_pass);
+  else
+    LOG(ERROR) << "pipeline_ is null";
+}
 #endif
 }  // namespace media
index 071ce06..c7d06ef 100644 (file)
@@ -165,6 +165,7 @@ class MEDIA_EXPORT PipelineController {
 
 #if BUILDFLAG(IS_TIZEN_TV)
   void SetContentMimeType(const std::string& mime_type);
+  void SetParentalRatingResult(bool is_pass);
 #endif
  private:
   // Attempts to make progress from the current state to the target state.
index 3a2a101..7fec3cc 100644 (file)
@@ -351,6 +351,15 @@ void MojoRenderer::SetContentMimeType(const std::string& mime_type) {
   if (remote_renderer_.is_bound())
     remote_renderer_->SetContentMimeType(mime_type);
 }
+
+void MojoRenderer::SetParentalRatingResult(bool is_pass) {
+  DCHECK(task_runner_->RunsTasksInCurrentSequence());
+
+  if (remote_renderer_.is_bound())
+    remote_renderer_->SetParentalRatingResult(is_pass);
+  else
+    LOG(ERROR) << "remote_renderer is null";
+}
 #endif
 
 void MojoRenderer::OnWaiting(WaitingReason reason) {
index 918f3d2..ba357a9 100644 (file)
@@ -78,6 +78,7 @@ class MojoRenderer : public Renderer, public mojom::RendererClient {
 
 #if BUILDFLAG(IS_TIZEN_TV)
   void SetContentMimeType(const std::string& mime_type) override;
+  void SetParentalRatingResult(bool is_pass) override;
 #endif
 
  private:
index 823956f..798099f 100644 (file)
@@ -81,6 +81,13 @@ void MojoRendererWrapper::SetContentMimeType(const std::string& mime_type) {
   if (mojo_renderer_)
     mojo_renderer_->SetContentMimeType(mime_type);
 }
+
+void MojoRendererWrapper::SetParentalRatingResult(bool is_pass) {
+  if (mojo_renderer_)
+    mojo_renderer_->SetParentalRatingResult(is_pass);
+  else
+    LOG(ERROR) << "mojo_renderer_ is null";
+}
 #endif
 
 }  // namespace media
index d0e1db3..cd3b5d9 100644 (file)
@@ -50,6 +50,7 @@ class MojoRendererWrapper : public Renderer {
 
 #if BUILDFLAG(IS_TIZEN_TV)
   void SetContentMimeType(const std::string& mime_type) override;
+  void SetParentalRatingResult(bool is_pass) override;
 #endif
 
   base::TimeDelta GetMediaTime() override;
index 4efe13d..204cb3b 100644 (file)
@@ -70,6 +70,9 @@ interface Renderer {
 
   [EnableIf=is_tizen_tv]
   SetContentMimeType(string mime_type);
+
+  [EnableIf=is_tizen_tv]
+  SetParentalRatingResult(bool is_pass);
 };
 
 // A Mojo equivalent of media::RendererClient. See media/mojo/README.md
index 4b2b405..dc315f6 100644 (file)
@@ -215,6 +215,14 @@ void MojoRendererService::SetContentMimeType(const std::string& mime_type) {
   if (renderer_)
     renderer_->SetContentMimeType(mime_type);
 }
+
+void MojoRendererService::SetParentalRatingResult(bool is_pass) {
+  DVLOG(3) << __func__;
+  if (renderer_)
+    renderer_->SetParentalRatingResult(is_pass);
+  else
+    LOG(ERROR) << "renderer_ is null";
+}
 #endif
 
 void MojoRendererService::OnBufferingStateChange(
index d15ec87..5b6e16b 100644 (file)
@@ -84,6 +84,7 @@ class MEDIA_MOJO_EXPORT MojoRendererService final : public mojom::Renderer,
 
 #if BUILDFLAG(IS_TIZEN_TV)
   void SetContentMimeType(const std::string& mime_type) final;
+  void SetParentalRatingResult(bool is_pass) final;
 #endif
 
  private:
index 73fc64b..78dabfb 100644 (file)
@@ -142,6 +142,9 @@ interface Widget {
   [EnableIf=is_tizen_tv]
   SetTranslatedURL(string url);
 
+  [EnableIf=is_tizen_tv]
+  SetParentalRatingResult(string url, bool is_pass);
+
   [EnableIf=is_efl]
   PrintToPdf(uint32 width, uint32 height, mojo_base.mojom.FilePath filename);
 
index 6b600f6..7bc042b 100644 (file)
@@ -393,6 +393,10 @@ class WebMediaPlayer {
   // Adjusts the frame sink hierarchy for the media frame sink.
   virtual void RegisterFrameSinkHierarchy() {}
   virtual void UnregisterFrameSinkHierarchy() {}
+
+#if BUILDFLAG(IS_TIZEN_TV)
+  virtual void SetParentalRatingResult(bool is_pass) {}
+#endif
 };
 
 }  // namespace blink
index 431f402..de07ce2 100644 (file)
@@ -545,6 +545,7 @@ class BLINK_EXPORT WebView {
 
 #if BUILDFLAG(IS_TIZEN_TV)
   virtual void SetFloatVideoWindowState(bool enable) = 0;
+  virtual void SetParentalRatingResult(const WebString&, bool) = 0;
 #endif
 
  protected:
index 2964483..c057ad2 100644 (file)
@@ -9396,6 +9396,13 @@ Document* Document::parseHTMLUnsafe(ExecutionContext* context,
 void Document::SetTranslatedURL(const String& url) {
   GetExecutionContext()->SetTranslatedURL(url);
 }
+
+void Document::SetParentalRatingResult(const String& url, bool is_pass) {
+  if (GetExecutionContext())
+    GetExecutionContext()->SetParentalRatingResult(url, is_pass);
+  else
+    LOG(ERROR) << "GetExecutionContext() is false";
+}
 #endif
 
 template class CORE_TEMPLATE_EXPORT Supplement<Document>;
index 28d9ba1..ee3af84 100644 (file)
@@ -1739,6 +1739,10 @@ class CORE_EXPORT Document : public ContainerNode,
 
   bool IsSlotAssignmentDirty() const;
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  void SetParentalRatingResult(const String& url, bool is_pass);
+#endif
+
 #if DCHECK_IS_ON()
   unsigned& SlotAssignmentRecalcForbiddenRecursionDepth() {
     return slot_assignment_recalc_forbidden_recursion_depth_;
index cb2a173..fc386a1 100644 (file)
@@ -281,6 +281,28 @@ void ExecutionContext::SetTranslatedURL(const String& url) {
         state_observer->SetTranslatedURL(url);
       });
 }
+
+void ExecutionContext::SetParentalRatingResult(const String& url,
+                                               bool is_pass) {
+  ContextLifecycleNotifier::observers().ForEachObserver(
+      [&](ContextLifecycleObserver* observer) {
+        if (!observer->IsExecutionContextLifecycleObserver())
+          return;
+        if (static_cast<ExecutionContextLifecycleObserver*>(observer)
+                ->ObserverType() !=
+            ExecutionContextLifecycleObserver::kStateObjectType)
+          return;
+        ExecutionContextLifecycleStateObserver* state_observer =
+            static_cast<ExecutionContextLifecycleStateObserver*>(observer);
+#if DCHECK_IS_ON()
+        DCHECK_EQ(state_observer->GetExecutionContext(), Context());
+        DCHECK(state_observer->UpdateStateIfNeededCalled());
+#endif
+        if (state_observer->IsHTMLMediaElement() &&
+            state_observer->GetUrl() == url)
+          state_observer->SetParentalRatingResult(is_pass);
+      });
+}
 #endif
 
 void ExecutionContext::AddConsoleMessageImpl(
index e3dc666..131cc60 100644 (file)
@@ -478,6 +478,7 @@ class CORE_EXPORT ExecutionContext : public Supplementable<ExecutionContext>,
 
 #if BUILDFLAG(IS_TIZEN_TV)
   void SetTranslatedURL(const String&);
+  void SetParentalRatingResult(const String& url, bool is_pass);
 #endif
 
  protected:
index a51ec26..0a5c90d 100644 (file)
@@ -31,6 +31,7 @@
 #include "third_party/blink/public/mojom/frame/lifecycle.mojom-blink-forward.h"
 #include "third_party/blink/renderer/core/core_export.h"
 #include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_observer.h"
+#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
 
 namespace blink {
 
@@ -69,6 +70,12 @@ class CORE_EXPORT ExecutionContextLifecycleStateObserver
   virtual void ContextLifecycleStateChanged(
       mojom::blink::FrameLifecycleState state) {}
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  virtual bool IsHTMLMediaElement() const { return false; }
+  virtual String GetUrl() const { return ""; }
+  virtual void SetParentalRatingResult(bool) {}
+#endif
+
   void SetExecutionContext(ExecutionContext*) override;
 #if BUILDFLAG(IS_TIZEN_TV)
   virtual void SetTranslatedURL(const String&) {}
index 7326609..c71372a 100644 (file)
@@ -4618,6 +4618,20 @@ void WebViewImpl::SetTranslatedURL(const WebString url) {
     document->SetTranslatedURL(url);
   }
 }
+
+void WebViewImpl::SetParentalRatingResult(const WebString& url, bool is_pass) {
+  if (!MainFrameImpl()){
+    LOG(ERROR) << "no main frame.";
+    return;
+  }
+
+  for (const Frame* frame = MainFrameImpl()->GetFrame(); frame;
+       frame = frame->Tree().TraverseNext()) {
+    Document* document = To<LocalFrame>(frame)->GetDocument();
+    DCHECK(document);
+    document->SetParentalRatingResult(url, is_pass);
+  }
+}
 #endif
 
 }  // namespace blink
index 5688c0d..b830376 100644 (file)
@@ -566,6 +566,10 @@ class CORE_EXPORT WebViewImpl final : public WebView,
   gfx::Size Size();
   gfx::Size MainFrameSize();
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  void SetParentalRatingResult(const WebString&, bool) override;
+#endif
+
   PageScaleConstraintsSet& GetPageScaleConstraintsSet() const;
 
   gfx::Vector2dF ElasticOverscroll() const { return elastic_overscroll_; }
index 5c5ed42..c6ff440 100644 (file)
@@ -1437,6 +1437,17 @@ void WebFrameWidgetImpl::SetTranslatedURL(const WTF::String& url) {
     return;
   webview->SetTranslatedURL(blink::WebString::FromUTF8(url.Ascii()));
 }
+
+void WebFrameWidgetImpl::SetParentalRatingResult(const WTF::String& url,
+                                                 bool is_pass) {
+  WebViewImpl* webview = View();
+  if (!webview){
+    LOG(ERROR) << "no webview.";
+    return;
+  }
+  webview->SetParentalRatingResult(blink::WebString::FromUTF8(url.Ascii()),
+                                   is_pass);
+}
 #endif
 
 void WebFrameWidgetImpl::SetNeedsRecalculateRasterScales() {
index 646072f..7249331 100644 (file)
@@ -869,6 +869,7 @@ class CORE_EXPORT WebFrameWidgetImpl
   //Browser edge scroll
   void EdgeScrollBy(const gfx::Point& offset, const gfx::Point& mouse_position) override;
   void SetTranslatedURL(const WTF::String& url) override;
+  void SetParentalRatingResult(const WTF::String& url, bool is_pass) override;
 #endif
 
   // mojom::blink::FrameWidgetInputHandler overrides.
index ace3913..3c081e3 100644 (file)
@@ -4101,6 +4101,15 @@ void HTMLMediaElement::SetTranslatedURL(const String& url) {
   }
   RequestReload(current_src_.GetSource());
 }
+
+void HTMLMediaElement::SetParentalRatingResult(bool is_pass) {
+  LOG(INFO) << "setParentalRatingResult:" << BoolString(is_pass);
+  if (!GetWebMediaPlayer()) {
+    LOG(ERROR) << "setParentalRatingResult: mediaplayer not created";
+    return;
+  }
+  GetWebMediaPlayer()->SetParentalRatingResult(is_pass);
+}
 #endif
 
 bool HTMLMediaElement::HasPendingActivity() const {
index 3c56547..45db0e5 100644 (file)
@@ -384,6 +384,9 @@ class CORE_EXPORT HTMLMediaElement
   WebString GetContentMIMEType() override;
   void RequestReload(const KURL& new_url);
   void SetTranslatedURL(const String&) override;
+  bool IsHTMLMediaElement() const override { return true; }
+  WTF::String GetUrl() const override { return current_src_.GetSource(); }
+  void SetParentalRatingResult(bool is_pass) override;
 #endif
 
   bool HasMediaSource() const { return media_source_attachment_.get(); }
index 47767d0..78775f6 100644 (file)
@@ -2342,6 +2342,12 @@ void WebMediaPlayerImpl::OnBufferingStateChangeInternal(
   UpdatePlayState();
 }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+void WebMediaPlayerImpl::SetParentalRatingResult(bool is_pass) {
+  pipeline_controller_->SetParentalRatingResult(is_pass);
+}
+#endif
+
 void WebMediaPlayerImpl::OnDurationChange() {
   DCHECK(main_task_runner_->BelongsToCurrentThread());
 
index 285746c..a7041f9 100644 (file)
@@ -408,6 +408,9 @@ class PLATFORM_EXPORT WebMediaPlayerImpl
       media::BufferingState state,
       media::BufferingStateChangeReason reason) override;
   void OnDurationChange() override;
+#if BUILDFLAG(IS_TIZEN_TV)
+  void SetParentalRatingResult(bool is_pass) override;
+#endif
   void OnWaiting(media::WaitingReason reason) override;
   void OnAudioConfigChange(const media::AudioDecoderConfig& config) override;
   void OnVideoConfigChange(const media::VideoDecoderConfig& config) override;
index 2f37db5..92cf4f2 100644 (file)
@@ -584,6 +584,10 @@ void WidgetBase::SetFloatVideoWindowState(bool enabled) {
 void WidgetBase::SetTranslatedURL(const WTF::String& url) {
   client_->SetTranslatedURL(url);
 }
+
+void WidgetBase::SetParentalRatingResult(const WTF::String& url, bool is_pass) {
+  client_->SetParentalRatingResult(url, is_pass);
+}
 #endif // IS_TIZEN_TV
 
 void WidgetBase::WasHidden() {
index bb540a4..32cb498 100644 (file)
@@ -173,6 +173,7 @@ class PLATFORM_EXPORT WidgetBase : public mojom::blink::Widget,
 
 #if BUILDFLAG(IS_TIZEN_TV)
   void SetTranslatedURL(const WTF::String& url);
+  void SetParentalRatingResult(const WTF::String& url, bool is_pass) override;
 #endif
 
   void WasHidden() override;
index 8702ce4..270a84b 100644 (file)
@@ -206,6 +206,7 @@ class WidgetBaseClient {
 
 #if BUILDFLAG(IS_TIZEN_TV)
   virtual void SetTranslatedURL(const WTF::String& url) {}
+  virtual void SetParentalRatingResult(const WTF::String& url, bool is_pass) {}
 #endif
 
   // Convert screen coordinates to device emulated coordinates (scaled
index dc2c609..7c4cbbe 100644 (file)
@@ -482,6 +482,13 @@ void TizenRendererImpl::SetContentMimeType(const std::string& mime_type) {
     media_player_->SetContentMimeType(mime_type);
 }
 
+void TizenRendererImpl::SetParentalRatingResult(bool is_pass) {
+  if (media_player_)
+    media_player_->SetParentalRatingResult(is_pass);
+  else
+    LOG(ERROR) << "media_player_ is null";
+}
+
 bool TizenRendererImpl::PlaybackNotificationEnabled() {
   content::WebContents* web_contents = GetWebContents();
   if (!web_contents) {
index d9e66cd..2fac96d 100644 (file)
@@ -152,6 +152,7 @@ class CONTENT_EXPORT TizenRendererImpl
 
 #if BUILDFLAG(IS_TIZEN_TV)
   void SetContentMimeType(const std::string& mime_type) override;
+  void SetParentalRatingResult(bool is_pass) override;
 #endif
 
  private:
index 36f208c..d530c7c 100644 (file)
@@ -444,6 +444,14 @@ void RWHVAuraCommonHelperEfl::DidEdgeScrollBy(const gfx::Point& offset,
   web_contents_->GetDelegate()->DidEdgeScrollBy(offset, handled);
 }
 
+void RWHVAuraCommonHelperEfl::SetParentalRatingResult(const std::string& url,
+                                                      bool is_pass) {
+  if (rwhv_aura_)
+    rwhv_aura_->host()->SetParentalRatingResult(url, is_pass);
+  else
+    LOG(ERROR) << "rwhv_aura_ is null";
+}
+
 void RWHVAuraCommonHelperEfl::SetPopupMenuVisible(const bool visible) {
   NOTIMPLEMENTED();
 }
index 1df5811..ba6dd9b 100644 (file)
@@ -142,6 +142,7 @@ class CONTENT_EXPORT RWHVAuraCommonHelperEfl {
   void SetIMERecommendedWordsType(bool should_enable);
   void SetMouseEventsEnabled(bool enabled);
   void SetTranslatedURL(const std::string& url);
+  void SetParentalRatingResult(const std::string& url, bool is_pass);
 #endif
 
   void OnGestureEvent(ui::GestureEvent* event);
index efd6250..d1d0bf1 100644 (file)
@@ -88,6 +88,7 @@ class MEDIA_EXPORT MediaPlayerBridgeCapi : public MediaPlayerTizen {
   void SetMediaPlayerClient(MediaPlayerTizenClient* client) override {
     client_ = client;
   }
+  void SetParentalRatingResult(bool is_pass) override{};
 
 #if defined(TIZEN_VIDEO_HOLE)
   void SetVideoHole(bool is_video_hole) override;
index c9ece2c..94c898b 100644 (file)
@@ -97,6 +97,8 @@ void MediaPlayerBridgeCapiTV::Prepare() {
   if (blink::IsHbbTV() && CheckHighBitRate() && stream_type_ == DASH_STREAM)
     AppendUrlHighBitRate(url_.spec());
   player_prepared_ = false;
+
+  parental_rating_pass_ = true;
   MediaPlayerBridgeCapi::Prepare();
   if (GetMediaPlayerClient())
     GetMediaPlayerClient()->NotifyPlaybackState(kPlaybackReady, player_id_);
@@ -122,6 +124,14 @@ bool MediaPlayerBridgeCapiTV::Play() {
       LOG(ERROR) << "HBBTV prePlay fail.";
     return false;
   }
+
+  if (blink::IsHbbTV() && !parental_rating_pass_) {
+    LOG(INFO) << "parental rating authenticatoin is not pass yet,waiting...";
+    delayed_player_state_ = PLAYER_STATE_DELAYED_PLAY;
+    MediaPlayerBridgeCapi::ExecuteDelayedPlayerState();
+    return false;
+  }
+
   if (!MediaPlayerBridgeCapi::Play())
     return false;
   if (GetMediaPlayerClient())
@@ -531,4 +541,30 @@ void MediaPlayerBridgeCapiTV::OnDrmError(int err_code, char* err_str) {
   MediaPlayerBridgeCapi::OnHandlePlayerError(err_code, FROM_HERE);
 }
 
+void MediaPlayerBridgeCapiTV::HandleParentalRatingInfo(const std::string& info,
+                                                       const std::string& url) {
+  content::WebContentsDelegate* web_contents_delegate =
+      GetMediaPlayerClient()->GetWebContentsDelegate();
+  if (!web_contents_delegate){
+    LOG(ERROR) << "web_contents_delegate is null";
+    return;
+  }
+  web_contents_delegate->NotifyParentalRatingInfo(info, url);
+}
+
+void MediaPlayerBridgeCapiTV::SetParentalRatingResult(bool is_pass) {
+  LOG(INFO) << "ParentalRatingResult:" << std::boolalpha << is_pass;
+  parental_rating_pass_ = is_pass;
+
+  // if authentication fail, raise MEDIA_ERROR_DECODE
+  if (!parental_rating_pass_) {
+    OnHandlePlayerError(PLAYER_ERROR_INVALID_OPERATION, FROM_HERE);
+    return;
+  }
+
+  if (player_prepared_) {
+    LOG(INFO) << "player already prepared,execute play";
+    ExecuteDelayedPlayerState();
+  }
+}
 }  // namespace media
index 5cbab59..228deca 100644 (file)
@@ -45,6 +45,9 @@ class MEDIA_EXPORT MediaPlayerBridgeCapiTV : public MediaPlayerBridgeCapi {
   void OnPlayerPreloading();
 
   void OnDrmError(int err_code, char* err_str);
+  void SetParentalRatingResult(bool is_pass) override;
+  void HandleParentalRatingInfo(const std::string& info,
+                                const std::string& url);
 
  protected:
   void PlayerPrepared() override;
@@ -70,6 +73,7 @@ class MEDIA_EXPORT MediaPlayerBridgeCapiTV : public MediaPlayerBridgeCapi {
   std::string hbbtv_url_{""};  // url_ + HIGHBITRATE(if mpd)
   std::string mime_type_ = "";
   bool is_live_stream_ = false;
+  bool parental_rating_pass_{false};
 
   base::TimeDelta min_seekable_time_{base::TimeDelta()};
   base::TimeDelta max_seekable_time_{base::TimeDelta()};
index 0835ecf..b7da999 100644 (file)
@@ -108,6 +108,7 @@ class MEDIA_EXPORT MediaPlayerTizen {
   virtual void EnableTbmBufferCallback(bool enable) {}
   virtual void SetAppInfo() {}
   virtual void SetContentMimeType(const std::string& mime_type) {}
+  virtual void SetParentalRatingResult(bool is_pass) {}
 };
 }  // namespace media
 
index c184c32..103ed09 100644 (file)
 #include "devtools_port_manager.h"
 #include "private/ewk_file_chooser_request_private.h"
 #include "public/ewk_media_downloadable_font_info.h"
+#include "public/ewk_media_parental_rating_info.h"
 #include "public/ewk_media_playback_info_product.h"
 #include "public/ewk_user_media_internal.h"
 #endif
@@ -3366,6 +3367,27 @@ void EWebView::AddDynamicCertificatePath(const std::string& host,
                                          const std::string& cert_path) {
   web_contents_->AddDynamicCertificatePath(host, cert_path);
 }
+
+void EWebView::NotifyParentalRatingInfo(const char* info, const char* url) {
+  LOG(INFO) << "info:" << info << ",url:" << url;
+  Ewk_Media_Parental_Rating_Info* data =
+      ewkMediaParentalRatingInfoCreate(info, url);
+  SmartCallback<EWebViewCallbacks::ParentalRatingInfo>().call(
+      static_cast<void*>(data));
+  ewkMediaParentalRatingInfoDelete(data);
+}
+
+void EWebView::SetParentalRatingResult(const char* url, bool is_pass) {
+  LOG(INFO) << "SetParentalRatingResult,url:" << url
+            << ",pass:" << std::boolalpha << is_pass;
+
+  if (!rwhva() || !rwhva()->aura_efl_helper()){
+    LOG(ERROR) << "rwhva() or rwhva()->aura_efl_helper() is false";
+    return;
+  }
+  rwhva()->aura_efl_helper()->SetParentalRatingResult(
+      static_cast<std::string>(url), is_pass);
+}
 #endif
 
 bool EWebView::SetVisibility(bool enable) {
index 28c77c5..4e52d21 100644 (file)
@@ -793,6 +793,8 @@ class EWebView {
       std::array<blink::WebMediaDeviceInfoArray, NUM_MEDIA_DEVICE_TYPES>;
   void OnDeviceListed(const MediaDeviceEnumeration& devices);
   void SetTranslatedURL(const char* url);
+  void NotifyParentalRatingInfo(const char* info, const char* url);
+  void SetParentalRatingResult(const char* info, bool is_pass);
 #endif  // IS_TIZEN_TV
 
   void SetDidChangeThemeColorCallback(
index bd2cc64..11dea6a 100644 (file)
@@ -158,6 +158,7 @@ enum CallbackType {
 #if BUILDFLAG(IS_TIZEN_TV)
   HoverOverLink,
   HoverOutLink,
+  ParentalRatingInfo,
   LoginFormSubmitted,
   LoginFields,
   DidBlockInsecureContent,
@@ -334,6 +335,7 @@ DECLARE_EWK_VIEW_CALLBACK(NewWindowNavigationPolicyDecision, "policy,decision,ne
 #endif  // IS_TIZEN
 
 #if BUILDFLAG(IS_TIZEN_TV)
+DECLARE_EWK_VIEW_CALLBACK(ParentalRatingInfo, "on,parentalrating,info", void*);
 DECLARE_EWK_VIEW_CALLBACK(HoverOverLink, "hover,over,link", const char*);
 DECLARE_EWK_VIEW_CALLBACK(HoverOutLink, "hover,out,link", const char*);
 DECLARE_EWK_VIEW_CALLBACK(LoginFormSubmitted,
index 3addeff..4302dd4 100644 (file)
@@ -1751,7 +1751,12 @@ void ewk_media_set_subtitle_lang(Evas_Object* ewkView, const char* lang_list)
 
 void ewk_media_set_parental_rating_result(Evas_Object* ewkView, const char* url, Eina_Bool is_pass)
 {
-  LOG_EWK_API_MOCKUP();
+#if BUILDFLAG(IS_TIZEN_TV)
+  EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl);
+  impl->SetParentalRatingResult(url, is_pass);
+#else
+  LOG_EWK_API_MOCKUP("Only for Tizen TV.");
+#endif
 }
 
 void ewk_media_start_with_high_bit_rate(Evas_Object* ewkView, Eina_Bool high_bitrate)
index 030db1b..9178c52 100644 (file)
@@ -787,6 +787,14 @@ bool WebContentsDelegateEfl::IsHighBitRate() const {
   return web_view_ ? web_view_->IsHighBitRate() : false;
 }
 
+void WebContentsDelegateEfl::NotifyParentalRatingInfo(const std::string& info,
+                                                      const std::string& url) {
+  if (web_view_)
+    web_view_->NotifyParentalRatingInfo(info.c_str(), url.c_str());
+  else
+    LOG(ERROR) << "web_view_ is null";
+}
+
 void WebContentsDelegateEfl::NotifyDownloadableFontInfo(
     const std::string& scheme_id_uri,
     const std::string& value,
index a056dce..eda5506 100644 (file)
@@ -88,6 +88,8 @@ class WebContentsDelegateEfl : public WebContentsDelegate {
                            bool* media_resource_acquired,
                            std::string* translated_url,
                            std::string* drm_info) override;
+  void NotifyParentalRatingInfo(const std::string& info,
+                                const std::string& url) override;
 #endif
   void RequestCertificateConfirm(
       WebContents* web_contents,