| Index: content/browser/media/android/video_surface_manager_impl.cc
|
| diff --git a/content/browser/media/android/video_surface_manager_impl.cc b/content/browser/media/android/video_surface_manager_impl.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..355c0d02c802b4c63bf10dd881c2837d29df1e98
|
| --- /dev/null
|
| +++ b/content/browser/media/android/video_surface_manager_impl.cc
|
| @@ -0,0 +1,67 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "content/browser/media/android/video_surface_manager_impl.h"
|
| +
|
| +#include "content/browser/android/content_video_view.h"
|
| +#include "content/browser/web_contents/web_contents_impl.h"
|
| +#include "content/public/browser/web_contents_delegate.h"
|
| +
|
| +namespace content {
|
| +
|
| +static base::LazyInstance<VideoSurfaceManagerImpl>::Leaky g_surface_manager =
|
| + LAZY_INSTANCE_INITIALIZER;
|
| +
|
| +// static
|
| +VideoSurfaceManager* VideoSurfaceManager::GetInstance() {
|
| + return VideoSurfaceManagerImpl::GetInstance();
|
| +}
|
| +
|
| +// static
|
| +VideoSurfaceManagerImpl* VideoSurfaceManagerImpl::GetInstance() {
|
| + return g_surface_manager.Pointer();
|
| +}
|
| +
|
| +VideoSurfaceManagerImpl::VideoSurfaceManagerImpl() {}
|
| +
|
| +VideoSurfaceManagerImpl::~VideoSurfaceManagerImpl() {}
|
| +
|
| +void VideoSurfaceManagerImpl::SetOverrideVideoSurfaceProvider(
|
| + VideoSurfaceProvider* provider) {
|
| + // Make sure current provider isn't already set (it shouldn't be because
|
| + // entering vr (which would set an override) requires pausing chrome (which
|
| + // should exit fullscreen and remove any existing cvv instances).
|
| + // TODO(amp): Handle switching surface providers when/if VR changes to not
|
| + // exit full screen on transition.
|
| +
|
| + // I have no idea if this is an appropriate way to handle pointers params.
|
| + current_provider_.reset(provider);
|
| +}
|
| +
|
| +void VideoSurfaceManagerImpl::RemoveOverrideVideoSurfaceProvider(
|
| + VideoSurfaceProvider* provider) {
|
| + // Make sure the current provider is actually the passed in provider
|
| + current_provider_.reset();
|
| +}
|
| +
|
| +VideoSurfaceProvider* VideoSurfaceManagerImpl::GetVideoSurfaceProvider(
|
| + WebContents* web_contents) {
|
| +
|
| + if (!current_provider_) {
|
| + // If we don't own the fullscreen view, but one exists, it means another
|
| + // WebContents has it. Ignore the request and return a null surface
|
| + // provider.
|
| + if (ContentVideoView::GetInstance()) {
|
| + return nullptr;
|
| + }
|
| +
|
| + ContentViewCore* cvc = ContentViewCore::FromWebContents(web_contents);
|
| + current_provider_.reset(new ContentVideoView(
|
| + cvc, web_contents->GetDelegate()->GetContentVideoViewEmbedder()));
|
| + }
|
| + // Also for returning pointers, is this ok, or should it be something else?
|
| + return current_provider_.get();
|
| +}
|
| +
|
| +} // namespace content
|
|
|