summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--android_webview/browser/aw_content_browser_client.cc8
-rw-r--r--android_webview/browser/aw_content_browser_client.h5
-rw-r--r--android_webview/browser/jni_dependency_factory.h5
-rw-r--r--android_webview/lib/main/aw_main_delegate.cc9
-rw-r--r--android_webview/lib/main/aw_main_delegate.h6
-rw-r--r--android_webview/native/external_video_surface_container_impl.cc21
-rw-r--r--android_webview/native/external_video_surface_container_impl.h4
-rw-r--r--content/browser/android/content_view_core_impl.cc7
-rw-r--r--content/browser/media/android/browser_media_player_manager.cc47
-rw-r--r--content/browser/media/android/browser_media_player_manager.h17
-rw-r--r--content/browser/renderer_host/render_widget_host_view_android.cc33
-rw-r--r--content/public/browser/android/external_video_surface_container.h9
-rw-r--r--content/public/browser/content_browser_client.cc8
-rw-r--r--content/public/browser/content_browser_client.h8
14 files changed, 112 insertions, 75 deletions
diff --git a/android_webview/browser/aw_content_browser_client.cc b/android_webview/browser/aw_content_browser_client.cc
index b1edcfd..778e466 100644
--- a/android_webview/browser/aw_content_browser_client.cc
+++ b/android_webview/browser/aw_content_browser_client.cc
@@ -501,4 +501,12 @@ void AwContentBrowserClient::OverrideWebkitPrefs(content::RenderViewHost* rvh,
content::WebContents::FromRenderViewHost(rvh), web_prefs);
}
+#if defined(VIDEO_HOLE)
+content::ExternalVideoSurfaceContainer*
+AwContentBrowserClient::OverrideCreateExternalVideoSurfaceContainer(
+ content::WebContents* web_contents) {
+ return native_factory_->CreateExternalVideoSurfaceContainer(web_contents);
+}
+#endif
+
} // namespace android_webview
diff --git a/android_webview/browser/aw_content_browser_client.h b/android_webview/browser/aw_content_browser_client.h
index 28dc4d0..adae583 100644
--- a/android_webview/browser/aw_content_browser_client.h
+++ b/android_webview/browser/aw_content_browser_client.h
@@ -164,6 +164,11 @@ class AwContentBrowserClient : public content::ContentBrowserClient {
virtual void OverrideWebkitPrefs(content::RenderViewHost* rvh,
const GURL& url,
WebPreferences* web_prefs) OVERRIDE;
+#if defined(VIDEO_HOLE)
+ virtual content::ExternalVideoSurfaceContainer*
+ OverrideCreateExternalVideoSurfaceContainer(
+ content::WebContents* web_contents) OVERRIDE;
+#endif
private:
// Android WebView currently has a single global (non-off-the-record) browser
diff --git a/android_webview/browser/jni_dependency_factory.h b/android_webview/browser/jni_dependency_factory.h
index b396ad0..d0b6f72 100644
--- a/android_webview/browser/jni_dependency_factory.h
+++ b/android_webview/browser/jni_dependency_factory.h
@@ -8,6 +8,7 @@
#include "base/memory/ref_counted.h"
namespace content {
+class ExternalVideoSurfaceContainer;
class GeolocationPermissionContext;
class WebContents;
class WebContentsViewDelegate;
@@ -31,6 +32,10 @@ class JniDependencyFactory {
virtual content::WebContentsViewDelegate* CreateViewDelegate(
content::WebContents* web_contents) = 0;
virtual AwWebPreferencesPopulater* CreateWebPreferencesPopulater() = 0;
+#if defined(VIDEO_HOLE)
+ virtual content::ExternalVideoSurfaceContainer*
+ CreateExternalVideoSurfaceContainer(content::WebContents* contents) = 0;
+#endif
};
} // namespace android_webview
diff --git a/android_webview/lib/main/aw_main_delegate.cc b/android_webview/lib/main/aw_main_delegate.cc
index 7440b09..a9f6bf6 100644
--- a/android_webview/lib/main/aw_main_delegate.cc
+++ b/android_webview/lib/main/aw_main_delegate.cc
@@ -13,6 +13,7 @@
#include "android_webview/native/aw_quota_manager_bridge_impl.h"
#include "android_webview/native/aw_web_contents_view_delegate.h"
#include "android_webview/native/aw_web_preferences_populater_impl.h"
+#include "android_webview/native/external_video_surface_container_impl.h"
#include "android_webview/renderer/aw_content_renderer_client.h"
#include "base/command_line.h"
#include "base/lazy_instance.h"
@@ -147,4 +148,12 @@ AwWebPreferencesPopulater* AwMainDelegate::CreateWebPreferencesPopulater() {
return new AwWebPreferencesPopulaterImpl();
}
+#if defined(VIDEO_HOLE)
+content::ExternalVideoSurfaceContainer*
+AwMainDelegate::CreateExternalVideoSurfaceContainer(
+ content::WebContents* web_contents) {
+ return new ExternalVideoSurfaceContainerImpl(web_contents);
+}
+#endif
+
} // namespace android_webview
diff --git a/android_webview/lib/main/aw_main_delegate.h b/android_webview/lib/main/aw_main_delegate.h
index 2d07be4..93a116c 100644
--- a/android_webview/lib/main/aw_main_delegate.h
+++ b/android_webview/lib/main/aw_main_delegate.h
@@ -13,6 +13,7 @@
namespace content {
class BrowserMainRunner;
+class ExternalVideoSurfaceContainel;
}
namespace android_webview {
@@ -49,6 +50,11 @@ class AwMainDelegate : public content::ContentMainDelegate,
virtual content::WebContentsViewDelegate* CreateViewDelegate(
content::WebContents* web_contents) OVERRIDE;
virtual AwWebPreferencesPopulater* CreateWebPreferencesPopulater() OVERRIDE;
+#if defined(VIDEO_HOLE)
+ virtual content::ExternalVideoSurfaceContainer*
+ CreateExternalVideoSurfaceContainer(
+ content::WebContents* web_contents) OVERRIDE;
+#endif
scoped_ptr<content::BrowserMainRunner> browser_runner_;
AwContentClient content_client_;
diff --git a/android_webview/native/external_video_surface_container_impl.cc b/android_webview/native/external_video_surface_container_impl.cc
index 351b3ca..ca9ed34 100644
--- a/android_webview/native/external_video_surface_container_impl.cc
+++ b/android_webview/native/external_video_surface_container_impl.cc
@@ -9,30 +9,9 @@
#include "jni/ExternalVideoSurfaceContainer_jni.h"
#include "ui/gfx/rect_f.h"
-using android_webview::ExternalVideoSurfaceContainerImpl;
using base::android::AttachCurrentThread;
using content::ContentViewCore;
-DEFINE_WEB_CONTENTS_USER_DATA_KEY(ExternalVideoSurfaceContainerImpl);
-
-namespace content {
-
-// static
-void ExternalVideoSurfaceContainer::CreateForWebContents(
- WebContents* web_contents) {
- WebContentsUserData<ExternalVideoSurfaceContainerImpl>::CreateForWebContents(
- web_contents);
-}
-
-// static
-ExternalVideoSurfaceContainer* ExternalVideoSurfaceContainer::FromWebContents(
- WebContents* web_contents) {
- return WebContentsUserData<ExternalVideoSurfaceContainerImpl>::
- FromWebContents(web_contents);
-}
-
-} // namespace content
-
namespace android_webview {
ExternalVideoSurfaceContainerImpl::ExternalVideoSurfaceContainerImpl(
diff --git a/android_webview/native/external_video_surface_container_impl.h b/android_webview/native/external_video_surface_container_impl.h
index c5d9f07..4d34f83 100644
--- a/android_webview/native/external_video_surface_container_impl.h
+++ b/android_webview/native/external_video_surface_container_impl.h
@@ -11,13 +11,11 @@
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "content/public/browser/android/external_video_surface_container.h"
-#include "content/public/browser/web_contents_user_data.h"
namespace android_webview {
class ExternalVideoSurfaceContainerImpl
- : public content::ExternalVideoSurfaceContainer,
- public content::WebContentsUserData<ExternalVideoSurfaceContainerImpl> {
+ : public content::ExternalVideoSurfaceContainer {
public:
typedef base::Callback<void(int, jobject)> SurfaceCreatedCB;
typedef base::Callback<void(int)> SurfaceDestroyedCB;
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
index 2369f6f..d6d0591 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -38,7 +38,6 @@
#include "content/common/input/web_input_event_traits.h"
#include "content/common/input_messages.h"
#include "content/common/view_messages.h"
-#include "content/public/browser/android/external_video_surface_container.h"
#include "content/public/browser/browser_accessibility_state.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/favicon_status.h"
@@ -485,12 +484,6 @@ void ContentViewCoreImpl::UpdateFrameInfo(
controls_offset.y(),
content_offset.y(),
overdraw_bottom_height);
-#if defined(VIDEO_HOLE)
- ExternalVideoSurfaceContainer* surface_container =
- ExternalVideoSurfaceContainer::FromWebContents(web_contents_);
- if (surface_container)
- surface_container->OnFrameInfoUpdated();
-#endif // defined(VIDEO_HOLE)
}
void ContentViewCoreImpl::SetTitle(const base::string16& title) {
diff --git a/content/browser/media/android/browser_media_player_manager.cc b/content/browser/media/android/browser_media_player_manager.cc
index e53cfa09a..61b8b98 100644
--- a/content/browser/media/android/browser_media_player_manager.cc
+++ b/content/browser/media/android/browser_media_player_manager.cc
@@ -15,6 +15,7 @@
#include "content/public/browser/android/content_view_core.h"
#include "content/public/browser/android/external_video_surface_container.h"
#include "content/public/browser/browser_context.h"
+#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/storage_partition.h"
@@ -437,28 +438,42 @@ void BrowserMediaPlayerManager::DetachExternalVideoSurface(int player_id) {
player->SetVideoSurface(gfx::ScopedJavaSurface());
}
+void BrowserMediaPlayerManager::OnFrameInfoUpdated() {
+ if (external_video_surface_container_)
+ external_video_surface_container_->OnFrameInfoUpdated();
+}
+
void BrowserMediaPlayerManager::OnNotifyExternalSurface(
int player_id, bool is_request, const gfx::RectF& rect) {
if (!web_contents_)
return;
- ExternalVideoSurfaceContainer::CreateForWebContents(web_contents_);
- ExternalVideoSurfaceContainer* surface_container =
- ExternalVideoSurfaceContainer::FromWebContents(web_contents_);
- if (!surface_container)
- return;
-
if (is_request) {
- // It's safe to use base::Unretained(this), because the callbacks will not
- // be called after running ReleaseExternalVideoSurface().
- surface_container->RequestExternalVideoSurface(
+ OnRequestExternalSurface(player_id, rect);
+ }
+ if (external_video_surface_container_) {
+ external_video_surface_container_->OnExternalVideoSurfacePositionChanged(
+ player_id, rect);
+ }
+}
+
+void BrowserMediaPlayerManager::OnRequestExternalSurface(
+ int player_id, const gfx::RectF& rect) {
+ if (!external_video_surface_container_) {
+ ContentBrowserClient* client = GetContentClient()->browser();
+ external_video_surface_container_.reset(
+ client->OverrideCreateExternalVideoSurfaceContainer(web_contents_));
+ }
+ // It's safe to use base::Unretained(this), because the callbacks will not
+ // be called after running ReleaseExternalVideoSurface().
+ if (external_video_surface_container_) {
+ external_video_surface_container_->RequestExternalVideoSurface(
player_id,
base::Bind(&BrowserMediaPlayerManager::AttachExternalVideoSurface,
base::Unretained(this)),
base::Bind(&BrowserMediaPlayerManager::DetachExternalVideoSurface,
base::Unretained(this)));
}
- surface_container->OnExternalVideoSurfacePositionChanged(player_id, rect);
}
#endif // defined(VIDEO_HOLE)
@@ -484,10 +499,8 @@ void BrowserMediaPlayerManager::OnEnterFullscreen(int player_id) {
}
#if defined(VIDEO_HOLE)
- ExternalVideoSurfaceContainer* surface_container =
- ExternalVideoSurfaceContainer::FromWebContents(web_contents_);
- if (surface_container)
- surface_container->ReleaseExternalVideoSurface(player_id);
+ if (external_video_surface_container_)
+ external_video_surface_container_->ReleaseExternalVideoSurface(player_id);
#endif // defined(VIDEO_HOLE)
if (video_view_.get()) {
fullscreen_player_id_ = player_id;
@@ -873,10 +886,8 @@ void BrowserMediaPlayerManager::OnMediaResourcesReleased(int player_id) {
MediaPlayerAndroid* player = GetPlayer(player_id);
if (player && player->IsSurfaceInUse())
return;
- ExternalVideoSurfaceContainer* surface_container =
- ExternalVideoSurfaceContainer::FromWebContents(web_contents_);
- if (surface_container)
- surface_container->ReleaseExternalVideoSurface(player_id);
+ if (external_video_surface_container_)
+ external_video_surface_container_->ReleaseExternalVideoSurface(player_id);
#endif // defined(VIDEO_HOLE)
}
diff --git a/content/browser/media/android/browser_media_player_manager.h b/content/browser/media/android/browser_media_player_manager.h
index 8fa1b17..902ec47 100644
--- a/content/browser/media/android/browser_media_player_manager.h
+++ b/content/browser/media/android/browser_media_player_manager.h
@@ -31,6 +31,7 @@ class MediaDrmBridge;
namespace content {
class BrowserDemuxerAndroid;
class ContentViewCoreImpl;
+class ExternalVideoSurfaceContainer;
class WebContents;
// This class manages all the MediaPlayerAndroid objects. It receives
@@ -108,6 +109,7 @@ class CONTENT_EXPORT BrowserMediaPlayerManager
#if defined(VIDEO_HOLE)
void AttachExternalVideoSurface(int player_id, jobject surface);
void DetachExternalVideoSurface(int player_id);
+ void OnFrameInfoUpdated();
#endif // defined(VIDEO_HOLE)
// Called to disble the current fullscreen playback if the video is encrypted.
@@ -152,11 +154,6 @@ class CONTENT_EXPORT BrowserMediaPlayerManager
// Cancels all pending session creations associated with |cdm_id|.
void CancelAllPendingSessionCreations(int cdm_id);
-#if defined(VIDEO_HOLE)
- virtual void OnNotifyExternalSurface(
- int player_id, bool is_request, const gfx::RectF& rect);
-#endif // defined(VIDEO_HOLE)
-
// Adds a given player to the list.
void AddPlayer(media::MediaPlayerAndroid* player);
@@ -213,6 +210,12 @@ class CONTENT_EXPORT BrowserMediaPlayerManager
// releasing all the decoding resources.
virtual void OnMediaResourcesReleased(int player_id);
+#if defined(VIDEO_HOLE)
+ void OnNotifyExternalSurface(
+ int player_id, bool is_request, const gfx::RectF& rect);
+ void OnRequestExternalSurface(int player_id, const gfx::RectF& rect);
+#endif // defined(VIDEO_HOLE)
+
// An array of managed players.
ScopedVector<media::MediaPlayerAndroid> players_;
@@ -230,6 +233,10 @@ class CONTENT_EXPORT BrowserMediaPlayerManager
// fullscreen.
scoped_ptr<ContentVideoView> video_view_;
+#if defined(VIDEO_HOLE)
+ scoped_ptr<ExternalVideoSurfaceContainer> external_video_surface_container_;
+#endif
+
// Player ID of the fullscreen media player.
int fullscreen_player_id_;
diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc
index de2ac4b..0f14c99b 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -35,11 +35,13 @@
#include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/gpu/gpu_process_host_ui_shim.h"
#include "content/browser/gpu/gpu_surface_tracker.h"
+#include "content/browser/media/android/browser_media_player_manager.h"
#include "content/browser/renderer_host/compositor_impl_android.h"
#include "content/browser/renderer_host/dip_util.h"
#include "content/browser/renderer_host/image_transport_factory_android.h"
#include "content/browser/renderer_host/input/synthetic_gesture_target_android.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
+#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/common/gpu/client/gl_helper.h"
#include "content/common/gpu/gpu_messages.h"
@@ -936,19 +938,26 @@ void RenderWidgetHostViewAndroid::SynchronousCopyContents(
void RenderWidgetHostViewAndroid::UpdateContentViewCoreFrameMetadata(
const cc::CompositorFrameMetadata& frame_metadata) {
- if (content_view_core_) {
- // All offsets and sizes are in CSS pixels.
- content_view_core_->UpdateFrameInfo(
- frame_metadata.root_scroll_offset,
- frame_metadata.page_scale_factor,
- gfx::Vector2dF(frame_metadata.min_page_scale_factor,
- frame_metadata.max_page_scale_factor),
- frame_metadata.root_layer_size,
- frame_metadata.viewport_size,
- frame_metadata.location_bar_offset,
- frame_metadata.location_bar_content_translation,
- frame_metadata.overdraw_bottom_height);
+ if (!content_view_core_)
+ return;
+ // All offsets and sizes are in CSS pixels.
+ content_view_core_->UpdateFrameInfo(
+ frame_metadata.root_scroll_offset,
+ frame_metadata.page_scale_factor,
+ gfx::Vector2dF(frame_metadata.min_page_scale_factor,
+ frame_metadata.max_page_scale_factor),
+ frame_metadata.root_layer_size,
+ frame_metadata.viewport_size,
+ frame_metadata.location_bar_offset,
+ frame_metadata.location_bar_content_translation,
+ frame_metadata.overdraw_bottom_height);
+#if defined(VIDEO_HOLE)
+ if (host_ && host_->IsRenderView()) {
+ RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(
+ RenderViewHost::From(host_));
+ rvhi->media_player_manager()->OnFrameInfoUpdated();
}
+#endif // defined(VIDEO_HOLE)
}
void RenderWidgetHostViewAndroid::AcceleratedSurfaceInitialized(int host_id,
diff --git a/content/public/browser/android/external_video_surface_container.h b/content/public/browser/android/external_video_surface_container.h
index 1b630e1..38cbe59 100644
--- a/content/public/browser/android/external_video_surface_container.h
+++ b/content/public/browser/android/external_video_surface_container.h
@@ -23,14 +23,6 @@ class CONTENT_EXPORT ExternalVideoSurfaceContainer {
typedef base::Callback<void(int, jobject)> SurfaceCreatedCB;
typedef base::Callback<void(int)> SurfaceDestroyedCB;
- // Creates an ExternalVideoSurfaceContainer, and attaches it to the given
- // WebContents. If an instance is already attached, does nothing.
- static void CreateForWebContents(WebContents* contents);
-
- // Returns the existing ExternalVideoSurfaceContainer attached to the given
- // WebContents or NULL.
- static ExternalVideoSurfaceContainer* FromWebContents(WebContents* contents);
-
// Called when a media player wants to request an external video surface.
// Whenever the surface is created and visible, |surface_created_cb| will be
// called. And whenever it is destroyed or invisible, |surface_destroyed_cb|
@@ -52,7 +44,6 @@ class CONTENT_EXPORT ExternalVideoSurfaceContainer {
// Called when the page that contains the video element is scrolled or zoomed.
virtual void OnFrameInfoUpdated() = 0;
- protected:
virtual ~ExternalVideoSurfaceContainer() {}
};
diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc
index be0d5f0..ba80b8f 100644
--- a/content/public/browser/content_browser_client.cc
+++ b/content/public/browser/content_browser_client.cc
@@ -310,4 +310,12 @@ net::CookieStore* ContentBrowserClient::OverrideCookieStoreForRenderProcess(
return NULL;
}
+#if defined(VIDEO_HOLE)
+ExternalVideoSurfaceContainer*
+ContentBrowserClient::OverrideCreateExternalVideoSurfaceContainer(
+ WebContents* web_contents) {
+ return NULL;
+}
+#endif
+
} // namespace content
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
index 022fba2..3abafe5 100644
--- a/content/public/browser/content_browser_client.h
+++ b/content/public/browser/content_browser_client.h
@@ -87,6 +87,7 @@ class BrowserMainParts;
class BrowserPluginGuestDelegate;
class BrowserPpapiHost;
class BrowserURLHandler;
+class ExternalVideoSurfaceContainer;
class LocationProvider;
class MediaObserver;
class QuotaPermissionContext;
@@ -640,6 +641,13 @@ class CONTENT_EXPORT ContentBrowserClient {
// This is called on the IO thread.
virtual net::CookieStore* OverrideCookieStoreForRenderProcess(
int render_process_id_);
+
+#if defined(VIDEO_HOLE)
+ // Allows an embedder to provide its own ExternalVideoSurfaceContainer
+ // implementation. Return NULL to disable external surface video.
+ virtual ExternalVideoSurfaceContainer*
+ OverrideCreateExternalVideoSurfaceContainer(WebContents* web_contents);
+#endif
};
} // namespace content