diff options
author | Teng-Hui Zhu <ztenghui@google.com> | 2012-07-18 15:39:53 -0700 |
---|---|---|
committer | Teng-Hui Zhu <ztenghui@google.com> | 2012-07-18 15:53:28 -0700 |
commit | ad46784d9075ff6d1e11cd2be47a6169761b0eeb (patch) | |
tree | 64006c7367e689eb4a4e66fe8500348b1fca1fa1 | |
parent | d12967fd535d36a592841c6c4bb112bd94092b3c (diff) | |
download | external_webkit-ad46784d9075ff6d1e11cd2be47a6169761b0eeb.zip external_webkit-ad46784d9075ff6d1e11cd2be47a6169761b0eeb.tar.gz external_webkit-ad46784d9075ff6d1e11cd2be47a6169761b0eeb.tar.bz2 |
add webSetting API to allow media play without user gesture
bug:6806306
This also include partial change from webkit.
http://trac.webkit.org/changeset/91232
Framework change: https://android-git.corp.google.com/g/#/c/208569/
Change-Id: I1a843472c0ce3b01bcad3b7c3c12c93702f2970c
-rw-r--r-- | Source/WebCore/html/HTMLMediaElement.cpp | 6 | ||||
-rw-r--r-- | Source/WebCore/page/Settings.cpp | 2 | ||||
-rw-r--r-- | Source/WebCore/page/Settings.h | 8 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebSettings.cpp | 6 |
4 files changed, 19 insertions, 3 deletions
diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp index d25bada..693f214 100644 --- a/Source/WebCore/html/HTMLMediaElement.cpp +++ b/Source/WebCore/html/HTMLMediaElement.cpp @@ -185,9 +185,9 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document* docum document->registerForDocumentActivationCallbacks(this); document->registerForMediaVolumeCallbacks(this); document->registerForPrivateBrowsingStateChangedCallbacks(this); -#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) - m_restrictions |= RequireUserGestureForRateChangeRestriction; -#endif + + if (document->settings() && document->settings()->mediaPlaybackRequiresUserGesture()) + m_restrictions |= RequireUserGestureForRateChangeRestriction; } HTMLMediaElement::~HTMLMediaElement() diff --git a/Source/WebCore/page/Settings.cpp b/Source/WebCore/page/Settings.cpp index f668f3e..79e38d1 100644 --- a/Source/WebCore/page/Settings.cpp +++ b/Source/WebCore/page/Settings.cpp @@ -201,6 +201,8 @@ Settings::Settings(Page* page) #else , m_passwordEchoEnabled(false) #endif + , m_mediaPlaybackRequiresUserGesture(false) + , m_mediaPlaybackAllowsInline(true) { // A Frame may not have been created yet, so we initialize the AtomicString // hash before trying to use it. diff --git a/Source/WebCore/page/Settings.h b/Source/WebCore/page/Settings.h index 2cf7715..84828ab 100644 --- a/Source/WebCore/page/Settings.h +++ b/Source/WebCore/page/Settings.h @@ -479,6 +479,12 @@ namespace WebCore { bool blockNetworkImage() const { return m_blockNetworkImage; } #endif + void setMediaPlaybackRequiresUserGesture(bool flag) { m_mediaPlaybackRequiresUserGesture = flag; }; + bool mediaPlaybackRequiresUserGesture() const { return m_mediaPlaybackRequiresUserGesture; } + + void setMediaPlaybackAllowsInline(bool flag) { m_mediaPlaybackAllowsInline = flag; }; + bool mediaPlaybackAllowsInline() const { return m_mediaPlaybackAllowsInline; } + private: Page* m_page; @@ -633,6 +639,8 @@ namespace WebCore { #ifdef ANDROID_PLUGINS bool m_pluginsOnDemand : 1; #endif + bool m_mediaPlaybackRequiresUserGesture : 1; + bool m_mediaPlaybackAllowsInline : 1; bool m_passwordEchoEnabled : 1; #if USE(SAFARI_THEME) diff --git a/Source/WebKit/android/jni/WebSettings.cpp b/Source/WebKit/android/jni/WebSettings.cpp index 467da3d..1bd3e36 100644 --- a/Source/WebKit/android/jni/WebSettings.cpp +++ b/Source/WebKit/android/jni/WebSettings.cpp @@ -151,6 +151,7 @@ struct FieldIds { #endif mOverrideCacheMode = env->GetFieldID(clazz, "mOverrideCacheMode", "I"); mPasswordEchoEnabled = env->GetFieldID(clazz, "mPasswordEchoEnabled", "Z"); + mMediaPlaybackRequiresUserGesture = env->GetFieldID(clazz, "mMediaPlaybackRequiresUserGesture", "Z"); ALOG_ASSERT(mLayoutAlgorithm, "Could not find field mLayoutAlgorithm"); ALOG_ASSERT(mTextSize, "Could not find field mTextSize"); @@ -195,6 +196,7 @@ struct FieldIds { ALOG_ASSERT(mUseDoubleTree, "Could not find field mUseDoubleTree"); ALOG_ASSERT(mPageCacheCapacity, "Could not find field mPageCacheCapacity"); ALOG_ASSERT(mPasswordEchoEnabled, "Could not find field mPasswordEchoEnabled"); + ALOG_ASSERT(mMediaPlaybackRequiresUserGesture, "Could not find field mMediaPlaybackRequiresUserGesture"); jclass enumClass = env->FindClass("java/lang/Enum"); ALOG_ASSERT(enumClass, "Could not find Enum class!"); @@ -281,6 +283,7 @@ struct FieldIds { #endif jfieldID mOverrideCacheMode; jfieldID mPasswordEchoEnabled; + jfieldID mMediaPlaybackRequiresUserGesture; }; static struct FieldIds* gFieldIds; @@ -616,6 +619,9 @@ public: bool echoPassword = env->GetBooleanField(obj, gFieldIds->mPasswordEchoEnabled); s->setPasswordEchoEnabled(echoPassword); + + flag = env->GetBooleanField(obj, gFieldIds->mMediaPlaybackRequiresUserGesture); + s->setMediaPlaybackRequiresUserGesture(flag); } }; |