| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/media/android/video_surface_manager_impl.h" |
| 6 |
| 7 #include "content/browser/android/content_video_view.h" |
| 8 #include "content/browser/web_contents/web_contents_impl.h" |
| 9 #include "content/public/browser/web_contents_delegate.h" |
| 10 |
| 11 namespace content { |
| 12 |
| 13 static base::LazyInstance<VideoSurfaceManagerImpl>::Leaky g_surface_manager = |
| 14 LAZY_INSTANCE_INITIALIZER; |
| 15 |
| 16 // static |
| 17 VideoSurfaceManager* VideoSurfaceManager::GetInstance() { |
| 18 return VideoSurfaceManagerImpl::GetInstance(); |
| 19 } |
| 20 |
| 21 // static |
| 22 VideoSurfaceManagerImpl* VideoSurfaceManagerImpl::GetInstance() { |
| 23 return g_surface_manager.Pointer(); |
| 24 } |
| 25 |
| 26 VideoSurfaceManagerImpl::VideoSurfaceManagerImpl() {} |
| 27 |
| 28 VideoSurfaceManagerImpl::~VideoSurfaceManagerImpl() {} |
| 29 |
| 30 void VideoSurfaceManagerImpl::SetOverrideVideoSurfaceProvider( |
| 31 VideoSurfaceProvider* provider) { |
| 32 // Make sure current provider isn't already set (it shouldn't be because |
| 33 // entering vr (which would set an override) requires pausing chrome (which |
| 34 // should exit fullscreen and remove any existing cvv instances). |
| 35 // TODO(amp): Handle switching surface providers when/if VR changes to not |
| 36 // exit full screen on transition. |
| 37 |
| 38 // I have no idea if this is an appropriate way to handle pointers params. |
| 39 current_provider_.reset(provider); |
| 40 } |
| 41 |
| 42 void VideoSurfaceManagerImpl::RemoveOverrideVideoSurfaceProvider( |
| 43 VideoSurfaceProvider* provider) { |
| 44 // Make sure the current provider is actually the passed in provider |
| 45 current_provider_.reset(); |
| 46 } |
| 47 |
| 48 VideoSurfaceProvider* VideoSurfaceManagerImpl::GetVideoSurfaceProvider( |
| 49 WebContents* web_contents) { |
| 50 |
| 51 if (!current_provider_) { |
| 52 // If we don't own the fullscreen view, but one exists, it means another |
| 53 // WebContents has it. Ignore the request and return a null surface |
| 54 // provider. |
| 55 if (ContentVideoView::GetInstance()) { |
| 56 return nullptr; |
| 57 } |
| 58 |
| 59 ContentViewCore* cvc = ContentViewCore::FromWebContents(web_contents); |
| 60 current_provider_.reset(new ContentVideoView( |
| 61 cvc, web_contents->GetDelegate()->GetContentVideoViewEmbedder())); |
| 62 } |
| 63 // Also for returning pointers, is this ok, or should it be something else? |
| 64 return current_provider_.get(); |
| 65 } |
| 66 |
| 67 } // namespace content |
| OLD | NEW |