From a441573c69523ac7a4fb8605b0f27b8add23617a Mon Sep 17 00:00:00 2001 From: lizhiwei Date: Thu, 26 Dec 2024 20:37:50 +0800 Subject: [PATCH] video assistant code in src Signed-off-by: lizhiwei --- base/base_switches.cc | 4 + base/base_switches.h | 4 + cc/layers/layer.h | 3 + cc/layers/surface_layer.cc | 11 +++ cc/layers/surface_layer.h | 11 +++ cc/layers/surface_layer_impl.cc | 32 ++++++-- cc/layers/surface_layer_impl.h | 10 +++ cc/trees/layer_tree_host.cc | 9 +++ cc/trees/layer_tree_host.h | 4 + cc/trees/layer_tree_host_impl.cc | 6 ++ cc/trees/layer_tree_host_impl.h | 6 ++ cc/trees/layer_tree_impl.cc | 5 ++ cc/trees/layer_tree_impl.h | 4 + cc/trees/proxy_impl.cc | 9 +++ cc/trees/proxy_impl.h | 3 + cc/trees/proxy_main.cc | 5 ++ cc/trees/proxy_main.h | 3 + content/browser/BUILD.gn | 17 +++++ .../media/media_web_contents_observer.cc | 40 ++++++++++ .../media/media_web_contents_observer.h | 12 +++ .../media/video_assistant/video_assistant.cc | 41 +++++++++++ .../media/video_assistant/video_assistant.h | 50 +++++++++++++ .../browser/web_contents/web_contents_impl.cc | 73 ++++++++++++++++++- .../browser/web_contents/web_contents_impl.h | 20 +++++ .../public/browser/web_contents_delegate.cc | 17 +++++ .../public/browser/web_contents_delegate.h | 16 ++++ media/mojo/mojom/media_player.mojom | 40 ++++++++++ ohos_build/build/config/ohos.json | 71 ++++++++++++------ ohos_nweb/src/cef_delegate/nweb_delegate.cc | 6 +- .../src/cef_delegate/nweb_handler_delegate.cc | 25 +++++++ .../src/cef_delegate/nweb_handler_delegate.h | 8 ++ ohos_nweb/src/nweb_impl.cc | 13 ++++ ohos_nweb/src/nweb_impl.h | 4 + 33 files changed, 551 insertions(+), 31 deletions(-) create mode 100644 content/browser/media/video_assistant/video_assistant.cc create mode 100644 content/browser/media/video_assistant/video_assistant.h mode change 100644 => 100755 ohos_build/build/config/ohos.json diff --git a/base/base_switches.cc b/base/base_switches.cc index 8aa19df658..17c5004e57 100644 --- a/base/base_switches.cc +++ b/base/base_switches.cc @@ -195,4 +195,8 @@ const char kBundleName[] = "bundle-name"; const char kArkWebInstallPath[] = "arkwebcore-install-path"; #endif +#ifdef OHOS_VIDEO_ASSISTANT +const char kEnableVideoAssistant[] = "enable-nweb-ex-video-assistant"; +#endif // OHOS_VIDEO_ASSISTANT + } // namespace switches diff --git a/base/base_switches.h b/base/base_switches.h index 7b576c06ed..951fda7b77 100644 --- a/base/base_switches.h +++ b/base/base_switches.h @@ -77,6 +77,10 @@ extern const char kBundleName[]; extern const char kArkWebInstallPath[]; #endif +#ifdef OHOS_VIDEO_ASSISTANT +extern const char kEnableVideoAssistant[]; +#endif // OHOS_VIDEO_ASSISTANT + } // namespace switches #endif // BASE_BASE_SWITCHES_H_ diff --git a/cc/layers/layer.h b/cc/layers/layer.h index 1bb4398c15..82809f6521 100644 --- a/cc/layers/layer.h +++ b/cc/layers/layer.h @@ -867,6 +867,9 @@ class CC_EXPORT Layer : public base::RefCounted, virtual void OnLayerRectVisibilityChange(bool visibility) {} #endif +#ifdef OHOS_VIDEO_ASSISTANT + virtual void OnLayerBoundsUpdate(const gfx::Rect& bounds) {} +#endif // OHOS_VIDEO_ASSISTANT void SetShouldInterceptTouchEvent(bool intercept) { should_intercept_touch_event_.Write(*this) = intercept; diff --git a/cc/layers/surface_layer.cc b/cc/layers/surface_layer.cc index ec1b17612d..07527e288c 100644 --- a/cc/layers/surface_layer.cc +++ b/cc/layers/surface_layer.cc @@ -203,5 +203,16 @@ void SurfaceLayer::OnLayerRectUpdate(const gfx::Rect& rect) { } } #endif // OHOS_CUSTOM_VIDEO_PLAYER +#ifdef OHOS_VIDEO_ASSISTANT +void SurfaceLayer::SetLayerBoundsChangeCallback( + LayerBoundsChangeCallback callback) { + layer_bounds_change_callback_ = std::move(callback); +} +void SurfaceLayer::OnLayerBoundsUpdate(const gfx::Rect& bounds) { + if (layer_bounds_change_callback_) { + layer_bounds_change_callback_.Run(bounds); + } +} +#endif // OHOS_VIDEO_ASSISTANT } // namespace cc diff --git a/cc/layers/surface_layer.h b/cc/layers/surface_layer.h index 3522665821..e1b7298aac 100644 --- a/cc/layers/surface_layer.h +++ b/cc/layers/surface_layer.h @@ -65,6 +65,11 @@ class CC_EXPORT SurfaceLayer : public Layer { using RectChangeCallback = base::RepeatingCallback; void SetVideoRectChangeCallback(RectChangeCallback callback); #endif // OHOS_CUSTOM_VIDEO_PLAYER +#ifdef OHOS_VIDEO_ASSISTANT + using LayerBoundsChangeCallback = + base::RepeatingCallback; + void SetLayerBoundsChangeCallback(LayerBoundsChangeCallback callback); +#endif // OHOS_VIDEO_ASSISTANT // Layer overrides. std::unique_ptr CreateLayerImpl( @@ -76,6 +81,9 @@ class CC_EXPORT SurfaceLayer : public Layer { #if defined(OHOS_CUSTOM_VIDEO_PLAYER) void OnLayerRectUpdate(const gfx::Rect& rect) override; #endif // OHOS_CUSTOM_VIDEO_PLAYER +#ifdef OHOS_VIDEO_ASSISTANT + void OnLayerBoundsUpdate(const gfx::Rect& bounds) override; +#endif // OHOS_VIDEO_ASSISTANT const viz::SurfaceId& surface_id() const { return surface_range_.Read(*this).end(); @@ -126,6 +134,9 @@ class CC_EXPORT SurfaceLayer : public Layer { #if defined(OHOS_CUSTOM_VIDEO_PLAYER) RectChangeCallback video_rect_change_callback_; #endif // OHOS_CUSTOM_VIDEO_PLAYER +#ifdef OHOS_VIDEO_ASSISTANT + LayerBoundsChangeCallback layer_bounds_change_callback_; +#endif // OHOS_VIDEO_ASSISTANT }; } // namespace cc diff --git a/cc/layers/surface_layer_impl.cc b/cc/layers/surface_layer_impl.cc index 1a3e4d03bd..783e034636 100644 --- a/cc/layers/surface_layer_impl.cc +++ b/cc/layers/surface_layer_impl.cc @@ -19,6 +19,8 @@ #include "components/viz/common/quads/solid_color_draw_quad.h" #include "components/viz/common/quads/surface_draw_quad.h" +#include "base/logging.h" + namespace cc { // static @@ -212,13 +214,11 @@ void SurfaceLayerImpl::AppendQuads(viz::CompositorRenderPass* render_pass, // |surface_range_| more than once. deadline_in_frames_ = 0u; +#ifdef OHOS_VIDEO_ASSISTANT + OnLayerBoundsUpdate(visible_quad_rect); +#endif // OHOS_VIDEO_ASSISTANT #if defined(OHOS_CUSTOM_VIDEO_PLAYER) - visible_quad_rect.set_origin( - ScreenSpaceTransform().MapPoint(visible_quad_rect.origin())); - if (!visible_quad_rect_.ApproximatelyEqual(visible_quad_rect, 1)) { - visible_quad_rect_ = visible_quad_rect; - layer_tree_impl()->OnLayerRectUpdate(id(), visible_quad_rect); - } + OnLayerRectUpdate(visible_quad_rect); #endif // OHOS_CUSTOM_VIDEO_PLAYER } @@ -334,4 +334,24 @@ const char* SurfaceLayerImpl::LayerTypeAsString() const { return "cc::SurfaceLayerImpl"; } +#ifdef OHOS_VIDEO_ASSISTANT +void SurfaceLayerImpl::OnLayerBoundsUpdate(gfx::Rect visible_quad_rect) { + gfx::Rect layer_bounds = + ScreenSpaceTransform().MapRect(visible_quad_rect); + if (!layer_bounds_.ApproximatelyEqual(layer_bounds, 1)) { + layer_bounds_ = layer_bounds; + layer_tree_impl()->OnLayerBoundsUpdate(id(), layer_bounds); + } +} +#endif // OHOS_VIDEO_ASSISTANT +#if defined(OHOS_CUSTOM_VIDEO_PLAYER) +void SurfaceLayerImpl::OnLayerRectUpdate(gfx::Rect visible_quad_rect) { + visible_quad_rect.set_origin( + ScreenSpaceTransform().MapPoint(visible_quad_rect.origin())); + if (!visible_quad_rect_.ApproximatelyEqual(visible_quad_rect, 1)) { + visible_quad_rect_ = visible_quad_rect; + layer_tree_impl()->OnLayerRectUpdate(id(), visible_quad_rect); + } +} +#endif // OHOS_CUSTOM_VIDEO_PLAYER } // namespace cc diff --git a/cc/layers/surface_layer_impl.h b/cc/layers/surface_layer_impl.h index a701d4d9b7..16a9836738 100644 --- a/cc/layers/surface_layer_impl.h +++ b/cc/layers/surface_layer_impl.h @@ -80,6 +80,13 @@ class CC_EXPORT SurfaceLayerImpl : public LayerImpl { void AsValueInto(base::trace_event::TracedValue* dict) const override; const char* LayerTypeAsString() const override; +#ifdef OHOS_VIDEO_ASSISTANT + void OnLayerBoundsUpdate(gfx::Rect visible_quad_rect); +#endif // OHOS_VIDEO_ASSISTANT +#if defined(OHOS_CUSTOM_VIDEO_PLAYER) + void OnLayerRectUpdate(gfx::Rect visible_quad_rect); +#endif // OHOS_CUSTOM_VIDEO_PLAYER + UpdateSubmissionStateCB update_submission_state_callback_; viz::SurfaceRange surface_range_; absl::optional deadline_in_frames_; @@ -93,6 +100,9 @@ class CC_EXPORT SurfaceLayerImpl : public LayerImpl { #if defined(OHOS_CUSTOM_VIDEO_PLAYER) gfx::Rect visible_quad_rect_; #endif // OHOS_CUSTOM_VIDEO_PLAYER +#ifdef OHOS_VIDEO_ASSISTANT + gfx::Rect layer_bounds_; +#endif // OHOS_VIDEO_ASSISTANT }; } // namespace cc diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index 41f4edb80f..fe89bba72f 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -2087,4 +2087,13 @@ void LayerTreeHost::OnLayerRectVisibilityChange(int id, bool visibility) { } #endif +#ifdef OHOS_VIDEO_ASSISTANT +void LayerTreeHost::OnLayerBoundsUpdate(int id, const gfx::Rect& bounds) { + DCHECK(IsMainThread()); + if (auto* layer = LayerById(id)) { + layer->OnLayerBoundsUpdate(bounds); + } +} +#endif // OHOS_VIDEO_ASSISTANT + } // namespace cc diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h index 48bb5eb965..ec047140ce 100644 --- a/cc/trees/layer_tree_host.h +++ b/cc/trees/layer_tree_host.h @@ -919,6 +919,10 @@ void RegisterClippedVisualViewportSelectionBounds( void OnLayerRectVisibilityChange(int id, bool visibility); #endif +#ifdef OHOS_VIDEO_ASSISTANT + void OnLayerBoundsUpdate(int id, const gfx::Rect& bounds); +#endif // OHOS_VIDEO_ASSISTANT + protected: LayerTreeHost(InitParams params, CompositorMode mode); diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 5efa45b349..4b385efd9f 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -5428,6 +5428,12 @@ void LayerTreeHostImpl::OnLayerRectVisibilityChange(int id, bool visibility) { } #endif +#ifdef OHOS_VIDEO_ASSISTANT +void LayerTreeHostImpl::OnLayerBoundsUpdate(int id, const gfx::Rect& bounds) { + client_->OnLayerBoundsUpdate(id, bounds); +} +#endif // OHOS_VIDEO_ASSISTANT + #ifdef OHOS_NWEB_EX void LayerTreeHostImpl::SetupScrollBy() { if (!input_delegate_) { diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index 83a0e8835a..5fe60aa66e 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -194,6 +194,9 @@ class LayerTreeHostImplClient { virtual void OnLayerRectVisibilityChange(int id, bool visibility) {} #endif +#ifdef OHOS_VIDEO_ASSISTANT + virtual void OnLayerBoundsUpdate(int id, const gfx::Rect& bounds) {} +#endif // OHOS_VIDEO_ASSISTANT protected: virtual ~LayerTreeHostImplClient() = default; @@ -940,6 +943,9 @@ class CC_EXPORT LayerTreeHostImpl : public TileManagerClient, void OnLayerRectVisibilityChange(int id, bool visibility); #endif +#ifdef OHOS_VIDEO_ASSISTANT + void OnLayerBoundsUpdate(int id, const gfx::Rect& bounds); +#endif // OHOS_VIDEO_ASSISTANT void SetDownsampleMetricsForTesting(bool value) { downsample_metrics_ = value; diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc index f30a205cc6..4a1ad71234 100644 --- a/cc/trees/layer_tree_impl.cc +++ b/cc/trees/layer_tree_impl.cc @@ -3031,4 +3031,9 @@ void LayerTreeImpl::OnLayerRectVisibilityChange(int id, bool visibility) { } #endif +#ifdef OHOS_VIDEO_ASSISTANT +void LayerTreeImpl::OnLayerBoundsUpdate(int id, const gfx::Rect& bounds) { + host_impl_->OnLayerBoundsUpdate(id, bounds); +} +#endif // OHOS_VIDEO_ASSISTANT } // namespace cc diff --git a/cc/trees/layer_tree_impl.h b/cc/trees/layer_tree_impl.h index f6c6986927..ee10e2ab10 100644 --- a/cc/trees/layer_tree_impl.h +++ b/cc/trees/layer_tree_impl.h @@ -177,6 +177,10 @@ class CC_EXPORT LayerTreeImpl { void OnLayerRectVisibilityChange(int id, bool visibility); #endif +#ifdef OHOS_VIDEO_ASSISTANT + void OnLayerBoundsUpdate(int id, const gfx::Rect& bounds); +#endif // OHOS_VIDEO_ASSISTANT + // Tree specific methods exposed to layer-impl tree. // --------------------------------------------------------------------------- void SetNeedsRedraw(); diff --git a/cc/trees/proxy_impl.cc b/cc/trees/proxy_impl.cc index 5c88a238f4..6679cf3cda 100644 --- a/cc/trees/proxy_impl.cc +++ b/cc/trees/proxy_impl.cc @@ -1114,4 +1114,13 @@ void ProxyImpl::OnLayerRectVisibilityChange(int id, bool visibility) { proxy_main_weak_ptr_, id, visibility)); } #endif + +#ifdef OHOS_VIDEO_ASSISTANT +void ProxyImpl::OnLayerBoundsUpdate(int id, const gfx::Rect& bounds) { + DCHECK(IsImplThread()); + MainThreadTaskRunner()->PostTask( + FROM_HERE, base::BindOnce(&ProxyMain::OnLayerBoundsUpdate, + proxy_main_weak_ptr_, id, bounds)); +} +#endif // OHOS_VIDEO_ASSISTANT } // namespace cc diff --git a/cc/trees/proxy_impl.h b/cc/trees/proxy_impl.h index a0e894c3a3..5c892cb73f 100644 --- a/cc/trees/proxy_impl.h +++ b/cc/trees/proxy_impl.h @@ -100,6 +100,9 @@ class CC_EXPORT ProxyImpl : public LayerTreeHostImplClient, void OnLayerRectVisibilityChange(int id, bool visibility) override; #endif +#ifdef OHOS_VIDEO_ASSISTANT + void OnLayerBoundsUpdate(int id, const gfx::Rect& bounds) override; +#endif // OHOS_VIDEO_ASSISTANT private: // LayerTreeHostImplClient implementation diff --git a/cc/trees/proxy_main.cc b/cc/trees/proxy_main.cc index bda4accdc4..7f48b7524c 100644 --- a/cc/trees/proxy_main.cc +++ b/cc/trees/proxy_main.cc @@ -906,4 +906,9 @@ void ProxyMain::OnLayerRectVisibilityChange(int id, bool visibility) { } #endif +#ifdef OHOS_VIDEO_ASSISTANT +void ProxyMain::OnLayerBoundsUpdate(int id, const gfx::Rect& bounds) { + layer_tree_host_->OnLayerBoundsUpdate(id, bounds); +} +#endif // OHOS_VIDEO_ASSISTANT } // namespace cc diff --git a/cc/trees/proxy_main.h b/cc/trees/proxy_main.h index 32a41eda4e..4539ba086a 100644 --- a/cc/trees/proxy_main.h +++ b/cc/trees/proxy_main.h @@ -91,6 +91,9 @@ class CC_EXPORT ProxyMain : public Proxy { void OnLayerRectVisibilityChange(int id, bool visibility); #endif +#ifdef OHOS_VIDEO_ASSISTANT + void OnLayerBoundsUpdate(int id, const gfx::Rect& bounds); +#endif // OHOS_VIDEO_ASSISTANT private: // Proxy implementation. diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn index b26c54a3c4..40e4b8e8d6 100644 --- a/content/browser/BUILD.gn +++ b/content/browser/BUILD.gn @@ -2546,6 +2546,23 @@ source_set("browser") { deps += [ "//third_party:huawei_securec" ] } + #ifdef OHOS_VIDEO_ASSISTANT + if (defined(ohos_video_assistant) && ohos_video_assistant) { + sources += [ + "media/video_assistant/video_assistant.cc", + "media/video_assistant/video_assistant.h", + ] + + if (is_ohos) { + if (defined(ohos_nweb_ex) && ohos_nweb_ex) { + deps += [ + "//ohos_nweb_ex/overrides/ui/strings", + ] + } + } + } + #endif OHOS_VIDEO_ASSISTANT + if (is_mac) { sources += [ "../app_shim_remote_cocoa/ns_view_bridge_factory_impl.mm", diff --git a/content/browser/media/media_web_contents_observer.cc b/content/browser/media/media_web_contents_observer.cc index 0f66810d8c..5a4df5187a 100644 --- a/content/browser/media/media_web_contents_observer.cc +++ b/content/browser/media/media_web_contents_observer.cc @@ -643,6 +643,10 @@ void MediaWebContentsObserver::OnMediaPlayerObserverDisconnected( const MediaPlayerId& player_id) { DCHECK(media_player_observer_hosts_.contains(player_id)); media_player_observer_hosts_.erase(player_id); + +#ifdef OHOS_VIDEO_ASSISTANT + web_contents_impl()->OnVideoDestroyed(player_id); +#endif // OHOS_VIDEO_ASSISTANT } device::mojom::WakeLock* MediaWebContentsObserver::GetAudioWakeLock() { @@ -826,4 +830,40 @@ void MediaWebContentsObserver::RequestDownloadUrl( } #endif // defined(OHOS_VIDEO_ASSISTANT) +#ifdef OHOS_VIDEO_ASSISTANT +void MediaWebContentsObserver::MediaPlayerHostImpl:: + RequestVideoAssistantConfig( + RequestVideoAssistantConfigCallback callback) { + LOG(INFO) << "RequestVideoAssistantConfig"; + auto config = media::mojom::VideoAssistantConfig::New(true, true, + media::mojom::VideoAssistantDownloadButton::kDownloadPerPage); + auto* web_contents_impl = media_web_contents_observer_->web_contents_impl(); + web_contents_impl->PopluateVideoAssistantConfig(config); + std::move(callback).Run(std::move(config)); +} + +void MediaWebContentsObserver::MediaPlayerObserverHostImpl:: + OnVideoPlaying( + media::mojom::VideoAttributesForVASTPtr video_attributes) { + LOG(INFO) << "OnVideoPlaying"; + media_web_contents_observer_->web_contents_impl()->OnVideoPlaying( + std::move(video_attributes), media_player_id_); +} + +void MediaWebContentsObserver::MediaPlayerObserverHostImpl:: + OnUpdateVideoAttributes( + media::mojom::VideoAttributesForVASTPtr video_attributes) { + LOG(INFO) << "OnUpdateVideoAttributes"; + media_web_contents_observer_->web_contents_impl()->OnUpdateVideoAttributes( + std::move(video_attributes), media_player_id_); +} + +void MediaWebContentsObserver::MediaPlayerObserverHostImpl:: + OnVideoDestroyed() { + LOG(INFO) << "OnVideoDestroyed"; + media_web_contents_observer_->web_contents_impl()->OnVideoDestroyed( + media_player_id_); +} +#endif // OHOS_VIDEO_ASSISTANT + } // namespace content diff --git a/content/browser/media/media_web_contents_observer.h b/content/browser/media/media_web_contents_observer.h index 8d222d49b4..3d1ff01ab0 100644 --- a/content/browser/media/media_web_contents_observer.h +++ b/content/browser/media/media_web_contents_observer.h @@ -193,6 +193,10 @@ class CONTENT_EXPORT MediaWebContentsObserver mojo::PendingAssociatedReceiver media_player_observer, int32_t player_id) override; +#ifdef OHOS_VIDEO_ASSISTANT + void RequestVideoAssistantConfig( + RequestVideoAssistantConfigCallback callback) override; +#endif // OHOS_VIDEO_ASSISTANT private: GlobalRenderFrameHostId frame_routing_id_; @@ -243,6 +247,14 @@ class CONTENT_EXPORT MediaWebContentsObserver void FullscreenChanged(bool is_fullscreen) override; #endif // OHOS_CUSTOM_VIDEO_PLAYER +#ifdef OHOS_VIDEO_ASSISTANT + void OnVideoPlaying( + media::mojom::VideoAttributesForVASTPtr video_attributes) override; + void OnUpdateVideoAttributes( + media::mojom::VideoAttributesForVASTPtr video_attributes) override; + void OnVideoDestroyed() override; +#endif // OHOS_VIDEO_ASSISTANT + private: PlayerInfo* GetPlayerInfo(); void NotifyAudioStreamMonitorIfNeeded(); diff --git a/content/browser/media/video_assistant/video_assistant.cc b/content/browser/media/video_assistant/video_assistant.cc new file mode 100644 index 0000000000..4ce4c38bc2 --- /dev/null +++ b/content/browser/media/video_assistant/video_assistant.cc @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "content/browser/media/video_assistant/video_assistant.h" + +#include "media/mojo/mojom/media_player.mojom.h" + +namespace content { + +VideoAssistant::VideoAssistant() = default; +VideoAssistant::~VideoAssistant() = default; + +void VideoAssistant::EnableVideoAssistant(bool enable) {} +void VideoAssistant::ExecuteVideoAssistantFunction(const std::string& cmd_id) {} + +bool VideoAssistant::Enabled() { return false; } +void VideoAssistant::DidFinishNavigation() {} +void VideoAssistant::UpdateVideoAssistantConfig( + const media::mojom::VideoAssistantConfigPtr& config) {} + +void VideoAssistant::OnVideoPlaying( + media::mojom::VideoAttributesForVASTPtr video_attributes, + const MediaPlayerId& id) {} +void VideoAssistant::OnUpdateVideoAttributes( + media::mojom::VideoAttributesForVASTPtr video_attributes, + const MediaPlayerId& id) {} +void VideoAssistant::OnVideoDestroyed(const MediaPlayerId& id) {} + +} // namespace diff --git a/content/browser/media/video_assistant/video_assistant.h b/content/browser/media/video_assistant/video_assistant.h new file mode 100644 index 0000000000..aa2cecbced --- /dev/null +++ b/content/browser/media/video_assistant/video_assistant.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CONTENT_BROWSER_MEDIA_VIDEO_ASSISTANT_VIDEO_ASSISTANT_H_ +#define CONTENT_BROWSER_MEDIA_VIDEO_ASSISTANT_VIDEO_ASSISTANT_H_ + +#include + +#include "content/public/browser/media_player_id.h" +#include "media/mojo/mojom/media_player.mojom-forward.h" + +namespace content { + +class VideoAssistant { + public: + VideoAssistant(); + virtual ~VideoAssistant(); + + virtual void EnableVideoAssistant(bool enable); + virtual void ExecuteVideoAssistantFunction(const std::string& cmd_id); + + virtual bool Enabled(); + virtual void DidFinishNavigation(); + virtual void UpdateVideoAssistantConfig( + const media::mojom::VideoAssistantConfigPtr& config); + + virtual void OnVideoPlaying( + media::mojom::VideoAttributesForVASTPtr video_attributes, + const MediaPlayerId& id); + virtual void OnUpdateVideoAttributes( + media::mojom::VideoAttributesForVASTPtr video_attributes, + const MediaPlayerId& id); + virtual void OnVideoDestroyed(const MediaPlayerId& id); +}; + +} // namespace + +#endif // CONTENT_BROWSER_MEDIA_VIDEO_ASSISTANT_VIDEO_ASSISTANT_H_ diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index ec1f20552d..340a575c94 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -247,6 +247,10 @@ #include "base/ohos/locale_utils.h" #endif +#ifdef OHOS_VIDEO_ASSISTANT +#include "content/browser/media/video_assistant/video_assistant.h" +#endif // OHOS_VIDEO_ASSISTANT + namespace content { namespace { @@ -1109,6 +1113,10 @@ WebContentsImpl::WebContentsImpl(BrowserContext* browser_context) star_scan_load_observer_ = std::make_unique(this); } #endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && BUILDFLAG(USE_STARSCAN) + +#ifdef OHOS_VIDEO_ASSISTANT + video_assistant_ = std::make_unique(); +#endif // OHOS_VIDEO_ASSISTANT } WebContentsImpl::~WebContentsImpl() { @@ -1444,6 +1452,15 @@ void WebContentsImpl::SetDelegate(WebContentsDelegate* delegate) { // Re-read values from the new delegate and apply them. if (view_) view_->SetOverscrollControllerEnabled(CanOverscrollContent()); + +#ifdef OHOS_VIDEO_ASSISTANT + if (delegate_) { + video_assistant_ = delegate_->CreateVideoAssistant(); + } + if (!video_assistant_) { + video_assistant_ = std::make_unique(); + } +#endif // OHOS_VIDEO_ASSISTANT } RenderFrameHostImpl* WebContentsImpl::GetPrimaryMainFrame() { @@ -3156,6 +3173,12 @@ const blink::web_pref::WebPreferences WebContentsImpl::ComputeWebPreferences() { #endif GetContentClient()->browser()->OverrideWebkitPrefs(this, &prefs); +#ifdef OHOS_VIDEO_ASSISTANT + prefs.video_assistant_enabled = video_assistant_ + ? video_assistant_->Enabled() + : false; +#endif // OHOS_VIDEO_ASSISTANT + return prefs; } @@ -6279,6 +6302,11 @@ void WebContentsImpl::DidFinishNavigation(NavigationHandle* navigation_handle) { if (navigation_handle->IsInPrimaryMainFrame() && !navigation_handle->IsSameDocument()) { was_ever_audible_ = false; +#ifdef OHOS_VIDEO_ASSISTANT + if (video_assistant_) { + video_assistant_->DidFinishNavigation(); + } +#endif // OHOS_VIDEO_ASSISTANT } // Clear the stored prerender activation result if this is not a prerender @@ -9611,6 +9639,12 @@ void WebContentsImpl::MediaEffectivelyFullscreenChanged(bool is_fullscreen) { void WebContentsImpl::MediaDestroyed(const MediaPlayerId& id) { OPTIONAL_TRACE_EVENT0("content", "WebContentsImpl::MediaDestroyed"); observers_.NotifyObservers(&WebContentsObserver::MediaDestroyed, id); + +#ifdef OHOS_VIDEO_ASSISTANT + if (video_assistant_) { + video_assistant_->OnVideoDestroyed(id); + } +#endif // OHOS_VIDEO_ASSISTANT } int WebContentsImpl::GetCurrentlyPlayingVideoCount() { @@ -10619,9 +10653,17 @@ void WebContentsImpl::RequestExitFullscreen(const MediaPlayerId& player_id) { #endif // OHOS_CUSTOM_VIDEO_PLAYER #if defined(OHOS_VIDEO_ASSISTANT) -void WebContentsImpl::EnableVideoAssistant(bool enable) {} +void WebContentsImpl::EnableVideoAssistant(bool enable) { + if (video_assistant_->Enabled() == enable) { + return; + } + video_assistant_->EnableVideoAssistant(enable); + OnWebPreferencesChanged(); +} -void WebContentsImpl::ExecuteVideoAssistantFunction(const std::string& cmdId) {} +void WebContentsImpl::ExecuteVideoAssistantFunction(const std::string& cmdId) { + video_assistant_->ExecuteVideoAssistantFunction(cmdId); +} void WebContentsImpl::OnShowToast(double duration, const std::string& toast) { if (!delegate_) { @@ -10692,4 +10734,31 @@ void WebContentsImpl::OnBeforeUnloadFired(bool proceed) { } #endif // OHOS_DISPATCH_BEFORE_UNLOAD +#ifdef OHOS_VIDEO_ASSISTANT +void WebContentsImpl::PopluateVideoAssistantConfig( + media::mojom::VideoAssistantConfigPtr& config) { + if (delegate_) { + delegate_->PopluateVideoAssistantConfig( + GetLastCommittedURL().DeprecatedGetOriginAsURL().spec(), config); + video_assistant_->UpdateVideoAssistantConfig(config); + } +} + +void WebContentsImpl::OnVideoPlaying( + media::mojom::VideoAttributesForVASTPtr video_attributes, + const MediaPlayerId& id) { + video_assistant_->OnVideoPlaying(std::move(video_attributes), id); +} + +void WebContentsImpl::OnUpdateVideoAttributes( + media::mojom::VideoAttributesForVASTPtr video_attributes, + const MediaPlayerId& id) { + video_assistant_->OnUpdateVideoAttributes(std::move(video_attributes), id); +} + +void WebContentsImpl::OnVideoDestroyed(const MediaPlayerId& id) { + video_assistant_->OnVideoDestroyed(id); +} +#endif // OHOS_VIDEO_ASSISTANT + } // namespace content diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h index 51038d2a82..1e22f4e655 100644 --- a/content/browser/web_contents/web_contents_impl.h +++ b/content/browser/web_contents/web_contents_impl.h @@ -188,6 +188,10 @@ class PepperPlaybackObserver; class CustomMediaPlayerListener; #endif // OHOS_CUSTOM_VIDEO_PLAYER +#ifdef OHOS_VIDEO_ASSISTANT +class VideoAssistant; +#endif // OHOS_VIDEO_ASSISTANT + // CreatedWindow holds the WebContentsImpl and target url between IPC calls to // CreateNewWindow and ShowCreatedWindow. struct CONTENT_EXPORT CreatedWindow { @@ -1588,6 +1592,18 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents, void OnBeforeUnloadFired(bool proceed) override; #endif // OHOS_DISPATCH_BEFORE_UNLOAD +#ifdef OHOS_VIDEO_ASSISTANT + void PopluateVideoAssistantConfig( + media::mojom::VideoAssistantConfigPtr& config); + void OnVideoPlaying( + media::mojom::VideoAttributesForVASTPtr video_attributes, + const MediaPlayerId& id); + void OnUpdateVideoAttributes( + media::mojom::VideoAttributesForVASTPtr video_attributes, + const MediaPlayerId& id); + void OnVideoDestroyed(const MediaPlayerId& id); +#endif // OHOS_VIDEO_ASSISTANT + private: using FrameTreeIterationCallback = base::RepeatingCallback; using RenderViewHostIterationCallback = @@ -2676,6 +2692,10 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents, #if defined(OHOS_CUSTOM_VIDEO_PLAYER) std::map players_; #endif // OHOS_CUSTOM_VIDEO_PLAYER + +#ifdef OHOS_VIDEO_ASSISTANT + std::unique_ptr video_assistant_; +#endif // OHOS_VIDEO_ASSISTANT }; // Dangerous methods which should never be made part of the public API, so we diff --git a/content/public/browser/web_contents_delegate.cc b/content/public/browser/web_contents_delegate.cc index 2141c3c40c..92890135db 100644 --- a/content/public/browser/web_contents_delegate.cc +++ b/content/public/browser/web_contents_delegate.cc @@ -23,6 +23,10 @@ #include "third_party/blink/public/common/security/protocol_handler_security_level.h" #include "third_party/blink/public/mojom/mediastream/media_stream.mojom.h" #include "ui/gfx/geometry/rect.h" +#ifdef OHOS_VIDEO_ASSISTANT +#include "content/browser/media/video_assistant/video_assistant.h" +#include "media/mojo/mojom/media_player.mojom.h" +#endif // OHOS_VIDEO_ASSISTANT namespace content { @@ -420,4 +424,17 @@ void WebContentsDelegate::OnShowVideoAssistant( void WebContentsDelegate::OnReportStatisticLog(const std::string& content) {} #endif // defined(OHOS_VIDEO_ASSISTANT) +#ifdef OHOS_VIDEO_ASSISTANT +std::unique_ptr WebContentsDelegate::CreateVideoAssistant() { + return std::make_unique(); +} +void WebContentsDelegate::PopluateVideoAssistantConfig( + const std::string& url, + media::mojom::VideoAssistantConfigPtr& config) {} +void WebContentsDelegate::OnVideoPlaying( + media::mojom::VideoAttributesForVASTPtr video_attributes) {} +void WebContentsDelegate::OnUpdateVideoAttributes( + media::mojom::VideoAttributesForVASTPtr video_attributes) {} +#endif // OHOS_VIDEO_ASSISTANT + } // namespace content diff --git a/content/public/browser/web_contents_delegate.h b/content/public/browser/web_contents_delegate.h index 72abcda03c..0f7851700e 100644 --- a/content/public/browser/web_contents_delegate.h +++ b/content/public/browser/web_contents_delegate.h @@ -46,6 +46,10 @@ #include "content/public/browser/native_embed_info.h" #endif +#ifdef OHOS_VIDEO_ASSISTANT +#include "media/mojo/mojom/media_player.mojom-forward.h" +#endif // OHOS_VIDEO_ASSISTANT + class GURL; namespace base { @@ -84,6 +88,9 @@ class CustomMediaPlayerListener; struct MediaInfo; #endif // OHOS_CUSTOM_VIDEO_PLAYER +#ifdef OHOS_VIDEO_ASSISTANT +class VideoAssistant; +#endif // OHOS_VIDEO_ASSISTANT } // namespace content namespace device { @@ -840,6 +847,15 @@ class CONTENT_EXPORT WebContentsDelegate { #endif // OHOS_CUSTOM_VIDEO_PLAYER #if defined(OHOS_VIDEO_ASSISTANT) + virtual std::unique_ptr CreateVideoAssistant(); + virtual void PopluateVideoAssistantConfig( + const std::string& url, + media::mojom::VideoAssistantConfigPtr& config); + virtual void OnVideoPlaying( + media::mojom::VideoAttributesForVASTPtr video_attributes); + virtual void OnUpdateVideoAttributes( + media::mojom::VideoAttributesForVASTPtr video_attributes); + virtual void OnShowToast(double duration, const std::string& toast); virtual void OnShowVideoAssistant(const std::string& videoAssistantItems); virtual void OnReportStatisticLog(const std::string& content); diff --git a/media/mojo/mojom/media_player.mojom b/media/mojo/mojom/media_player.mojom index c240feaa45..6ea04ec5df 100644 --- a/media/mojo/mojom/media_player.mojom +++ b/media/mojo/mojom/media_player.mojom @@ -9,6 +9,33 @@ import "mojo/public/mojom/base/time.mojom"; import "services/media_session/public/mojom/media_session.mojom"; import "ui/gfx/geometry/mojom/geometry.mojom"; +[EnableIf=ohos_video_assistant] +enum VideoAssistantDownloadButton { + kDownloadPerPage, + kDownloadForceShow, + kDownloadForceHide, +}; + +[EnableIf=ohos_video_assistant] +struct VideoAssistantConfig { + bool video_assistant; + bool playback_rate; + VideoAssistantDownloadButton download_button; +}; + +[EnableIf=ohos_video_assistant] +struct VideoAttributesForVAST { + bool show_fullscreen_button; + bool show_download_button; + bool show_playback_rate_menu; + double current_playback_rate; + gfx.mojom.RectF rect; + + bool supports_save; + double duration; + bool visible; +}; + // Implemented by HTMLMediaElement in the renderer process to allow the // browser to control media playback. interface MediaPlayer { @@ -140,6 +167,15 @@ interface MediaPlayerObserver { [EnableIf=ohos_custom_video_player] FullscreenChanged(bool is_fullscreen); + + [EnableIf=ohos_video_assistant] + OnVideoPlaying(VideoAttributesForVAST video_attributes); + + [EnableIf=ohos_video_assistant] + OnUpdateVideoAttributes(VideoAttributesForVAST video_attributes); + + [EnableIf=ohos_video_assistant] + OnVideoDestroyed(); }; // Implemented by MediaWebContentsObserver::MediaPlayerHostImpl in the browser @@ -154,4 +190,8 @@ interface MediaPlayerHost { OnMediaPlayerAdded(pending_associated_remote player_remote, pending_associated_receiver observer, int32 player_id); + + [EnableIf=ohos_video_assistant] + RequestVideoAssistantConfig() => (VideoAssistantConfig config); + }; diff --git a/ohos_build/build/config/ohos.json b/ohos_build/build/config/ohos.json old mode 100644 new mode 100755 index fa968d1c84..d4498b9258 --- a/ohos_build/build/config/ohos.json +++ b/ohos_build/build/config/ohos.json @@ -18,8 +18,8 @@ }, { "name": "OHOS_API_PER", - "owner": "", - "desc": "", + "owner": "", + "desc": "", "effect": "main gn blink_core other", "genCommandline": "default", "dependence": "", @@ -124,6 +124,15 @@ "dependence": "", "default": "true" }, +{ + "name": "OHOS_CLOUD_CONTROL", + "owner": "", + "desc": "", + "effect": "main gn blink_core other", + "genCommandline": "default", + "dependence": "", + "default": "true" +}, { "name": "OHOS_COMPOSITE_RENDER", "owner": "", @@ -250,15 +259,6 @@ "dependence": "", "default": "true" }, -{ - "name": "OHOS_DISPATCH_BEFORE_UNLOAD", - "owner": "", - "desc": "", - "effect":"main gn blink_core other", - "genCommandline": "default", - "dependence": "", - "default": "true" -}, { "name": "OHOS_DISPLAY_CUTOUT", "owner": "", @@ -341,26 +341,26 @@ "default": "true" }, { - "name": "OHOS_EX_NETWORK_CONNECTION", + "name": "OHOS_EX_NAVIGATION", "owner": "", - "desc": "", + "desc": "Navigation list op", "effect": "main gn blink_core other", "genCommandline": "default", "dependence": "", "default": "true" }, { - "name": "OHOS_EX_REFRESH_IFRAME", + "name": "OHOS_EX_NETWORK_CONNECTION", "owner": "", "desc": "", - "effect":"main gn blink_core other", + "effect": "main gn blink_core other", "genCommandline": "default", "dependence": "", "default": "true" }, { - "name": "OHOS_EX_SCREEN_CAPTURE", - "owner": "", + "name": "OHOS_EX_NET_EXPORT", + "owner": "xuxiaoli", "desc": "", "effect": "main gn blink_core other", "genCommandline": "default", @@ -521,8 +521,8 @@ "default": "true" }, { - "name": "OHOS_LOG_MESSAGE", - "owner": "gaojianhao", + "name": "OHOS_MEDIA", + "owner": "", "desc": "", "effect": "main gn blink_core other", "genCommandline": "default", @@ -530,7 +530,7 @@ "default": "true" }, { - "name": "OHOS_MEDIA", + "name": "OHOS_MEDIA_AVSESSION", "owner": "", "desc": "", "effect": "main gn blink_core other", @@ -539,7 +539,7 @@ "default": "true" }, { - "name": "OHOS_MEDIA_AVSESSION", + "name": "OHOS_MEDIA_CAPABILITIES_ENHANCE", "owner": "", "desc": "", "effect": "main gn blink_core other", @@ -556,6 +556,15 @@ "dependence": "", "default": "true" }, +{ + "name": "OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT", + "owner": "", + "desc": "", + "effect": "main gn blink_core other", + "genCommandline": "default", + "dependence": "", + "default": "true" +}, { "name": "OHOS_MEDIA_PER", "owner": "", @@ -601,6 +610,15 @@ "dependence": "", "default": "true" }, +{ + "name": "OHOS_MULTI_IP_CONNECT", + "owner": "", + "desc": "support multi ip sockets connect", + "effect": "main gn blink_core other", + "genCommandline": "default", + "dependence": "", + "default": "true" +}, { "name": "OHOS_MULTI_WINDOW", "owner": "", @@ -907,6 +925,15 @@ "dependence": "", "default": "true" }, +{ + "name": "OHOS_THEME_FONT", + "owner": "", + "desc": "", + "effect": "main gn blink_core other", + "genCommandline": "", + "dependence": "", + "default": "true" +}, { "name": "OHOS_UNITTESTS", "owner": "", @@ -1014,4 +1041,4 @@ "genCommandline": "default", "dependence": "", "default": "true" -} +} \ No newline at end of file diff --git a/ohos_nweb/src/cef_delegate/nweb_delegate.cc b/ohos_nweb/src/cef_delegate/nweb_delegate.cc index 318715fe41..c553b0efc6 100644 --- a/ohos_nweb/src/cef_delegate/nweb_delegate.cc +++ b/ohos_nweb/src/cef_delegate/nweb_delegate.cc @@ -4283,7 +4283,11 @@ void NWebDelegate::RegisterOnCreateNativeMediaPlayerListener( #if defined(OHOS_VIDEO_ASSISTANT) void NWebDelegate::EnableVideoAssistant(bool enable) { if (GetBrowser() == nullptr || GetBrowser()->GetHost() == nullptr) { - LOG(ERROR) << "failed to get host when enable video assistant"; + if (!handler_delegate_) { + LOG(ERROR) << "failed to enable video assistant, handler delegate is null"; + return; + } + handler_delegate_->EnableVideoAssistant(enable); return; } diff --git a/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc b/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc index 99db6089c1..801a500e31 100644 --- a/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc +++ b/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc @@ -892,6 +892,16 @@ void NWebHandlerDelegate::OnAfterCreated(CefRefPtr browser) { } } #endif + +#if defined(OHOS_VIDEO_ASSISTANT) + if (video_assistant_enabled_) { + if (main_browser_ && main_browser_->GetHost()) { + main_browser_->GetHost()->EnableVideoAssistant( + *video_assistant_enabled_); + } + } +#endif // OHOS_VIDEO_ASSISTANT + return; } #endif // defined(OHOS_MULTI_WINDOW) @@ -911,6 +921,15 @@ void NWebHandlerDelegate::OnAfterCreated(CefRefPtr browser) { } else { LOG(ERROR) << "Failed to set browser to settings delegate"; } + +#if defined(OHOS_VIDEO_ASSISTANT) + if (video_assistant_enabled_) { + if (main_browser_ && main_browser_->GetHost()) { + main_browser_->GetHost()->EnableVideoAssistant( + *video_assistant_enabled_); + } + } +#endif // OHOS_VIDEO_ASSISTANT } bool NWebHandlerDelegate::DoClose(CefRefPtr browser) { @@ -3964,4 +3983,10 @@ void NWebHandlerDelegate::OnBeforeUnloadFired(CefRefPtr browser, } #endif // OHOS_DISPATCH_BEFORE_UNLOAD +#if defined(OHOS_VIDEO_ASSISTANT) +void NWebHandlerDelegate::EnableVideoAssistant(bool enable) { + video_assistant_enabled_ = enable; +} +#endif // OHOS_VIDEO_ASSISTANT + } // namespace OHOS::NWeb diff --git a/ohos_nweb/src/cef_delegate/nweb_handler_delegate.h b/ohos_nweb/src/cef_delegate/nweb_handler_delegate.h index 1a8cea71b1..253154ef1e 100644 --- a/ohos_nweb/src/cef_delegate/nweb_handler_delegate.h +++ b/ohos_nweb/src/cef_delegate/nweb_handler_delegate.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include "capi/nweb_app_client_extension_callback.h" @@ -790,6 +791,10 @@ void OnTouchIconUrlWithSizesReceived( void OnBeforeUnloadFired(CefRefPtr browser, bool proceed) override; #endif // OHOS_DISPATCH_BEFORE_UNLOAD + +#if defined(OHOS_VIDEO_ASSISTANT) + void EnableVideoAssistant(bool enable); +#endif // OHOS_VIDEO_ASSISTANT private: enum class JsRunTime { Start = 0, @@ -920,6 +925,9 @@ void OnTouchIconUrlWithSizesReceived( #ifdef OHOS_ARKWEB_ADBLOCK bool is_global_adblock_enabled_ = false; #endif +#if defined(OHOS_VIDEO_ASSISTANT) + std::optional video_assistant_enabled_; +#endif // OHOS_VIDEO_ASSISTANT base::WeakPtrFactory weak_factory_{this}; }; diff --git a/ohos_nweb/src/nweb_impl.cc b/ohos_nweb/src/nweb_impl.cc index 010a7cdd2e..ce10b31abb 100644 --- a/ohos_nweb/src/nweb_impl.cc +++ b/ohos_nweb/src/nweb_impl.cc @@ -96,6 +96,10 @@ #include "ohos_nweb_ex/overrides/cef/libcef/browser/alloy/alloy_browser_ua_config.h" #endif +#if defined(OHOS_NWEB_EX) && defined(OHOS_VIDEO_ASSISTANT) +#include "ohos_nweb_ex/overrides/cef/libcef/browser/alloy/alloy_browser_engine_cloud_config.h" +#endif + #ifdef OHOS_EX_GET_ZOOM_LEVEL #include "third_party/blink/public/common/page/page_zoom.h" #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" @@ -2618,6 +2622,15 @@ void NWebImpl::SetBrowserUA(const std::string& ua_name) { } #endif // OHOS_EX_UA +#if defined(OHOS_VIDEO_ASSISTANT) +// static +void NWebImpl::UpdateBrowserEngineConfig(const std::string& file_path, const std::string& version) { +#if defined(OHOS_NWEB_EX) + nweb_ex::AlloyBrowserEngineCloudConfig::GetInstance()->UpdateBrowserEngineCloudConfig(file_path, version); +#endif +} +#endif + #if defined(OHOS_I18N) void NWebImpl::UpdateAcceptLanguageInternal() { const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); diff --git a/ohos_nweb/src/nweb_impl.h b/ohos_nweb/src/nweb_impl.h index b6437ccf3a..6d3e03ee9d 100644 --- a/ohos_nweb/src/nweb_impl.h +++ b/ohos_nweb/src/nweb_impl.h @@ -456,6 +456,10 @@ class NWebImpl : public NWeb { static void SetBrowserUA(const std::string& ua_name); #endif // OHOS_EX_UA +#if defined(OHOS_VIDEO_ASSISTANT) + static void UpdateBrowserEngineConfig(const std::string& file_path, const std::string& version); +#endif + #if defined(OHOS_EX_FORCE_ZOOM) void SetForceEnableZoom(bool forceEnableZoom) const; bool GetForceEnableZoom() const; -- Gitee