Commit e2df8d38 authored by Tim Volodine's avatar Tim Volodine Committed by Commit Bot

[Android WebView] Implement onReceivedLoginRequest callback (NS code path)

Implement the WebViewClient.onReceivedLoginRequest callback for Android
WebView in the Network Service enabled case. This patch makes sure the
header is properly parsed and the callback executed. Also updates the
test filter with the tests fixed by this patch.

Tests fixed:
-org.chromium.android_webview.test.AwContentsClientAutoLoginTest.testAutoLoginOnGoogleCom
-org.chromium.android_webview.test.AwContentsClientAutoLoginTest.testAutoLoginOnNonGoogle
-org.chromium.android_webview.test.AwContentsClientAutoLoginTest.testAutoLoginWithNullAccount

BUG=893562,841556

Change-Id: I91bfb1e3d9ffb8783cc0952e0498f2e428976a7e
Reviewed-on: https://chromium-review.googlesource.com/c/1292052
Commit-Queue: Tim Volodine <timvolodine@chromium.org>
Reviewed-by: default avatarClark DuVall <cduvall@chromium.org>
Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603070}
parent afe862d3
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <utility> #include <utility>
#include "android_webview/browser/aw_contents_client_bridge.h" #include "android_webview/browser/aw_contents_client_bridge.h"
#include "android_webview/browser/renderer_host/auto_login_parser.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
...@@ -21,6 +22,8 @@ namespace android_webview { ...@@ -21,6 +22,8 @@ namespace android_webview {
namespace { namespace {
const char kAutoLoginHeaderName[] = "X-Auto-Login";
// Handles intercepted, in-progress requests/responses, so that they can be // Handles intercepted, in-progress requests/responses, so that they can be
// controlled and modified accordingly. // controlled and modified accordingly.
class InterceptedRequest : public network::mojom::URLLoader, class InterceptedRequest : public network::mojom::URLLoader,
...@@ -173,6 +176,18 @@ void OnReceivedErrorOnUiThread(int process_id, ...@@ -173,6 +176,18 @@ void OnReceivedErrorOnUiThread(int process_id,
client->OnReceivedError(request, error_code, false /*safebrowsing_hit*/); client->OnReceivedError(request, error_code, false /*safebrowsing_hit*/);
} }
void OnNewLoginRequestOnUiThread(int process_id,
int render_frame_id,
const std::string& realm,
const std::string& account,
const std::string& args) {
auto* client = GetAwContentsClientBridgeFromID(process_id, render_frame_id);
if (!client) {
return;
}
client->NewLoginRequest(realm, account, args);
}
} // namespace } // namespace
// URLLoaderClient methods. // URLLoaderClient methods.
...@@ -201,6 +216,24 @@ void InterceptedRequest::OnReceiveResponse( ...@@ -201,6 +216,24 @@ void InterceptedRequest::OnReceiveResponse(
std::move(error_info))); std::move(error_info)));
} }
if (request_.resource_type == content::RESOURCE_TYPE_MAIN_FRAME) {
// Check for x-auto-login-header
HeaderData header_data;
std::string header_string;
if (head.headers->GetNormalizedHeader(kAutoLoginHeaderName,
&header_string)) {
if (ParseHeader(header_string, ALLOW_ANY_REALM, &header_data)) {
// TODO(timvolodine): consider simplifying this and above callback
// code, crbug.com/897149.
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&OnNewLoginRequestOnUiThread, process_id_,
request_.render_frame_id, header_data.realm,
header_data.account, header_data.args));
}
}
}
target_client_->OnReceiveResponse(head); target_client_->OnReceiveResponse(head);
} }
......
...@@ -16,11 +16,6 @@ ...@@ -16,11 +16,6 @@
# https://crbug.com/893561 # https://crbug.com/893561
-org.chromium.android_webview.test.AcceptLanguageTest.testAcceptLanguage -org.chromium.android_webview.test.AcceptLanguageTest.testAcceptLanguage
# https://crbug.com/893562
-org.chromium.android_webview.test.AwContentsClientAutoLoginTest.testAutoLoginOnGoogleCom
-org.chromium.android_webview.test.AwContentsClientAutoLoginTest.testAutoLoginOnNonGoogle
-org.chromium.android_webview.test.AwContentsClientAutoLoginTest.testAutoLoginWithNullAccount
# https://crbug.com/893563 # https://crbug.com/893563
-org.chromium.android_webview.test.AwContentsClientFullScreenTest.testExitFullscreenEndsIfAppInvokesCallbackFromOnHideCustomView -org.chromium.android_webview.test.AwContentsClientFullScreenTest.testExitFullscreenEndsIfAppInvokesCallbackFromOnHideCustomView
-org.chromium.android_webview.test.AwContentsClientFullScreenTest.testFullscreenForNonVideoElementIsSupportedInSoftwareMode -org.chromium.android_webview.test.AwContentsClientFullScreenTest.testFullscreenForNonVideoElementIsSupportedInSoftwareMode
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment