diff options
-rw-r--r-- | WebCore/config.h | 6 | ||||
-rw-r--r-- | WebCore/loader/EmptyClients.h | 4 | ||||
-rw-r--r-- | WebCore/loader/FrameLoader.cpp | 41 | ||||
-rw-r--r-- | WebCore/loader/FrameLoader.h | 7 | ||||
-rw-r--r-- | WebCore/loader/RedirectScheduler.cpp | 3 | ||||
-rw-r--r-- | WebCore/page/Chrome.cpp | 7 | ||||
-rw-r--r-- | WebCore/page/Chrome.h | 4 | ||||
-rw-r--r-- | WebCore/page/ChromeClient.h | 4 | ||||
-rw-r--r-- | WebCore/page/DOMWindow.cpp | 4 | ||||
-rw-r--r-- | WebCore/platform/network/android/ResourceRequest.h | 11 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp | 19 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/ChromeClientAndroid.h | 4 | ||||
-rw-r--r-- | WebKit/android/jni/WebCoreFrameBridge.cpp | 17 |
13 files changed, 29 insertions, 102 deletions
diff --git a/WebCore/config.h b/WebCore/config.h index c198305..8af4fe9 100644 --- a/WebCore/config.h +++ b/WebCore/config.h @@ -194,10 +194,8 @@ // 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 +// Checking if an action is user initiated or not +#define ANDROID_USER_GESTURE_CHECK // Enable prefetching when specified via the rel element of <link> elements. #define ENABLE_LINK_PREFETCH 1 diff --git a/WebCore/loader/EmptyClients.h b/WebCore/loader/EmptyClients.h index 703ee0c..869de22 100644 --- a/WebCore/loader/EmptyClients.h +++ b/WebCore/loader/EmptyClients.h @@ -72,11 +72,7 @@ public: virtual void webAppCanBeInstalled() { } #endif -#ifdef ANDROID_USER_GESTURE - virtual void focus(bool userGesture) { } -#else virtual void focus() { } -#endif virtual void unfocus() { } virtual bool canTakeFocus(FocusDirection) { return false; } diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp index 540e0f7..bdf7298 100644 --- a/WebCore/loader/FrameLoader.cpp +++ b/WebCore/loader/FrameLoader.cpp @@ -281,11 +281,7 @@ Frame* FrameLoader::createWindow(FrameLoader* frameLoaderForFrameLookup, const F if (!request.resourceRequest().url().isEmpty()) frame->loader()->loadFrameRequest(request, false, false, 0, 0, SendReferrer); if (Page* page = frame->page()) -#ifdef ANDROID_USER_GESTURE - page->chrome()->focus(isProcessingUserGesture()); -#else page->chrome()->focus(); -#endif created = false; return frame; } @@ -350,9 +346,6 @@ 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 urlSelected(request, "_self", 0, lockHistory, lockBackForwardList, userGesture, SendReferrer, ReplaceDocumentIfJavaScriptURL); } @@ -1019,11 +1012,7 @@ 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, false); -#else childFrame->loader()->loadURL(workingURL, referer, String(), false, childLoadType, 0, 0); -#endif } #if ENABLE(ARCHIVE) // ANDROID extension: disabled to reduce code size @@ -1372,17 +1361,10 @@ 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. @@ -1390,29 +1372,17 @@ void FrameLoader::loadFrameRequest(const FrameLoadRequest& request, bool lockHis Frame* targetFrame = sourceFrame->loader()->findFrameForNavigation(request.frameName()); if (targetFrame && targetFrame != sourceFrame) { if (Page* page = targetFrame->page()) -#ifdef ANDROID_USER_GESTURE - page->chrome()->focus(request.resourceRequest().getUserGesture()); -#else page->chrome()->focus(); -#endif } } -#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); @@ -1427,11 +1397,7 @@ 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; } @@ -2807,11 +2773,7 @@ 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; @@ -2831,9 +2793,6 @@ 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 b361b51..e157850 100644 --- a/WebCore/loader/FrameLoader.h +++ b/WebCore/loader/FrameLoader.h @@ -404,17 +404,10 @@ private: 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 bool shouldReload(const KURL& currentURL, const KURL& destinationURL); diff --git a/WebCore/loader/RedirectScheduler.cpp b/WebCore/loader/RedirectScheduler.cpp index 4fda8fe..3cfe61a 100644 --- a/WebCore/loader/RedirectScheduler.cpp +++ b/WebCore/loader/RedirectScheduler.cpp @@ -191,9 +191,6 @@ public: if (!m_submission->state()->sourceFrame()->loader()->shouldAllowNavigation(frame)) return; FrameLoadRequest frameRequest; -#ifdef ANDROID_USER_GESTURE - frameRequest.resourceRequest().setUserGesture(m_submission->state()->sourceFrame()->loader()->isProcessingUserGesture()); -#endif m_submission->populateFrameLoadRequest(frameRequest); frame->loader()->loadFrameRequest(frameRequest, lockHistory(), lockBackForwardList(), m_submission->event(), m_submission->state(), SendReferrer); } diff --git a/WebCore/page/Chrome.cpp b/WebCore/page/Chrome.cpp index 799aaee..0124211 100644 --- a/WebCore/page/Chrome.cpp +++ b/WebCore/page/Chrome.cpp @@ -138,17 +138,10 @@ float Chrome::scaleFactor() return m_client->scaleFactor(); } -#ifdef ANDROID_USER_GESTURE -void Chrome::focus(bool userGesture) const -{ - m_client->focus(userGesture); -} -#else void Chrome::focus() const { m_client->focus(); } -#endif void Chrome::unfocus() const { diff --git a/WebCore/page/Chrome.h b/WebCore/page/Chrome.h index 3882f5e..88035a5 100644 --- a/WebCore/page/Chrome.h +++ b/WebCore/page/Chrome.h @@ -81,11 +81,7 @@ namespace WebCore { float scaleFactor(); -#ifdef ANDROID_USER_GESTURE - void focus(bool userGesture) const; -#else void focus() const; -#endif void unfocus() const; bool canTakeFocus(FocusDirection) const; diff --git a/WebCore/page/ChromeClient.h b/WebCore/page/ChromeClient.h index 660ec68..64b9f26 100644 --- a/WebCore/page/ChromeClient.h +++ b/WebCore/page/ChromeClient.h @@ -79,11 +79,7 @@ namespace WebCore { virtual float scaleFactor() = 0; -#ifdef ANDROID_USER_GESTURE - virtual void focus(bool userGesture) = 0; -#else virtual void focus() = 0; -#endif virtual void unfocus() = 0; virtual bool canTakeFocus(FocusDirection) = 0; diff --git a/WebCore/page/DOMWindow.cpp b/WebCore/page/DOMWindow.cpp index f050a80..6ecde3c 100644 --- a/WebCore/page/DOMWindow.cpp +++ b/WebCore/page/DOMWindow.cpp @@ -779,11 +779,7 @@ void DOMWindow::focus() // If we're a top level window, bring the window to the front. if (m_frame == page->mainFrame()) -#ifdef ANDROID_USER_GESTURE - page->chrome()->focus(m_frame->loader()->isProcessingUserGesture()); -#else page->chrome()->focus(); -#endif if (!m_frame) return; diff --git a/WebCore/platform/network/android/ResourceRequest.h b/WebCore/platform/network/android/ResourceRequest.h index 3102ff1..1edd4bf 100644 --- a/WebCore/platform/network/android/ResourceRequest.h +++ b/WebCore/platform/network/android/ResourceRequest.h @@ -36,26 +36,23 @@ namespace WebCore { class ResourceRequest : public ResourceRequestBase { public: ResourceRequest(const String& url) - : ResourceRequestBase(KURL(ParsedURLString, url), UseProtocolCachePolicy), m_userGesture(true) { } + : ResourceRequestBase(KURL(ParsedURLString, url), UseProtocolCachePolicy) { } - ResourceRequest(const KURL& url) : ResourceRequestBase(url, UseProtocolCachePolicy) , m_userGesture(true) { } + ResourceRequest(const KURL& url) : ResourceRequestBase(url, UseProtocolCachePolicy) { } ResourceRequest(const KURL& url, const String& referrer, ResourceRequestCachePolicy policy = UseProtocolCachePolicy) - : ResourceRequestBase(url, policy) , m_userGesture(true) + : ResourceRequestBase(url, policy) { setHTTPReferrer(referrer); } - ResourceRequest() : ResourceRequestBase(KURL(), UseProtocolCachePolicy), m_userGesture(true) { } + ResourceRequest() : ResourceRequestBase(KURL(), UseProtocolCachePolicy) { } 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/WebCoreSupport/ChromeClientAndroid.cpp b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp index 30ac36c..af74638 100644 --- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp +++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp @@ -46,6 +46,7 @@ #include "WebViewCore.h" #include "WindowFeatures.h" #include "Settings.h" +#include "UserGestureIndicator.h" #include <wtf/text/CString.h> namespace android { @@ -123,18 +124,16 @@ float ChromeClientAndroid::scaleFactor() return m_webFrame->density(); } -#ifdef ANDROID_USER_GESTURE -void ChromeClientAndroid::focus(bool userGesture) { +void ChromeClientAndroid::focus() +{ + ASSERT(m_webFrame); +#ifdef ANDROID_USER_GESTURE_CHECK + bool isUserGesture = UserGestureIndicator::processingUserGesture(); #else -void ChromeClientAndroid::focus() { - // The old behavior was to always allow javascript to focus a window. If we - // turn off ANDROID_USER_GESTURE, go back to the old behavior by forcing - // userGesture to be true. - bool userGesture = true; + bool isUserGesture = true; #endif - ASSERT(m_webFrame); - // Ask the application to focus this WebView. - if (userGesture) + // Ask the application to focus this WebView if the action is intiated by the user + if (isUserGesture) m_webFrame->requestFocus(); } void ChromeClientAndroid::unfocus() { notImplemented(); } diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h index a1f097c..b3b9335 100644 --- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h +++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h @@ -59,11 +59,7 @@ namespace android { virtual float scaleFactor(); -#ifdef ANDROID_USER_GESTURE - virtual void focus(bool userGesture); -#else virtual void focus(); -#endif virtual void unfocus(); virtual bool canTakeFocus(FocusDirection); diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp index bfd4b62..7324173 100644 --- a/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -75,6 +75,7 @@ #include "Settings.h" #include "StringBuilder.h" #include "SubstituteData.h" +#include "UserGestureIndicator.h" #include "WebCoreJni.h" #include "WebCoreResourceLoader.h" #include "WebHistory.h" @@ -481,11 +482,16 @@ WebFrame::startLoadingResource(WebCore::ResourceHandle* loader, jstring jPasswordString = loaderInternal->m_pass.isEmpty() ? NULL : env->NewString(loaderInternal->m_pass.characters(), loaderInternal->m_pass.length()); +#ifdef ANDROID_USER_GESTURE_CHECK + bool isUserGesture = UserGestureIndicator::processingUserGesture(); +#else + bool isUserGesture = true; +#endif jobject jLoadListener = env->CallObjectMethod(obj.get(), mJavaFrame->mStartLoadingResource, (int)loader, jUrlStr, jMethodStr, jHeaderMap, jPostDataStr, formdata ? formdata->identifier(): 0, - cacheMode, mainResource, request.getUserGesture(), + cacheMode, mainResource, isUserGesture, synchronous, jUsernameString, jPasswordString); env->DeleteLocalRef(jUrlStr); @@ -750,8 +756,13 @@ WebFrame::canHandleRequest(const WebCore::ResourceRequest& request) if (equalIgnoringCase(request.httpMethod(), "POST")) return true; WebCore::KURL requestUrl = request.url(); - if (!mUserInitiatedClick && !request.getUserGesture() && - (requestUrl.protocolIs("http") || requestUrl.protocolIs("https") || +#ifdef ANDROID_USER_GESTURE_CHECK + bool isUserGesture = UserGestureIndicator::processingUserGesture(); +#else + bool isUserGesture = true; +#endif + if (!mUserInitiatedClick && !isUserGesture && + (requestUrl.protocolIs("http") || requestUrl.protocolIs("https") || requestUrl.protocolIs("file") || requestUrl.protocolIs("about") || WebCore::protocolIsJavaScript(requestUrl.string()))) return true; |