summaryrefslogtreecommitdiffstats
path: root/WebKit/android/WebCoreSupport
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/android/WebCoreSupport')
-rw-r--r--WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp29
-rw-r--r--WebKit/android/WebCoreSupport/ChromeClientAndroid.h8
-rw-r--r--WebKit/android/WebCoreSupport/EditorClientAndroid.cpp2
-rw-r--r--WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp25
-rw-r--r--WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.h11
-rw-r--r--WebKit/android/WebCoreSupport/InspectorClientAndroid.h16
-rw-r--r--WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp544
-rw-r--r--WebKit/android/WebCoreSupport/V8Counters.cpp2
8 files changed, 355 insertions, 282 deletions
diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
index c258d79..b59689d 100644
--- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
+++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
@@ -29,7 +29,6 @@
#include "ApplicationCacheStorage.h"
#include "ChromeClientAndroid.h"
-#include "CString.h"
#include "DatabaseTracker.h"
#include "Document.h"
#include "PlatformString.h"
@@ -39,6 +38,7 @@
#include "FrameView.h"
#include "Geolocation.h"
#include "GraphicsLayerAndroid.h"
+#include "Icon.h"
#include "Page.h"
#include "Screen.h"
#include "ScriptController.h"
@@ -47,6 +47,7 @@
#include "WebViewCore.h"
#include "WindowFeatures.h"
#include "Settings.h"
+#include <wtf/text/CString.h>
namespace android {
@@ -276,12 +277,19 @@ bool ChromeClientAndroid::tabsToLinks() const { return false; }
IntRect ChromeClientAndroid::windowResizerRect() const { return IntRect(0, 0, 0, 0); }
-// new to change 38068 (Nov 6, 2008)
-void ChromeClientAndroid::repaint(const IntRect& rect, bool contentChanged,
- bool immediate, bool repaintContentOnly) {
- notImplemented();
-// was in ScrollViewAndroid::update() : needs to be something like:
-// android::WebViewCore::getWebViewCore(this)->contentInvalidate(rect);
+void ChromeClientAndroid::invalidateWindow(const IntRect&, bool)
+{
+ notImplemented();
+}
+
+void ChromeClientAndroid::invalidateContentsAndWindow(const IntRect& updateRect, bool /*immediate*/)
+{
+ notImplemented();
+}
+
+void ChromeClientAndroid::invalidateContentsForSlowScroll(const IntRect& updateRect, bool immediate)
+{
+ notImplemented();
}
// new to change 38068 (Nov 6, 2008)
@@ -461,7 +469,7 @@ void ChromeClientAndroid::requestGeolocationPermissionForFrame(Frame* frame, Geo
m_geolocationPermissions->queryPermissionState(frame);
}
-void ChromeClientAndroid::cancelGeolocationPermissionRequestForFrame(Frame* frame)
+void ChromeClientAndroid::cancelGeolocationPermissionRequestForFrame(Frame* frame, WebCore::Geolocation*)
{
if (m_geolocationPermissions)
m_geolocationPermissions->cancelPermissionStateQuery(frame);
@@ -492,6 +500,11 @@ void ChromeClientAndroid::runOpenPanel(Frame* frame,
core->openFileChooser(chooser);
}
+void ChromeClientAndroid::chooseIconForFiles(const Vector<WebCore::String>&, FileChooser*)
+{
+ notImplemented();
+}
+
bool ChromeClientAndroid::setCursor(PlatformCursorHandle)
{
notImplemented();
diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h
index 68cac24..902d84c 100644
--- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h
+++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h
@@ -113,7 +113,9 @@ namespace android {
virtual IntRect windowResizerRect() const;
// Methods used by HostWindow.
- virtual void repaint(const IntRect&, bool contentChanged, bool immediate = false, bool repaintContentOnly = false);
+ virtual void invalidateWindow(const WebCore::IntRect&, bool);
+ virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool);
+ virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool);
virtual void scroll(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect);
virtual IntPoint screenToWindow(const IntPoint&) const;
virtual IntRect windowToScreen(const IntRect&) const;
@@ -143,7 +145,7 @@ namespace android {
// Methods used to request and provide Geolocation permissions.
virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*);
- virtual void cancelGeolocationPermissionRequestForFrame(Frame*);
+ virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*);
// Android-specific
void provideGeolocationPermissions(const String &origin, bool allow, bool remember);
void storeGeolocationPermissions();
@@ -151,6 +153,7 @@ namespace android {
virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>);
virtual bool setCursor(PlatformCursorHandle);
+ virtual void chooseIconForFiles(const WTF::Vector<WebCore::String>&, FileChooser*);
// Notification that the given form element has changed. This function
// will be called frequently, so handling should be very fast.
@@ -160,6 +163,7 @@ namespace android {
// Android-specific
void setWebFrame(android::WebFrame* webframe);
+ android::WebFrame* webFrame() { return m_webFrame; }
void wakeUpMainThreadWithNewQuota(long newQuota);
#if USE(ACCELERATED_COMPOSITING)
diff --git a/WebKit/android/WebCoreSupport/EditorClientAndroid.cpp b/WebKit/android/WebCoreSupport/EditorClientAndroid.cpp
index c07ea71..718a30c 100644
--- a/WebKit/android/WebCoreSupport/EditorClientAndroid.cpp
+++ b/WebKit/android/WebCoreSupport/EditorClientAndroid.cpp
@@ -32,12 +32,12 @@
#include "EventNames.h"
#include "FocusController.h"
#include "Frame.h"
-#include "KeyboardCodes.h"
#include "KeyboardEvent.h"
#include "NotImplemented.h"
#include "PlatformKeyboardEvent.h"
#include "PlatformString.h"
#include "WebViewCore.h"
+#include "WindowsKeyboardCodes.h"
namespace android {
diff --git a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp
index 9112afe..697f7b9 100644
--- a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp
+++ b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp
@@ -29,9 +29,10 @@
#include "FrameLoaderClientAndroid.h"
#include "BackForwardList.h"
-#include "CString.h"
#include "CachedFrame.h"
#include "CachedFramePlatformDataAndroid.h"
+#include "Chrome.h"
+#include "ChromeClientAndroid.h"
#include "DOMImplementation.h"
#include "Document.h"
#include "DocumentLoader.h"
@@ -75,6 +76,7 @@
#include "android_graphics.h"
#include <utils/AssetManager.h>
+#include <wtf/text/CString.h>
extern android::AssetManager* globalAssetManager();
@@ -693,7 +695,7 @@ void FrameLoaderClientAndroid::committedLoad(DocumentLoader* loader, const char*
bool userChosen = !encoding.isNull();
if (encoding.isNull())
encoding = loader->response().textEncodingName();
- loader->frameLoader()->setEncoding(encoding, userChosen);
+ loader->frameLoader()->writer()->setEncoding(encoding, userChosen);
Document *doc = m_frame->document();
if (doc)
loader->frameLoader()->addData(data, length);
@@ -1215,6 +1217,21 @@ WTF::PassRefPtr<Widget> FrameLoaderClientAndroid::createJavaAppletWidget(const I
return 0;
}
+void FrameLoaderClientAndroid::didTransferChildFrameToNewDocument()
+{
+ ASSERT(m_frame);
+ // m_webFrame points to the WebFrame for the page that our frame previously
+ // belonged to. If the frame now belongs to a new page, we need to update
+ // m_webFrame to point to the WebFrame for the new page.
+ Page* newPage = m_frame->page();
+ if (newPage != m_webFrame->page()) {
+ ChromeClientAndroid* chromeClient = static_cast<ChromeClientAndroid*>(newPage->chrome()->client());
+ Release(m_webFrame);
+ m_webFrame = chromeClient->webFrame();
+ Retain(m_webFrame);
+ }
+}
+
// This function is used by the <OBJECT> element to determine the type of
// the contents and work out if it can render it.
ObjectContentType FrameLoaderClientAndroid::objectContentType(const KURL& url,
@@ -1281,4 +1298,8 @@ void FrameLoaderClientAndroid::didAddIconForPageUrl(const String& pageUrl) {
}
}
+void FrameLoaderClientAndroid::dispatchDidChangeIcons() {
+ notImplemented();
+}
+
}
diff --git a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.h b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.h
index 3b754b8..ddbe196 100644
--- a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.h
+++ b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.h
@@ -176,11 +176,9 @@ namespace android {
virtual bool canCachePage() const;
virtual void download(ResourceHandle*, const ResourceRequest&, const ResourceRequest&, const ResourceResponse&);
- virtual WTF::PassRefPtr<Frame> createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
- const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight);
- virtual WTF::PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&,
- const WTF::Vector<String>&, const WTF::Vector<String>&,
- const String&, bool loadManually);
+ virtual WTF::PassRefPtr<Frame> createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement, const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight);
+ virtual void didTransferChildFrameToNewDocument();
+ virtual WTF::PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const WTF::Vector<String>&, const WTF::Vector<String>&, const String&, bool loadManually);
virtual void redirectDataToPlugin(Widget* pluginWidget);
virtual WTF::PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL, const WTF::Vector<String>& paramNames, const WTF::Vector<String>& paramValues);
@@ -210,6 +208,9 @@ namespace android {
CacheBuilder& getCacheBuilder() { return m_cacheBuilder; }
void enableOnDemandPlugins() { m_onDemandPluginsEnabled = true; }
+
+ void dispatchDidChangeIcons();
+ void dispatchWillSendSubmitEvent(HTMLFormElement*) { }
private:
CacheBuilder m_cacheBuilder;
Frame* m_frame;
diff --git a/WebKit/android/WebCoreSupport/InspectorClientAndroid.h b/WebKit/android/WebCoreSupport/InspectorClientAndroid.h
index 6feb2d7..50fcc47 100644
--- a/WebKit/android/WebCoreSupport/InspectorClientAndroid.h
+++ b/WebKit/android/WebCoreSupport/InspectorClientAndroid.h
@@ -36,27 +36,13 @@ public:
virtual void inspectorDestroyed() { delete this; }
- virtual Page* createPage() { return NULL; }
-
- virtual String localizedStringsURL() { return String(); }
-
- virtual void showWindow() {}
- virtual void closeWindow() {}
-
- virtual void attachWindow() {}
- virtual void detachWindow() {}
-
- virtual void setAttachedWindowHeight(unsigned height) {}
+ virtual void openInspectorFrontend(WebCore::InspectorController*) {}
virtual void highlight(Node*) {}
virtual void hideHighlight() {}
- virtual void inspectedURLChanged(const String& newURL) {}
-
virtual void populateSetting(const String& key, String* value) {}
virtual void storeSetting(const String& key, const String& value) {}
- virtual String hiddenPanels() { return String(); }
- virtual void inspectorWindowObjectCleared() {}
};
}
diff --git a/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp b/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp
index bfb5305..6224707 100644
--- a/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp
+++ b/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp
@@ -30,7 +30,6 @@
#include "GraphicsContext.h"
#include "SkiaUtils.h"
-#include "TimeRanges.h"
#include "WebCoreJni.h"
#include "WebViewCore.h"
@@ -44,16 +43,22 @@ using namespace android;
namespace WebCore {
static const char* g_ProxyJavaClass = "android/webkit/HTML5VideoViewProxy";
+static const char* g_ProxyJavaClassAudio = "android/webkit/HTML5Audio";
struct MediaPlayerPrivate::JavaGlue
{
jobject m_javaProxy;
- jmethodID m_getInstance;
jmethodID m_play;
jmethodID m_teardown;
- jmethodID m_loadPoster;
jmethodID m_seek;
jmethodID m_pause;
+ // Audio
+ jmethodID m_newInstance;
+ jmethodID m_setDataSource;
+ jmethodID m_getMaxTimeSeekable;
+ // Video
+ jmethodID m_getInstance;
+ jmethodID m_loadPoster;
};
MediaPlayerPrivate::~MediaPlayerPrivate()
@@ -65,7 +70,6 @@ MediaPlayerPrivate::~MediaPlayerPrivate()
env->DeleteGlobalRef(m_glue->m_javaProxy);
}
}
-
delete m_glue;
}
@@ -74,29 +78,6 @@ void MediaPlayerPrivate::registerMediaEngine(MediaEngineRegistrar registrar)
registrar(create, getSupportedTypes, supportsType);
}
-void MediaPlayerPrivate::load(const String& url)
-{
- // Just save the URl.
- m_url = url;
-}
-
-void MediaPlayerPrivate::cancelLoad()
-{
-}
-
-void MediaPlayerPrivate::play()
-{
- JNIEnv* env = JSC::Bindings::getJNIEnv();
- if (!env || !m_glue->m_javaProxy || !m_url.length())
- return;
-
- m_paused = false;
- jstring jUrl = env->NewString((unsigned short *)m_url.characters(), m_url.length());
- env->CallVoidMethod(m_glue->m_javaProxy, m_glue->m_play, jUrl);
- env->DeleteLocalRef(jUrl);
- checkException(env);
-}
-
void MediaPlayerPrivate::pause()
{
JNIEnv* env = JSC::Bindings::getJNIEnv();
@@ -108,22 +89,6 @@ void MediaPlayerPrivate::pause()
checkException(env);
}
-IntSize MediaPlayerPrivate::naturalSize() const
-{
- return m_naturalSize;
-}
-
-bool MediaPlayerPrivate::hasAudio() const
-{
- // TODO
- return false;
-}
-
-bool MediaPlayerPrivate::hasVideo() const
-{
- return m_hasVideo;
-}
-
void MediaPlayerPrivate::setVisible(bool visible)
{
m_isVisible = visible;
@@ -131,99 +96,19 @@ void MediaPlayerPrivate::setVisible(bool visible)
createJavaPlayerIfNeeded();
}
-float MediaPlayerPrivate::duration() const
-{
- return m_duration;
-}
-
-float MediaPlayerPrivate::currentTime() const
-{
- return m_currentTime;
-}
-
void MediaPlayerPrivate::seek(float time)
{
JNIEnv* env = JSC::Bindings::getJNIEnv();
- if (!env || !m_glue->m_javaProxy || !m_url.length())
+ if (!env || !m_url.length())
return;
- m_currentTime = time;
- env->CallVoidMethod(m_glue->m_javaProxy, m_glue->m_seek, static_cast<jint>(time * 1000.0f));
+ if (m_glue->m_javaProxy) {
+ env->CallVoidMethod(m_glue->m_javaProxy, m_glue->m_seek, static_cast<jint>(time * 1000.0f));
+ m_currentTime = time;
+ }
checkException(env);
}
-bool MediaPlayerPrivate::seeking() const
-{
- return false;
-}
-
-void MediaPlayerPrivate::setEndTime(float)
-{
-}
-
-void MediaPlayerPrivate::setRate(float)
-{
-}
-
-bool MediaPlayerPrivate::paused() const
-{
- return m_paused;
-}
-
-void MediaPlayerPrivate::setVolume(float)
-{
-}
-
-MediaPlayer::NetworkState MediaPlayerPrivate::networkState() const
-{
- return m_networkState;
-}
-
-MediaPlayer::ReadyState MediaPlayerPrivate::readyState() const
-{
- return m_readyState;
-}
-
-float MediaPlayerPrivate::maxTimeSeekable() const
-{
- return 0;
-}
-
-PassRefPtr<TimeRanges> MediaPlayerPrivate::buffered() const
-{
- return TimeRanges::create();
-}
-
-int MediaPlayerPrivate::dataRate() const
-{
- return 0;
-}
-
-unsigned MediaPlayerPrivate::totalBytes() const
-{
- return 0;
-}
-
-unsigned MediaPlayerPrivate::bytesLoaded() const
-{
- return 0;
-}
-
-void MediaPlayerPrivate::setSize(const IntSize&)
-{
-}
-
-void MediaPlayerPrivate::setPoster(const String& url)
-{
- m_posterUrl = url;
- JNIEnv* env = JSC::Bindings::getJNIEnv();
- if (!env || !m_glue->m_javaProxy || !m_posterUrl.length())
- return;
- // Send the poster
- jstring jUrl = env->NewString((unsigned short *)m_posterUrl.characters(), m_posterUrl.length());
- env->CallVoidMethod(m_glue->m_javaProxy, m_glue->m_loadPoster, jUrl);
- env->DeleteLocalRef(jUrl);
-}
void MediaPlayerPrivate::prepareToPlay() {
// We are about to start playing. Since our Java VideoView cannot
@@ -237,45 +122,6 @@ void MediaPlayerPrivate::prepareToPlay() {
m_player->readyStateChanged();
}
-void MediaPlayerPrivate::paint(GraphicsContext* ctxt, const IntRect& r)
-{
- if (ctxt->paintingDisabled())
- return;
-
- if (!m_isVisible)
- return;
-
- if (!m_poster || (!m_poster->getPixels() && !m_poster->pixelRef()))
- return;
-
- SkCanvas* canvas = ctxt->platformContext()->mCanvas;
- // We paint with the following rules in mind:
- // - only downscale the poster, never upscale
- // - maintain the natural aspect ratio of the poster
- // - the poster should be centered in the target rect
- float originalRatio = static_cast<float>(m_poster->width()) / static_cast<float>(m_poster->height());
- int posterWidth = r.width() > m_poster->width() ? m_poster->width() : r.width();
- int posterHeight = posterWidth / originalRatio;
- int posterX = ((r.width() - posterWidth) / 2) + r.x();
- int posterY = ((r.height() - posterHeight) / 2) + r.y();
- IntRect targetRect(posterX, posterY, posterWidth, posterHeight);
- canvas->drawBitmapRect(*m_poster, 0, targetRect, 0);
-}
-
-MediaPlayerPrivateInterface* MediaPlayerPrivate::create(MediaPlayer* player)
-{
- return new MediaPlayerPrivate(player);
-}
-
-void MediaPlayerPrivate::getSupportedTypes(HashSet<String>&)
-{
-}
-
-MediaPlayer::SupportsType MediaPlayerPrivate::supportsType(const String& type, const String& codecs)
-{
- return MediaPlayer::IsNotSupported;
-}
-
MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player)
: m_player(player),
m_glue(0),
@@ -290,72 +136,6 @@ MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player)
m_naturalSizeUnknown(true),
m_isVisible(false)
{
- JNIEnv* env = JSC::Bindings::getJNIEnv();
- if (!env)
- return;
-
- jclass clazz = env->FindClass(g_ProxyJavaClass);
- if (!clazz)
- return;
-
- m_glue = new JavaGlue;
- m_glue->m_getInstance = env->GetStaticMethodID(clazz, "getInstance", "(Landroid/webkit/WebViewCore;I)Landroid/webkit/HTML5VideoViewProxy;");
- m_glue->m_play = env->GetMethodID(clazz, "play", "(Ljava/lang/String;)V");
- m_glue->m_teardown = env->GetMethodID(clazz, "teardown", "()V");
- m_glue->m_loadPoster = env->GetMethodID(clazz, "loadPoster", "(Ljava/lang/String;)V");
- m_glue->m_seek = env->GetMethodID(clazz, "seek", "(I)V");
- m_glue->m_pause = env->GetMethodID(clazz, "pause", "()V");
- m_glue->m_javaProxy = NULL;
- env->DeleteLocalRef(clazz);
- // An exception is raised if any of the above fails.
- checkException(env);
-}
-
-void MediaPlayerPrivate::createJavaPlayerIfNeeded()
-{
- // Check if we have been already created.
- if (m_glue->m_javaProxy)
- return;
-
- FrameView* frameView = m_player->frameView();
- if (!frameView)
- return;
-
- JNIEnv* env = JSC::Bindings::getJNIEnv();
- if (!env)
- return;
-
- jclass clazz = env->FindClass(g_ProxyJavaClass);
- if (!clazz)
- return;
-
- WebViewCore* webViewCore = WebViewCore::getWebViewCore(frameView);
- ASSERT(webViewCore);
-
- // Get the HTML5VideoViewProxy instance
- jobject obj = env->CallStaticObjectMethod(clazz, m_glue->m_getInstance, webViewCore->getJavaObject().get(), this);
- m_glue->m_javaProxy = env->NewGlobalRef(obj);
- // Send the poster
- jstring jUrl = 0;
- if (m_posterUrl.length())
- jUrl = env->NewString((unsigned short *)m_posterUrl.characters(), m_posterUrl.length());
- // Sending a NULL jUrl allows the Java side to try to load the default poster.
- env->CallVoidMethod(m_glue->m_javaProxy, m_glue->m_loadPoster, jUrl);
- if (jUrl)
- env->DeleteLocalRef(jUrl);
- // Clean up.
- env->DeleteLocalRef(obj);
- env->DeleteLocalRef(clazz);
- checkException(env);
-}
-
-void MediaPlayerPrivate::onPrepared(int duration, int width, int height) {
- m_duration = duration / 1000.0f;
- m_naturalSize = IntSize(width, height);
- m_naturalSizeUnknown = false;
- m_hasVideo = true;
- m_player->durationChanged();
- m_player->sizeChanged();
}
void MediaPlayerPrivate::onEnded() {
@@ -368,25 +148,269 @@ void MediaPlayerPrivate::onEnded() {
m_readyState = MediaPlayer::HaveNothing;
}
-void MediaPlayerPrivate::onPosterFetched(SkBitmap* poster) {
- m_poster = poster;
- if (m_naturalSizeUnknown) {
- // We had to fake the size at startup, or else our paint
- // method would not be called. If we haven't yet received
- // the onPrepared event, update the intrinsic size to the size
- // of the poster. That will be overriden when onPrepare comes.
- // In case of an error, we should report the poster size, rather
- // than our initial fake value.
- m_naturalSize = IntSize(poster->width(), poster->height());
- m_player->sizeChanged();
- }
-}
-
void MediaPlayerPrivate::onTimeupdate(int position) {
m_currentTime = position / 1000.0f;
m_player->timeChanged();
}
+class MediaPlayerVideoPrivate : public MediaPlayerPrivate {
+public:
+ void load(const String& url) { m_url = url; }
+ void play() {
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ if (!env || !m_url.length() || !m_glue->m_javaProxy)
+ return;
+
+ m_paused = false;
+ jstring jUrl = env->NewString((unsigned short *)m_url.characters(), m_url.length());
+ env->CallVoidMethod(m_glue->m_javaProxy, m_glue->m_play, jUrl);
+ env->DeleteLocalRef(jUrl);
+
+ checkException(env);
+ }
+ bool canLoadPoster() const { return true; }
+ void setPoster(const String& url) {
+ m_posterUrl = url;
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ if (!env || !m_glue->m_javaProxy || !m_posterUrl.length())
+ return;
+ // Send the poster
+ jstring jUrl = env->NewString((unsigned short *)m_posterUrl.characters(), m_posterUrl.length());
+ env->CallVoidMethod(m_glue->m_javaProxy, m_glue->m_loadPoster, jUrl);
+ env->DeleteLocalRef(jUrl);
+ }
+ void paint(GraphicsContext* ctxt, const IntRect& r) {
+ if (ctxt->paintingDisabled())
+ return;
+
+ if (!m_isVisible)
+ return;
+
+ if (!m_poster || (!m_poster->getPixels() && !m_poster->pixelRef()))
+ return;
+
+ SkCanvas* canvas = ctxt->platformContext()->mCanvas;
+ // We paint with the following rules in mind:
+ // - only downscale the poster, never upscale
+ // - maintain the natural aspect ratio of the poster
+ // - the poster should be centered in the target rect
+ float originalRatio = static_cast<float>(m_poster->width()) / static_cast<float>(m_poster->height());
+ int posterWidth = r.width() > m_poster->width() ? m_poster->width() : r.width();
+ int posterHeight = posterWidth / originalRatio;
+ int posterX = ((r.width() - posterWidth) / 2) + r.x();
+ int posterY = ((r.height() - posterHeight) / 2) + r.y();
+ IntRect targetRect(posterX, posterY, posterWidth, posterHeight);
+ canvas->drawBitmapRect(*m_poster, 0, targetRect, 0);
+ }
+
+ void onPosterFetched(SkBitmap* poster) {
+ m_poster = poster;
+ if (m_naturalSizeUnknown) {
+ // We had to fake the size at startup, or else our paint
+ // method would not be called. If we haven't yet received
+ // the onPrepared event, update the intrinsic size to the size
+ // of the poster. That will be overriden when onPrepare comes.
+ // In case of an error, we should report the poster size, rather
+ // than our initial fake value.
+ m_naturalSize = IntSize(poster->width(), poster->height());
+ m_player->sizeChanged();
+ }
+ }
+
+ void onPrepared(int duration, int width, int height) {
+ m_duration = duration / 1000.0f;
+ m_naturalSize = IntSize(width, height);
+ m_naturalSizeUnknown = false;
+ m_hasVideo = true;
+ m_player->durationChanged();
+ m_player->sizeChanged();
+ }
+
+ bool hasAudio() { return false; } // do not display the audio UI
+ bool hasVideo() { return m_hasVideo; }
+
+ MediaPlayerVideoPrivate(MediaPlayer* player) : MediaPlayerPrivate(player) {
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ if (!env)
+ return;
+
+ jclass clazz = env->FindClass(g_ProxyJavaClass);
+
+ if (!clazz)
+ return;
+
+ m_glue = new JavaGlue;
+ m_glue->m_getInstance = env->GetStaticMethodID(clazz, "getInstance", "(Landroid/webkit/WebViewCore;I)Landroid/webkit/HTML5VideoViewProxy;");
+ m_glue->m_loadPoster = env->GetMethodID(clazz, "loadPoster", "(Ljava/lang/String;)V");
+ m_glue->m_play = env->GetMethodID(clazz, "play", "(Ljava/lang/String;)V");
+
+ m_glue->m_teardown = env->GetMethodID(clazz, "teardown", "()V");
+ m_glue->m_seek = env->GetMethodID(clazz, "seek", "(I)V");
+ m_glue->m_pause = env->GetMethodID(clazz, "pause", "()V");
+ m_glue->m_javaProxy = NULL;
+ env->DeleteLocalRef(clazz);
+ // An exception is raised if any of the above fails.
+ checkException(env);
+ }
+
+ void createJavaPlayerIfNeeded() {
+ // Check if we have been already created.
+ if (m_glue->m_javaProxy)
+ return;
+
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ if (!env)
+ return;
+
+ jclass clazz = env->FindClass(g_ProxyJavaClass);
+
+ if (!clazz)
+ return;
+
+ jobject obj = NULL;
+
+ FrameView* frameView = m_player->frameView();
+ if (!frameView)
+ return;
+ WebViewCore* webViewCore = WebViewCore::getWebViewCore(frameView);
+ ASSERT(webViewCore);
+
+ // Get the HTML5VideoViewProxy instance
+ obj = env->CallStaticObjectMethod(clazz, m_glue->m_getInstance, webViewCore->getJavaObject().get(), this);
+ m_glue->m_javaProxy = env->NewGlobalRef(obj);
+ // Send the poster
+ jstring jUrl = 0;
+ if (m_posterUrl.length())
+ jUrl = env->NewString((unsigned short *)m_posterUrl.characters(), m_posterUrl.length());
+ // Sending a NULL jUrl allows the Java side to try to load the default poster.
+ env->CallVoidMethod(m_glue->m_javaProxy, m_glue->m_loadPoster, jUrl);
+ if (jUrl)
+ env->DeleteLocalRef(jUrl);
+
+ // Clean up.
+ if (obj)
+ env->DeleteLocalRef(obj);
+ env->DeleteLocalRef(clazz);
+ checkException(env);
+ }
+};
+
+class MediaPlayerAudioPrivate : public MediaPlayerPrivate {
+public:
+ void load(const String& url) {
+ m_url = url;
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ if (!env || !m_url.length())
+ return;
+
+ createJavaPlayerIfNeeded();
+
+ if (!m_glue->m_javaProxy)
+ return;
+
+ jstring jUrl = env->NewString((unsigned short *)m_url.characters(), m_url.length());
+ // start loading the data asynchronously
+ env->CallVoidMethod(m_glue->m_javaProxy, m_glue->m_setDataSource, jUrl);
+ env->DeleteLocalRef(jUrl);
+ checkException(env);
+ }
+
+ void play() {
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ if (!env || !m_url.length())
+ return;
+
+ createJavaPlayerIfNeeded();
+
+ if (!m_glue->m_javaProxy)
+ return;
+
+ m_paused = false;
+ env->CallVoidMethod(m_glue->m_javaProxy, m_glue->m_play);
+ checkException(env);
+ }
+
+ bool hasAudio() { return true; }
+
+ float maxTimeSeekable() const {
+ if (m_glue->m_javaProxy) {
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ if (env) {
+ float maxTime = env->CallFloatMethod(m_glue->m_javaProxy,
+ m_glue->m_getMaxTimeSeekable);
+ checkException(env);
+ return maxTime;
+ }
+ }
+ return 0;
+ }
+
+ MediaPlayerAudioPrivate(MediaPlayer* player) : MediaPlayerPrivate(player) {
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ if (!env)
+ return;
+
+ jclass clazz = env->FindClass(g_ProxyJavaClassAudio);
+
+ if (!clazz)
+ return;
+
+ m_glue = new JavaGlue;
+ m_glue->m_newInstance = env->GetMethodID(clazz, "<init>", "(I)V");
+ m_glue->m_setDataSource = env->GetMethodID(clazz, "setDataSource", "(Ljava/lang/String;)V");
+ m_glue->m_play = env->GetMethodID(clazz, "play", "()V");
+ m_glue->m_getMaxTimeSeekable = env->GetMethodID(clazz, "getMaxTimeSeekable", "()F");
+ m_glue->m_teardown = env->GetMethodID(clazz, "teardown", "()V");
+ m_glue->m_seek = env->GetMethodID(clazz, "seek", "(I)V");
+ m_glue->m_pause = env->GetMethodID(clazz, "pause", "()V");
+ m_glue->m_javaProxy = NULL;
+ env->DeleteLocalRef(clazz);
+ // An exception is raised if any of the above fails.
+ checkException(env);
+ }
+
+ void createJavaPlayerIfNeeded() {
+ // Check if we have been already created.
+ if (m_glue->m_javaProxy)
+ return;
+
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ if (!env)
+ return;
+
+ jclass clazz = env->FindClass(g_ProxyJavaClassAudio);
+
+ if (!clazz)
+ return;
+
+ jobject obj = NULL;
+
+ // Get the HTML5Audio instance
+ obj = env->NewObject(clazz, m_glue->m_newInstance, this);
+ m_glue->m_javaProxy = env->NewGlobalRef(obj);
+
+ // Clean up.
+ if (obj)
+ env->DeleteLocalRef(obj);
+ env->DeleteLocalRef(clazz);
+ checkException(env);
+ }
+
+ void onPrepared(int duration, int width, int height) {
+ m_duration = duration / 1000.0f;
+ m_player->durationChanged();
+ m_player->sizeChanged();
+ m_player->prepareToPlay();
+ }
+};
+
+MediaPlayerPrivateInterface* MediaPlayerPrivate::create(MediaPlayer* player)
+{
+ if (player->mediaElementType() == MediaPlayer::Video)
+ return new MediaPlayerVideoPrivate(player);
+ return new MediaPlayerAudioPrivate(player);
+}
+
}
namespace android {
@@ -416,6 +440,13 @@ static void OnPosterFetched(JNIEnv* env, jobject obj, jobject poster, int pointe
player->onPosterFetched(posterNative);
}
+static void OnBuffering(JNIEnv* env, jobject obj, int percent, int pointer) {
+ if (pointer) {
+ WebCore::MediaPlayerPrivate* player = reinterpret_cast<WebCore::MediaPlayerPrivate*>(pointer);
+ //TODO: player->onBuffering(percent);
+ }
+}
+
static void OnTimeupdate(JNIEnv* env, jobject obj, int position, int pointer) {
if (pointer) {
WebCore::MediaPlayerPrivate* player = reinterpret_cast<WebCore::MediaPlayerPrivate*>(pointer);
@@ -437,11 +468,28 @@ static JNINativeMethod g_MediaPlayerMethods[] = {
(void*) OnTimeupdate },
};
-int register_mediaplayer(JNIEnv* env)
+static JNINativeMethod g_MediaAudioPlayerMethods[] = {
+ { "nativeOnBuffering", "(II)V",
+ (void*) OnBuffering },
+ { "nativeOnEnded", "(I)V",
+ (void*) OnEnded },
+ { "nativeOnPrepared", "(IIII)V",
+ (void*) OnPrepared },
+ { "nativeOnTimeupdate", "(II)V",
+ (void*) OnTimeupdate },
+};
+
+int register_mediaplayer_video(JNIEnv* env)
{
return jniRegisterNativeMethods(env, g_ProxyJavaClass,
g_MediaPlayerMethods, NELEM(g_MediaPlayerMethods));
}
+int register_mediaplayer_audio(JNIEnv* env)
+{
+ return jniRegisterNativeMethods(env, g_ProxyJavaClassAudio,
+ g_MediaAudioPlayerMethods, NELEM(g_MediaAudioPlayerMethods));
+}
+
}
#endif // VIDEO
diff --git a/WebKit/android/WebCoreSupport/V8Counters.cpp b/WebKit/android/WebCoreSupport/V8Counters.cpp
index 7f3f3ad..7472447 100644
--- a/WebKit/android/WebCoreSupport/V8Counters.cpp
+++ b/WebKit/android/WebCoreSupport/V8Counters.cpp
@@ -33,9 +33,9 @@
#include "V8Counters.h"
#include "NotImplemented.h"
-#include <CString.h>
#include <StringHash.h>
#include <utils/Log.h>
+#include <wtf/text/CString.h>
namespace WebCore {