From 6a6881a3ff408ab630684ae1779f12b83a024044 Mon Sep 17 00:00:00 2001 From: Steve Block Date: Wed, 24 Mar 2010 16:27:17 +0000 Subject: Fixes XHR requests to use the username and password supplied from JavaScript Currently, the browser does not use the credentials supplied from JavaScript. If a request returns a 401 Unauthorized, the browser always prompts the user. This violates http://www.w3.org/TR/XMLHttpRequest/#the-send-method Bug: 2533522 Change-Id: Ic232003a3f321167810fc7263d6ecb654eeeb5eb --- WebKit/android/jni/WebCoreFrameBridge.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'WebKit') diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp index ff7e868..250ffc9 100644 --- a/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -68,6 +68,7 @@ #include "RenderTreeAsText.h" #include "RenderView.h" #include "ResourceHandle.h" +#include "ResourceHandleInternal.h" #include "ScriptController.h" #include "ScriptValue.h" #include "SecurityOrigin.h" @@ -209,7 +210,7 @@ WebFrame::WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page* mJavaFrame->mObj = env->NewWeakGlobalRef(obj); mJavaFrame->mHistoryList = env->NewWeakGlobalRef(historyList); mJavaFrame->mStartLoadingResource = env->GetMethodID(clazz, "startLoadingResource", - "(ILjava/lang/String;Ljava/lang/String;Ljava/util/HashMap;[BJIZZZ)Landroid/webkit/LoadListener;"); + "(ILjava/lang/String;Ljava/lang/String;Ljava/util/HashMap;[BJIZZZLjava/lang/String;Ljava/lang/String;)Landroid/webkit/LoadListener;"); mJavaFrame->mLoadStarted = env->GetMethodID(clazz, "loadStarted", "(Ljava/lang/String;Landroid/graphics/Bitmap;IZ)V"); mJavaFrame->mTransitionToCommitted = env->GetMethodID(clazz, "transitionToCommitted", @@ -475,18 +476,25 @@ WebFrame::startLoadingResource(WebCore::ResourceHandle* loader, LOGV("::WebCore:: startLoadingResource %s with cacheMode %d", urlStr.ascii().data(), cacheMode); + ResourceHandleInternal* loaderInternal = loader->getInternal(); + jstring jUsernameString = loaderInternal->m_user.isEmpty() ? + NULL : env->NewString(loaderInternal->m_user.characters(), loaderInternal->m_user.length()); + jstring jPasswordString = loaderInternal->m_pass.isEmpty() ? + NULL : env->NewString(loaderInternal->m_pass.characters(), loaderInternal->m_pass.length()); jobject jLoadListener = env->CallObjectMethod(obj.get(), mJavaFrame->mStartLoadingResource, (int)loader, jUrlStr, jMethodStr, jHeaderMap, jPostDataStr, formdata ? formdata->identifier(): 0, cacheMode, mainResource, request.getUserGesture(), - synchronous); + synchronous, jUsernameString, jPasswordString); env->DeleteLocalRef(jUrlStr); env->DeleteLocalRef(jMethodStr); env->DeleteLocalRef(jPostDataStr); env->DeleteLocalRef(jHeaderMap); + env->DeleteLocalRef(jUsernameString); + env->DeleteLocalRef(jPasswordString); if (checkException(env)) return NULL; -- cgit v1.1