summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-18 21:40:36 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-18 21:40:36 +0000
commitec9212f3e7399920c6c50b8943549b995192c5cf (patch)
tree2f0ebe96ba5c4ec29457ea4f68aa702dc7a99afa /webkit
parentf08f95e9d8e6f36be7162c77acefc834764209e1 (diff)
downloadchromium_src-ec9212f3e7399920c6c50b8943549b995192c5cf.zip
chromium_src-ec9212f3e7399920c6c50b8943549b995192c5cf.tar.gz
chromium_src-ec9212f3e7399920c6c50b8943549b995192c5cf.tar.bz2
Bridge out media player from MediaPlayerPrivate.
- Remove MediaPlayerPrivateChromium.cpp and move it to webkit/glue/media_player_private_impl.cc - Added the following classes: WebMediaPlayer WebMediaPlayerImpl WebMediaPlayerDelegate WebMediaPlayerDelegateImpl TestWebMediaPlayerDelegate VideoStackMediaPlayer (Just a forward declaration) - One include fix for webkit/glue/webframe.h - Overview of what each class is doing: WebMediaPlayer and WebMediaPlayerImpl Wrapper over the MediaPlayerPrivate, it provides methods like Repaint(), NotifyNetworkStateChange(), etc to VideoStackMediaPlayer. It also creates the ResourceHandle for VideoStackMediaPlayer for resource loading, or maybe VideoStackMediaPlayer can simply use webkit_glue::ResourceDispatcher? WebMediaPlayerDelegate, WebMediaPlayerDelegateImpl Delegate calls from webkit to the internal media player. MediaPlayerPrivate Forward calls to WebMidiaPlayerDelegate, creates WebMediaPlayerDelegate and WebMediaPlayer in the constructor. Expose some public methods to WebMediaPlayer so we can actually do repaint and notification of changes. Review URL: http://codereview.chromium.org/13762 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7256 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/build/WebCore/SConscript1
-rw-r--r--webkit/build/glue/glue.vcproj20
-rw-r--r--webkit/build/port/port.vcproj4
-rw-r--r--webkit/glue/SConscript2
-rw-r--r--webkit/glue/media_player_private_impl.cc301
-rw-r--r--webkit/glue/webframe.h1
-rw-r--r--webkit/glue/webkit_glue.h4
-rw-r--r--webkit/glue/webmediaplayer.h63
-rw-r--r--webkit/glue/webmediaplayer_delegate.h80
-rw-r--r--webkit/glue/webmediaplayer_impl.cc61
-rw-r--r--webkit/glue/webmediaplayer_impl.h60
-rw-r--r--webkit/glue/webview_delegate.h14
-rw-r--r--webkit/port/platform/graphics/chromium/MediaPlayerPrivateChromium.h25
-rw-r--r--webkit/tools/test_shell/test_shell.cc5
-rw-r--r--webkit/tools/test_shell/test_shell_switches.cc3
-rw-r--r--webkit/tools/test_shell/test_shell_switches.h1
16 files changed, 630 insertions, 15 deletions
diff --git a/webkit/build/WebCore/SConscript b/webkit/build/WebCore/SConscript
index 4f9a1ef3..fdab0a5 100644
--- a/webkit/build/WebCore/SConscript
+++ b/webkit/build/WebCore/SConscript
@@ -438,7 +438,6 @@ input_files = [
'$WEBCORE_DIR/platform/graphics/Image.cpp',
'$WEBCORE_DIR/platform/graphics/IntRect.cpp',
'$WEBCORE_DIR/platform/graphics/MediaPlayer.cpp',
- '$PORT_DIR/platform/graphics/chromium/MediaPlayerPrivateChromium.cpp',
'$WEBCORE_DIR/platform/graphics/Path.cpp',
'$WEBCORE_DIR/platform/graphics/PathTraversalState.cpp',
'$WEBCORE_DIR/platform/graphics/Pattern.cpp',
diff --git a/webkit/build/glue/glue.vcproj b/webkit/build/glue/glue.vcproj
index b391a24..26901a7 100644
--- a/webkit/build/glue/glue.vcproj
+++ b/webkit/build/glue/glue.vcproj
@@ -193,6 +193,14 @@
>
</File>
<File
+ RelativePath="..\..\glue\webmediaplayer.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\glue\webmediaplayer_delegate.h"
+ >
+ </File>
+ <File
RelativePath="..\..\glue\webplugin.h"
>
</File>
@@ -441,6 +449,10 @@
>
</File>
<File
+ RelativePath="..\..\glue\media_player_private_impl.cc"
+ >
+ </File>
+ <File
RelativePath="..\..\glue\multipart_response_delegate.cc"
>
</File>
@@ -601,6 +613,14 @@
>
</File>
<File
+ RelativePath="..\..\glue\webmediaplayer_impl.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\glue\webmediaplayer_impl.h"
+ >
+ </File>
+ <File
RelativePath="..\..\glue\webplugin_impl.cc"
>
</File>
diff --git a/webkit/build/port/port.vcproj b/webkit/build/port/port.vcproj
index 14f8499..b388f20 100644
--- a/webkit/build/port/port.vcproj
+++ b/webkit/build/port/port.vcproj
@@ -1143,10 +1143,6 @@
>
</File>
<File
- RelativePath="..\..\port\platform\graphics\chromium\MediaPlayerPrivateChromium.cpp"
- >
- </File>
- <File
RelativePath="..\..\port\platform\graphics\chromium\MediaPlayerPrivateChromium.h"
>
</File>
diff --git a/webkit/glue/SConscript b/webkit/glue/SConscript
index e613d0b..68e16bd 100644
--- a/webkit/glue/SConscript
+++ b/webkit/glue/SConscript
@@ -50,6 +50,7 @@ input_files = [
'image_resource_fetcher.cc',
'inspector_client_impl.cc',
'localized_strings.cc',
+ 'media_player_private_impl.cc',
'multipart_response_delegate.cc',
'npruntime_util.cc',
'password_autocomplete_listener.cc',
@@ -72,6 +73,7 @@ input_files = [
'webframeloaderclient_impl.cc',
'webhistoryitem_impl.cc',
'webkit_glue.cc',
+ 'webmediaplayer_impl.cc',
'webplugin_impl.cc',
'webtextinput_impl.cc',
'weburlrequest_impl.cc',
diff --git a/webkit/glue/media_player_private_impl.cc b/webkit/glue/media_player_private_impl.cc
new file mode 100644
index 0000000..2112507
--- /dev/null
+++ b/webkit/glue/media_player_private_impl.cc
@@ -0,0 +1,301 @@
+// Copyright (c) 2006-2008 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 "config.h"
+
+#if ENABLE(VIDEO)
+
+#include "GraphicsContext.h"
+#include "IntRect.h"
+#include "MediaPlayerPrivateChromium.h"
+#include "PlatformContextSkia.h"
+#undef LOG
+
+#include "googleurl/src/gurl.h"
+#include "webkit/glue/glue_util.h"
+#include "webkit/glue/webframe.h"
+#include "webkit/glue/webkit_glue.h"
+#include "webkit/glue/webmediaplayer.h"
+#include "webkit/glue/webmediaplayer_impl.h"
+#include "webkit/glue/webmediaplayer_delegate.h"
+#include "webkit/glue/webview.h"
+#include "webkit/glue/webview_delegate.h"
+
+namespace WebCore {
+
+// We can't create the delegate here because m_player->frameView is null at
+// this moment. Although we can static_cast the MediaPlayerClient to
+// HTMLElement and get the frame from there, but creating the delegate from
+// load() seems to be a better idea.
+MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player)
+ : m_player(player),
+ m_delegate(NULL) {
+}
+
+MediaPlayerPrivate::~MediaPlayerPrivate() {
+ // Delete the delegate, it should delete the associated WebMediaPlayer.
+ delete m_delegate;
+}
+
+void MediaPlayerPrivate::load(const String& url) {
+ // Delete the delegate if it already exists. Because we may be in a different
+ // view since last load. WebMediaPlayer uses the view internally when
+ // using ResourceHandle, WebMediaPlayerDelegate contains the actual media
+ // player, in order to hook the actual media player with ResourceHandle in
+ // WebMediaPlayer given the new view, we destroy the old
+ // WebMediaPlayerDelegate and WebMediaPlayer and create a new set of both.
+ delete m_delegate;
+ m_delegate = NULL;
+
+ webkit_glue::WebMediaPlayer* media_player =
+ new webkit_glue::WebMediaPlayerImpl(this);
+ WebViewDelegate* d = media_player->GetWebFrame()->GetView()->GetDelegate();
+
+ m_delegate = d->CreateMediaPlayerDelegate();
+ // In case we couldn't create a delegate.
+ if (m_delegate) {
+ m_delegate->Initialize(media_player);
+ media_player->Initialize(m_delegate);
+
+ m_delegate->Load(webkit_glue::StringToGURL(url));
+ }
+}
+
+void MediaPlayerPrivate::cancelLoad() {
+ if (m_delegate) {
+ m_delegate->CancelLoad();
+ }
+}
+
+IntSize MediaPlayerPrivate::naturalSize() const {
+ if (m_delegate) {
+ return IntSize(m_delegate->GetWidth(), m_delegate->GetHeight());
+ } else {
+ return IntSize(0, 0);
+ }
+}
+
+bool MediaPlayerPrivate::hasVideo() const {
+ if (m_delegate) {
+ return m_delegate->IsVideo();
+ } else {
+ return false;
+ }
+}
+
+void MediaPlayerPrivate::play() {
+ if (m_delegate) {
+ m_delegate->Play();
+ }
+}
+
+void MediaPlayerPrivate::pause() {
+ if (m_delegate) {
+ m_delegate->Pause();
+ }
+}
+
+bool MediaPlayerPrivate::paused() const {
+ if (m_delegate) {
+ return m_delegate->IsPaused();
+ } else {
+ return true;
+ }
+}
+
+bool MediaPlayerPrivate::seeking() const {
+ if (m_delegate) {
+ return m_delegate->IsSeeking();
+ } else {
+ return false;
+ }
+}
+
+float MediaPlayerPrivate::duration() const {
+ if (m_delegate) {
+ return m_delegate->GetDuration();
+ } else {
+ return 0.0f;
+ }
+}
+
+float MediaPlayerPrivate::currentTime() const {
+ if (m_delegate) {
+ return m_delegate->GetCurrentTime();
+ } else {
+ return 0.0f;
+ }
+}
+
+void MediaPlayerPrivate::seek(float time) {
+ if (m_delegate) {
+ m_delegate->Seek(time);
+ }
+}
+
+void MediaPlayerPrivate::setEndTime(float time) {
+ if (m_delegate) {
+ m_delegate->SetEndTime(time);
+ }
+}
+
+void MediaPlayerPrivate::setRate(float rate) {
+ if (m_delegate) {
+ m_delegate->SetPlaybackRate(rate);
+ }
+}
+
+void MediaPlayerPrivate::setVolume(float volume) {
+ if (m_delegate) {
+ m_delegate->SetVolume(volume);
+ }
+}
+
+int MediaPlayerPrivate::dataRate() const {
+ if (m_delegate) {
+ return m_delegate->GetDataRate();
+ } else {
+ return 0;
+ }
+}
+
+MediaPlayer::NetworkState MediaPlayerPrivate::networkState() const {
+ if (m_delegate) {
+ switch (m_delegate->GetNetworkState()) {
+ case webkit_glue::WebMediaPlayer::EMPTY:
+ return MediaPlayer::Empty;
+ case webkit_glue::WebMediaPlayer::LOADED:
+ return MediaPlayer::Loaded;
+ case webkit_glue::WebMediaPlayer::LOADING:
+ return MediaPlayer::Loading;
+ case webkit_glue::WebMediaPlayer::LOAD_FAILED:
+ return MediaPlayer::LoadFailed;
+ case webkit_glue::WebMediaPlayer::LOADED_META_DATA:
+ return MediaPlayer::LoadedMetaData;
+ case webkit_glue::WebMediaPlayer::LOADED_FIRST_FRAME:
+ return MediaPlayer::LoadedFirstFrame;
+ default:
+ return MediaPlayer::Empty;
+ }
+ } else {
+ return MediaPlayer::Empty;
+ }
+}
+
+MediaPlayer::ReadyState MediaPlayerPrivate::readyState() const {
+ if (m_delegate) {
+ switch (m_delegate->GetReadyState()) {
+ case webkit_glue::WebMediaPlayer::CAN_PLAY:
+ return MediaPlayer::CanPlay;
+ case webkit_glue::WebMediaPlayer::CAN_PLAY_THROUGH:
+ return MediaPlayer::CanPlayThrough;
+ case webkit_glue::WebMediaPlayer::CAN_SHOW_CURRENT_FRAME:
+ return MediaPlayer::CanShowCurrentFrame;
+ case webkit_glue::WebMediaPlayer::DATA_UNAVAILABLE:
+ return MediaPlayer::DataUnavailable;
+ default:
+ return MediaPlayer::DataUnavailable;
+ }
+ } else {
+ return MediaPlayer::DataUnavailable;
+ }
+}
+
+float MediaPlayerPrivate::maxTimeBuffered() const {
+ if (m_delegate) {
+ return m_delegate->GetMaxTimeBuffered();
+ } else {
+ return 0.0f;
+ }
+}
+
+float MediaPlayerPrivate::maxTimeSeekable() const {
+ if (m_delegate) {
+ return m_delegate->GetMaxTimeSeekable();
+ } else {
+ return 0.0f;
+ }
+}
+
+unsigned MediaPlayerPrivate::bytesLoaded() const {
+ if (m_delegate) {
+ return static_cast<unsigned>(m_delegate->GetBytesLoaded());
+ } else {
+ return 0;
+ }
+}
+
+bool MediaPlayerPrivate::totalBytesKnown() const {
+ if (m_delegate) {
+ return m_delegate->IsTotalBytesKnown();
+ } else {
+ return false;
+ }
+}
+
+unsigned MediaPlayerPrivate::totalBytes() const {
+ if (m_delegate) {
+ return static_cast<unsigned>(m_delegate->GetTotalBytes());
+ } else {
+ return 0;
+ }
+}
+
+void MediaPlayerPrivate::setVisible(bool visible) {
+ if (m_delegate) {
+ m_delegate->SetVisible(visible);
+ }
+}
+
+void MediaPlayerPrivate::setRect(const IntRect& r) {
+ if (m_delegate) {
+ m_delegate->SetRect(gfx::Rect(r.x(), r.y(), r.width(), r.height()));
+ }
+}
+
+void MediaPlayerPrivate::paint(GraphicsContext* p, const IntRect& r) {
+ if (m_delegate) {
+ gfx::Rect rect(r.x(), r.y(), r.width(), r.height());
+ m_delegate->Paint(p->platformContext()->canvas(), rect);
+ }
+}
+
+// Called from WebMediaPlayer -------------------------------------------------
+FrameView* MediaPlayerPrivate::frameView() {
+ return m_player->m_frameView;
+}
+
+void MediaPlayerPrivate::networkStateChanged() {
+ m_player->networkStateChanged();
+}
+
+void MediaPlayerPrivate::readyStateChanged() {
+ m_player->readyStateChanged();
+}
+
+void MediaPlayerPrivate::timeChanged() {
+ m_player->timeChanged();
+}
+
+void MediaPlayerPrivate::volumeChanged() {
+ m_player->volumeChanged();
+}
+
+void MediaPlayerPrivate::repaint() {
+ m_player->repaint();
+}
+
+// public static methods ------------------------------------------------------
+
+void MediaPlayerPrivate::getSupportedTypes(HashSet<String>& types) {
+ // Do nothing for now.
+}
+
+bool MediaPlayerPrivate::isAvailable() {
+ return webkit_glue::IsMediaPlayerAvailable();
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/webkit/glue/webframe.h b/webkit/glue/webframe.h
index f865b0f..60052dc 100644
--- a/webkit/glue/webframe.h
+++ b/webkit/glue/webframe.h
@@ -9,6 +9,7 @@
#include "base/basictypes.h"
#include "base/ref_counted.h"
+#include "base/scoped_ptr.h"
#include "base/gfx/size.h"
#include "skia/ext/bitmap_platform_device.h"
#include "skia/ext/platform_canvas.h"
diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h
index 843c6e7..78ad7ee 100644
--- a/webkit/glue/webkit_glue.h
+++ b/webkit/glue/webkit_glue.h
@@ -127,6 +127,10 @@ bool DecodeImage(const std::string& image_data, SkBitmap* image);
//-----------------------------------------------------------------------------
// Functions implemented by the embedder, called by WebKit:
+// This function is called from WebCore::MediaPlayerPrivate,
+// Returns true if media player is available and can be created.
+bool IsMediaPlayerAvailable();
+
// This function is called to request a prefetch of the DNS resolution for the
// provided hostname.
void PrefetchDns(const std::string& hostname);
diff --git a/webkit/glue/webmediaplayer.h b/webkit/glue/webmediaplayer.h
new file mode 100644
index 0000000..3dfbd31
--- /dev/null
+++ b/webkit/glue/webmediaplayer.h
@@ -0,0 +1,63 @@
+// Copyright (c) 2008 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.
+
+#ifndef WEBKIT_GLUE_WEBMEDIAPLAYER_H_
+#define WEBKIT_GLUE_WEBMEDIAPLAYER_H_
+
+#include "base/basictypes.h"
+
+class WebFrame;
+
+namespace webkit_glue {
+
+class WebMediaPlayerDelegate;
+
+class WebMediaPlayer {
+public:
+ enum NetworkState {
+ EMPTY,
+ LOAD_FAILED,
+ LOADING,
+ LOADED_META_DATA,
+ LOADED_FIRST_FRAME,
+ LOADED
+ };
+
+ enum ReadyState {
+ DATA_UNAVAILABLE,
+ CAN_SHOW_CURRENT_FRAME,
+ CAN_PLAY,
+ CAN_PLAY_THROUGH
+ };
+
+ WebMediaPlayer() {}
+ virtual ~WebMediaPlayer() {}
+
+ virtual void Initialize(WebMediaPlayerDelegate* delegate) = 0;
+
+ // Get the web frame associated with the media player
+ virtual WebFrame* GetWebFrame() = 0;
+
+ // Notify the media player about network state change.
+ virtual void NotifynetworkStateChange() = 0;
+
+ // Notify the media player about ready state change.
+ virtual void NotifyReadyStateChange() = 0;
+
+ // Notify the media player about time change.
+ virtual void NotifyTimeChange() = 0;
+
+ // Notify the media player about volume change.
+ virtual void NotifyVolumeChange() = 0;
+
+ // Tell the media player to repaint itself.
+ virtual void Repaint() = 0;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(WebMediaPlayer);
+};
+
+} // namespace webkit_glue
+
+#endif // ifndef WEBKIT_GLUE_WEBMEDIAPLAYER_H_
diff --git a/webkit/glue/webmediaplayer_delegate.h b/webkit/glue/webmediaplayer_delegate.h
new file mode 100644
index 0000000..ee2d553
--- /dev/null
+++ b/webkit/glue/webmediaplayer_delegate.h
@@ -0,0 +1,80 @@
+// Copyright (c) 2008 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.
+
+#ifndef WEBKIT_GLUE_WEBMEDIAPLAYER_DELEGATE_H_
+#define WEBKIT_GLUE_WEBMEDIAPLAYER_DELEGATE_H_
+
+#include "base/gfx/platform_canvas.h"
+#include "webkit/glue/webmediaplayer.h"
+
+class GURL;
+
+namespace gfx {
+class Rect;
+}
+
+namespace webkit_glue {
+
+class WebMediaPlayerDelegate {
+ public:
+ WebMediaPlayerDelegate() {}
+ virtual ~WebMediaPlayerDelegate() {}
+
+ virtual void Initialize(WebMediaPlayer *web_media_player) = 0;
+
+ virtual void Load(const GURL& url) = 0;
+ virtual void CancelLoad() = 0;
+
+ // Playback controls.
+ virtual void Play() = 0;
+ virtual void Pause() = 0;
+ virtual void Stop() = 0;
+ virtual void Seek(float time) = 0;
+ virtual void SetEndTime(float time) = 0;
+ virtual void SetPlaybackRate(float rate) = 0;
+ virtual void SetVolume(float volume) = 0;
+ virtual void SetVisible(bool visible) = 0;
+ virtual bool IsTotalBytesKnown() = 0;
+ virtual float GetMaxTimeBuffered() const = 0;
+ virtual float GetMaxTimeSeekable() const = 0;
+
+ // Methods for painting.
+ virtual void SetRect(const gfx::Rect& rect) = 0;
+
+ // TODO(hclam): Using paint at the moment, maybe we just need to return a
+ // SkiaBitmap?
+ virtual void Paint(skia::PlatformCanvas *canvas, const gfx::Rect& rect) = 0;
+
+ // True if a video is loaded.
+ virtual bool IsVideo() const = 0;
+
+ // Dimension of the video.
+ virtual size_t GetWidth() const = 0;
+ virtual size_t GetHeight() const = 0;
+
+ // Getters fo playback state.
+ virtual bool IsPaused() const = 0;
+ virtual bool IsSeeking() const = 0;
+ virtual float GetDuration() const = 0;
+ virtual float GetCurrentTime() const = 0;
+ virtual float GetPlayBackRate() const = 0;
+ virtual float GetVolume() const = 0;
+
+ // Get rate of loading the resource.
+ virtual int32 GetDataRate() const = 0;
+
+ // Internal states of loading and network.
+ virtual WebMediaPlayer::NetworkState GetNetworkState() const = 0;
+ virtual WebMediaPlayer::ReadyState GetReadyState() const = 0;
+
+ virtual int64 GetBytesLoaded() const = 0;
+ virtual int64 GetTotalBytes() const = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerDelegate);
+};
+
+} // namespace webkit_glue
+
+#endif // ifndef WEBKIT_GLUE_WEBMEDIAPLAYER_DELEGATE_H_
diff --git a/webkit/glue/webmediaplayer_impl.cc b/webkit/glue/webmediaplayer_impl.cc
new file mode 100644
index 0000000..d743886
--- /dev/null
+++ b/webkit/glue/webmediaplayer_impl.cc
@@ -0,0 +1,61 @@
+// Copyright (c) 2008 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 "config.h"
+
+#include "FrameView.h"
+#include "MediaPlayerPrivateChromium.h"
+#undef LOG
+
+#include "webkit/glue/webframe_impl.h"
+#include "webkit/glue/webmediaplayer_impl.h"
+
+#if ENABLE(VIDEO)
+
+namespace webkit_glue {
+
+WebMediaPlayerImpl::WebMediaPlayerImpl(
+ WebCore::MediaPlayerPrivate* media_player_private)
+ : media_player_private_(media_player_private) {
+}
+
+WebMediaPlayerImpl::~WebMediaPlayerImpl() {
+}
+
+void WebMediaPlayerImpl::Initialize(WebMediaPlayerDelegate* delegate){
+ delegate_ = delegate;
+}
+
+WebFrame* WebMediaPlayerImpl::GetWebFrame() {
+ if (media_player_private_->frameView()->frame()) {
+ return WebFrameImpl::FromFrame(
+ media_player_private_->frameView()->frame());
+ } else {
+ return NULL;
+ }
+}
+
+void WebMediaPlayerImpl::NotifynetworkStateChange() {
+ media_player_private_->networkStateChanged();
+}
+
+void WebMediaPlayerImpl::NotifyReadyStateChange() {
+ media_player_private_->readyStateChanged();
+}
+
+void WebMediaPlayerImpl::NotifyTimeChange() {
+ media_player_private_->timeChanged();
+}
+
+void WebMediaPlayerImpl::NotifyVolumeChange() {
+ media_player_private_->volumeChanged();
+}
+
+void WebMediaPlayerImpl::Repaint() {
+ media_player_private_->repaint();
+}
+
+} // namespace webkit_glue
+
+#endif
diff --git a/webkit/glue/webmediaplayer_impl.h b/webkit/glue/webmediaplayer_impl.h
new file mode 100644
index 0000000..e8ed8f2
--- /dev/null
+++ b/webkit/glue/webmediaplayer_impl.h
@@ -0,0 +1,60 @@
+// Copyright (c) 2008 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.
+//
+// Wrapper over WebCore::MediaPlayerPrivate. It also would handle resource
+// loading for the internal media player.
+
+#ifndef WEBKIT_GLUE_WEBMEDIAPLAYER_IMPL_H_
+#define WEBKIT_GLUE_WEBMEDIAPLAYER_IMPL_H_
+
+#include "webkit/glue/webmediaplayer.h"
+
+#if ENABLE(VIDEO)
+
+namespace WebCore {
+class MediaPlayerPrivate;
+}
+
+namespace webkit_glue {
+
+class WebMediaPlayerDelegate;
+
+class WebMediaPlayerImpl : public WebMediaPlayer {
+public:
+ WebMediaPlayerImpl(WebCore::MediaPlayerPrivate* media_player_private);
+
+ virtual ~WebMediaPlayerImpl();
+
+ virtual void Initialize(WebMediaPlayerDelegate* delegate);
+
+ // Get the web frame associated with the media player
+ virtual WebFrame* GetWebFrame();
+
+ // Notify the media player about network state change.
+ virtual void NotifynetworkStateChange();
+
+ // Notify the media player about ready state change.
+ virtual void NotifyReadyStateChange();
+
+ // Notify the media player about time change.
+ virtual void NotifyTimeChange();
+
+ // Notify the media player about volume change.
+ virtual void NotifyVolumeChange();
+
+ // Tell the media player to repaint itself.
+ virtual void Repaint();
+
+private:
+ WebCore::MediaPlayerPrivate* media_player_private_;
+ WebMediaPlayerDelegate* delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl);
+};
+
+} // namespace webkit_glue
+
+#endif // ENABLE(VIDEO)
+
+#endif // ifndef WEBKIT_GLUE_WEBMEDIAPLAYER_H_
diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h
index cfdc99e..0ffd764 100644
--- a/webkit/glue/webview_delegate.h
+++ b/webkit/glue/webview_delegate.h
@@ -37,8 +37,12 @@
#include "webkit/glue/window_open_disposition.h"
namespace gfx {
- class Point;
- class Rect;
+class Point;
+class Rect;
+}
+
+namespace webkit_glue {
+class WebMediaPlayerDelegate;
}
struct PasswordForm;
@@ -49,6 +53,7 @@ class SkBitmap;
class WebError;
class WebFrame;
class WebHistoryItem;
+class WebMediaPlayerDelegate;
class WebPluginDelegate;
class WebRequest;
class WebResponse;
@@ -128,6 +133,11 @@ class WebViewDelegate : virtual public WebWidgetDelegate {
return NULL;
}
+ // Called when a WebMediaPlayerDelegate is needed.
+ virtual webkit_glue::WebMediaPlayerDelegate* CreateMediaPlayerDelegate() {
+ return NULL;
+ }
+
// This method is called when default plugin has been correctly created and
// initialized, and found that the missing plugin is available to install or
// user has started installation.
diff --git a/webkit/port/platform/graphics/chromium/MediaPlayerPrivateChromium.h b/webkit/port/platform/graphics/chromium/MediaPlayerPrivateChromium.h
index 42280df..06aeeb4 100644
--- a/webkit/port/platform/graphics/chromium/MediaPlayerPrivateChromium.h
+++ b/webkit/port/platform/graphics/chromium/MediaPlayerPrivateChromium.h
@@ -1,5 +1,5 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
+// Copyright (c) 2006-2008 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.
#ifndef MediaPlayerPrivateChromium_h
@@ -9,6 +9,10 @@
#include "MediaPlayer.h"
+namespace webkit_glue {
+class WebMediaPlayerDelegate;
+}
+
namespace WebCore {
class MediaPlayerPrivate : public Noncopyable {
@@ -50,20 +54,25 @@ namespace WebCore {
void setVisible(bool);
void setRect(const IntRect&);
- void loadStateChanged();
- void didEnd();
-
void paint(GraphicsContext*, const IntRect&);
static void getSupportedTypes(HashSet<String>& types);
static bool isAvailable();
+ // Public methods to be called by WebMediaPlayer
+ FrameView* frameView();
+ void networkStateChanged();
+ void readyStateChanged();
+ void timeChanged();
+ void volumeChanged();
+ void repaint();
+
private:
MediaPlayer* m_player;
- MediaPlayer::NetworkState m_networkState;
- MediaPlayer::ReadyState m_readyState;
+ // TODO(hclam): MediaPlayerPrivateChromium should not know
+ // WebMediaPlayerDelegate, will need to get rid of this later.
+ webkit_glue::WebMediaPlayerDelegate* m_delegate;
};
-
}
#endif
diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc
index 4d7404b..b62d62f 100644
--- a/webkit/tools/test_shell/test_shell.cc
+++ b/webkit/tools/test_shell/test_shell.cc
@@ -33,6 +33,7 @@
#include "webkit/glue/webwidget.h"
#include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
#include "webkit/tools/test_shell/test_navigation_controller.h"
+#include "webkit/tools/test_shell/test_shell_switches.h"
#if defined(OS_MACOSX)
#include "webkit/glue/bogus_webkit_strings.h"
@@ -442,6 +443,10 @@ void TestShell::SetFocus(WebWidgetHost* host, bool enable) {
namespace webkit_glue {
+bool IsMediaPlayerAvailable() {
+ return CommandLine().HasSwitch(test_shell::kEnableVideo);
+}
+
void PrefetchDns(const std::string& hostname) {}
void PrecacheUrl(const char16* url, int url_length) {}
diff --git a/webkit/tools/test_shell/test_shell_switches.cc b/webkit/tools/test_shell/test_shell_switches.cc
index 214dd96..54e7af3 100644
--- a/webkit/tools/test_shell/test_shell_switches.cc
+++ b/webkit/tools/test_shell/test_shell_switches.cc
@@ -67,5 +67,8 @@ const wchar_t kAllowScriptsToCloseWindows[] = L"allow-scripts-to-close-windows";
extern const wchar_t kCheckLayoutTestSystemDeps[] =
L"check-layout-test-sys-deps";
+// Enable the media player by having this switch.
+extern const wchar_t kEnableVideo[] = L"enable-video";
+
} // namespace test_shell
diff --git a/webkit/tools/test_shell/test_shell_switches.h b/webkit/tools/test_shell/test_shell_switches.h
index 450c5ee..22bc982 100644
--- a/webkit/tools/test_shell/test_shell_switches.h
+++ b/webkit/tools/test_shell/test_shell_switches.h
@@ -29,6 +29,7 @@ extern const wchar_t kUseWinHttp[];
extern const wchar_t kEnableTracing[];
extern const wchar_t kAllowScriptsToCloseWindows[];
extern const wchar_t kCheckLayoutTestSystemDeps[];
+extern const wchar_t kEnableVideo[];
} // namespace test_shell