summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Scott <phanna@android.com>2009-09-24 10:54:01 -0400
committerPatrick Scott <phanna@android.com>2009-09-24 10:56:22 -0400
commit28e09963cd0ab02a20ddd0b687e55f97921445cc (patch)
tree99a1b6b95064e0574df34e97a7cdfd477d67a4e2
parent2c02e355bf0631c0bec3496fab67f45710c5cd21 (diff)
downloadexternal_webkit-28e09963cd0ab02a20ddd0b687e55f97921445cc.zip
external_webkit-28e09963cd0ab02a20ddd0b687e55f97921445cc.tar.gz
external_webkit-28e09963cd0ab02a20ddd0b687e55f97921445cc.tar.bz2
Add ANDROID_USER_GESTURE back to WebCore.
We only care about the user gesture during a location change. Add the m_userGesture field to our ResourceRequest and check the value in canHandleRequest. This could be cleaner if WebCore passed around the ResourceRequest rather than constructing a new one.
-rw-r--r--WebCore/WebCorePrefixAndroid.h5
-rw-r--r--WebCore/loader/FrameLoader.cpp33
-rw-r--r--WebCore/loader/FrameLoader.h7
-rw-r--r--WebCore/platform/network/android/ResourceRequest.h7
-rw-r--r--WebKit/android/jni/WebCoreFrameBridge.cpp2
5 files changed, 53 insertions, 1 deletions
diff --git a/WebCore/WebCorePrefixAndroid.h b/WebCore/WebCorePrefixAndroid.h
index a23718f..901af5f 100644
--- a/WebCore/WebCorePrefixAndroid.h
+++ b/WebCore/WebCorePrefixAndroid.h
@@ -150,3 +150,8 @@ typedef unsigned char flex_uint8_t;
// apple-touch-icon support in <link> tags
#define ANDROID_APPLE_TOUCH_ICON
+
+// The user gesture flag is lost during a scheduled location change. We need to
+// maintain that flag until canHandleRequest to determine if a link was clicked
+// or if javascript tried to change the location.
+#define ANDROID_USER_GESTURE
diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp
index 256c82d..5c81cfc 100644
--- a/WebCore/loader/FrameLoader.cpp
+++ b/WebCore/loader/FrameLoader.cpp
@@ -392,6 +392,9 @@ void FrameLoader::changeLocation(const KURL& url, const String& referrer, bool l
RefPtr<Frame> protect(m_frame);
ResourceRequest request(url, referrer, refresh ? ReloadIgnoringCacheData : UseProtocolCachePolicy);
+#ifdef ANDROID_USER_GESTURE
+ request.setUserGesture(userGesture);
+#endif
if (executeIfJavaScriptURL(request.url(), userGesture))
return;
@@ -1534,7 +1537,11 @@ void FrameLoader::loadURLIntoChildFrame(const KURL& url, const String& referer,
childFrame->loader()->loadArchive(subframeArchive.release());
else
#endif
+#ifdef ANDROID_USER_GESTURE
+ childFrame->loader()->loadURL(workingURL, referer, String(), false, childLoadType, 0, 0, true);
+#else
childFrame->loader()->loadURL(workingURL, referer, String(), false, childLoadType, 0, 0);
+#endif
}
#if ENABLE(ARCHIVE) // ANDROID extension: disabled to reduce code size
@@ -2250,10 +2257,17 @@ void FrameLoader::loadFrameRequest(const FrameLoadRequest& request, bool lockHis
else
loadType = FrameLoadTypeStandard;
+#ifdef ANDROID_USER_GESTURE
+ if (request.resourceRequest().httpMethod() == "POST")
+ loadPostRequest(request.resourceRequest(), referrer, request.frameName(), lockHistory, loadType, event, formState.get(), request.resourceRequest().getUserGesture());
+ else
+ loadURL(request.resourceRequest().url(), referrer, request.frameName(), lockHistory, loadType, event, formState.get(), request.resourceRequest().getUserGesture());
+#else
if (request.resourceRequest().httpMethod() == "POST")
loadPostRequest(request.resourceRequest(), referrer, request.frameName(), lockHistory, loadType, event, formState.get());
else
loadURL(request.resourceRequest().url(), referrer, request.frameName(), lockHistory, loadType, event, formState.get());
+#endif
// FIXME: It's possible this targetFrame will not be the same frame that was targeted by the actual
// load if frame names have changed.
@@ -2265,13 +2279,21 @@ void FrameLoader::loadFrameRequest(const FrameLoadRequest& request, bool lockHis
}
}
+#ifdef ANDROID_USER_GESTURE
+void FrameLoader::loadURL(const KURL& newURL, const String& referrer, const String& frameName, bool lockHistory, FrameLoadType newLoadType,
+ PassRefPtr<Event> event, PassRefPtr<FormState> prpFormState, bool userGesture)
+#else
void FrameLoader::loadURL(const KURL& newURL, const String& referrer, const String& frameName, bool lockHistory, FrameLoadType newLoadType,
PassRefPtr<Event> event, PassRefPtr<FormState> prpFormState)
+#endif
{
RefPtr<FormState> formState = prpFormState;
bool isFormSubmission = formState;
ResourceRequest request(newURL);
+#ifdef ANDROID_USER_GESTURE
+ request.setUserGesture(userGesture);
+#endif
if (!referrer.isEmpty()) {
request.setHTTPReferrer(referrer);
RefPtr<SecurityOrigin> referrerOrigin = SecurityOrigin::createFromString(referrer);
@@ -2286,7 +2308,11 @@ void FrameLoader::loadURL(const KURL& newURL, const String& referrer, const Stri
// The search for a target frame is done earlier in the case of form submission.
Frame* targetFrame = isFormSubmission ? 0 : findFrameForNavigation(frameName);
if (targetFrame && targetFrame != m_frame) {
+#ifdef ANDROID_USER_GESTURE
+ targetFrame->loader()->loadURL(newURL, referrer, String(), lockHistory, newLoadType, event, formState.release(), userGesture);
+#else
targetFrame->loader()->loadURL(newURL, referrer, String(), lockHistory, newLoadType, event, formState.release());
+#endif
return;
}
@@ -3687,7 +3713,11 @@ void FrameLoader::committedLoad(DocumentLoader* loader, const char* data, int le
m_client->committedLoad(loader, data, length);
}
+#ifdef ANDROID_USER_GESTURE
+void FrameLoader::loadPostRequest(const ResourceRequest& inRequest, const String& referrer, const String& frameName, bool lockHistory, FrameLoadType loadType, PassRefPtr<Event> event, PassRefPtr<FormState> prpFormState, bool userGesture)
+#else
void FrameLoader::loadPostRequest(const ResourceRequest& inRequest, const String& referrer, const String& frameName, bool lockHistory, FrameLoadType loadType, PassRefPtr<Event> event, PassRefPtr<FormState> prpFormState)
+#endif
{
RefPtr<FormState> formState = prpFormState;
@@ -3707,6 +3737,9 @@ void FrameLoader::loadPostRequest(const ResourceRequest& inRequest, const String
String origin = inRequest.httpOrigin();
ResourceRequest workingResourceRequest(url);
+#ifdef ANDROID_USER_GESTURE
+ workingResourceRequest.setUserGesture(userGesture);
+#endif
if (!referrer.isEmpty())
workingResourceRequest.setHTTPReferrer(referrer);
diff --git a/WebCore/loader/FrameLoader.h b/WebCore/loader/FrameLoader.h
index 5a8ee91..3d3f9c3 100644
--- a/WebCore/loader/FrameLoader.h
+++ b/WebCore/loader/FrameLoader.h
@@ -501,10 +501,17 @@ namespace WebCore {
void loadWithNavigationAction(const ResourceRequest&, const NavigationAction&, // Calls loadWithDocumentLoader
bool lockHistory, FrameLoadType, PassRefPtr<FormState>);
+#ifdef ANDROID_USER_GESTURE
+ void loadPostRequest(const ResourceRequest&, const String& referrer, // Called by loadFrameRequest, calls loadWithNavigationAction
+ const String& frameName, bool lockHistory, FrameLoadType, PassRefPtr<Event>, PassRefPtr<FormState>, bool);
+ void loadURL(const KURL&, const String& referrer, const String& frameName, // Called by loadFrameRequest, calls loadWithNavigationAction or dispatches to navigation policy delegate
+ bool lockHistory, FrameLoadType, PassRefPtr<Event>, PassRefPtr<FormState>, bool);
+#else
void loadPostRequest(const ResourceRequest&, const String& referrer, // Called by loadFrameRequest, calls loadWithNavigationAction
const String& frameName, bool lockHistory, FrameLoadType, PassRefPtr<Event>, PassRefPtr<FormState>);
void loadURL(const KURL&, const String& referrer, const String& frameName, // Called by loadFrameRequest, calls loadWithNavigationAction or dispatches to navigation policy delegate
bool lockHistory, FrameLoadType, PassRefPtr<Event>, PassRefPtr<FormState>);
+#endif
void clientRedirectCancelledOrFinished(bool cancelWithLoadInProgress);
void clientRedirected(const KURL&, double delay, double fireDate, bool lockBackForwardList);
diff --git a/WebCore/platform/network/android/ResourceRequest.h b/WebCore/platform/network/android/ResourceRequest.h
index 22c8104..4e9a977 100644
--- a/WebCore/platform/network/android/ResourceRequest.h
+++ b/WebCore/platform/network/android/ResourceRequest.h
@@ -37,29 +37,36 @@ namespace WebCore {
ResourceRequest(const String& url)
: ResourceRequestBase(KURL(url), UseProtocolCachePolicy)
+ , m_userGesture(true)
{
}
ResourceRequest(const KURL& url)
: ResourceRequestBase(url, UseProtocolCachePolicy)
+ , m_userGesture(true)
{
}
ResourceRequest(const KURL& url, const String& referrer, ResourceRequestCachePolicy policy = UseProtocolCachePolicy)
: ResourceRequestBase(url, policy)
+ , m_userGesture(true)
{
setHTTPReferrer(referrer);
}
ResourceRequest()
: ResourceRequestBase(KURL(), UseProtocolCachePolicy)
+ , m_userGesture(true)
{
}
void doUpdatePlatformRequest() {}
void doUpdateResourceRequest() {}
+ void setUserGesture(bool userGesture) { m_userGesture = userGesture; }
+ bool getUserGesture() const { return m_userGesture; }
private:
friend class ResourceRequestBase;
+ bool m_userGesture;
};
} // namespace WebCore
diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp
index 2d5c3f0..bb59b73 100644
--- a/WebKit/android/jni/WebCoreFrameBridge.cpp
+++ b/WebKit/android/jni/WebCoreFrameBridge.cpp
@@ -634,7 +634,7 @@ WebFrame::canHandleRequest(const WebCore::ResourceRequest& request)
if (equalIgnoringCase(request.httpMethod(), "POST"))
return true;
WebCore::KURL requestUrl = request.url();
- if (!mUserInitiatedClick &&
+ if (!mUserInitiatedClick && !request.getUserGesture() &&
(requestUrl.protocolIs("http") || requestUrl.protocolIs("https") ||
requestUrl.protocolIs("file") || requestUrl.protocolIs("about") ||
requestUrl.protocolIs("javascript")))