Commit ac5e3628 authored by Robbie McElrath's avatar Robbie McElrath Committed by Commit Bot

Make ExistingUserController work with the network service enabled.

Bug: 838942
Change-Id: Ibb116e15580dace63bb271af04e983d37db56167
Reviewed-on: https://chromium-review.googlesource.com/c/1371208
Commit-Queue: Robbie McElrath <rmcelrath@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615779}
parent e94e5ba0
......@@ -8,6 +8,7 @@
#include <utility>
#include <vector>
#include "base/barrier_closure.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/callback.h"
......@@ -103,6 +104,7 @@
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/views/widget/widget.h"
......@@ -141,36 +143,7 @@ void RefreshPoliciesOnUIThread() {
g_browser_process->policy_service()->RefreshPolicies(base::Closure());
}
// Copies any authentication details that were entered in the login profile to
// the main profile to make sure all subsystems of Chrome can access the network
// with the provided authentication which are possibly for a proxy server.
void TransferContextAuthenticationsOnIOThread(
net::URLRequestContextGetter* default_profile_context_getter,
net::URLRequestContextGetter* webview_context_getter,
net::URLRequestContextGetter* browser_process_context_getter) {
net::HttpAuthCache* new_cache =
browser_process_context_getter->GetURLRequestContext()
->http_transaction_factory()
->GetSession()
->http_auth_cache();
net::HttpAuthCache* old_cache =
default_profile_context_getter->GetURLRequestContext()
->http_transaction_factory()
->GetSession()
->http_auth_cache();
new_cache->UpdateAllFrom(*old_cache);
// Copy the auth cache from webview's context since the proxy authentication
// information is saved in webview's context.
if (webview_context_getter) {
net::HttpAuthCache* webview_cache =
webview_context_getter->GetURLRequestContext()
->http_transaction_factory()
->GetSession()
->http_auth_cache();
new_cache->UpdateAllFrom(*webview_cache);
}
void OnTranferredHttpAuthCaches() {
VLOG(1) << "Main request context populated with authentication data.";
// Last but not least tell the policy subsystem to refresh now as it might
// have been stuck until now too.
......@@ -178,6 +151,37 @@ void TransferContextAuthenticationsOnIOThread(
base::BindOnce(&RefreshPoliciesOnUIThread));
}
void TransferHttpAuthCacheToSystemNetworkContext(
base::RepeatingClosure completion_callback,
const base::UnguessableToken& cache_key) {
network::mojom::NetworkContext* system_network_context =
g_browser_process->system_network_context_manager()->GetContext();
system_network_context->LoadHttpAuthCache(cache_key, completion_callback);
}
// Copies any authentication details that were entered in the login profile to
// the main profile to make sure all subsystems of Chrome can access the network
// with the provided authentication which are possibly for a proxy server.
void TransferHttpAuthCaches() {
content::StoragePartition* webview_storage_partition =
login::GetSigninPartition();
base::RepeatingClosure completion_callback =
base::BarrierClosure(webview_storage_partition ? 2 : 1,
base::BindOnce(&OnTranferredHttpAuthCaches));
if (webview_storage_partition) {
webview_storage_partition->GetNetworkContext()->SaveHttpAuthCache(
base::BindOnce(&TransferHttpAuthCacheToSystemNetworkContext,
completion_callback));
}
network::mojom::NetworkContext* default_network_context =
content::BrowserContext::GetDefaultStoragePartition(
ProfileHelper::GetSigninProfile())
->GetNetworkContext();
default_network_context->SaveHttpAuthCache(base::BindOnce(
&TransferHttpAuthCacheToSystemNetworkContext, completion_callback));
}
// Record UMA for password login of regular user when Easy sign-in is enabled.
void RecordPasswordLoginEvent(const UserContext& user_context) {
EasyUnlockService* easy_unlock_service =
......@@ -460,27 +464,8 @@ void ExistingUserController::Observe(
// has been updated before we copy it.
// TODO(pmarko): Find a better way to do this, see https://crbug.com/796512.
VLOG(1) << "Authentication was entered manually, possibly for proxyauth.";
scoped_refptr<net::URLRequestContextGetter> browser_process_context_getter =
g_browser_process->system_request_context();
Profile* signin_profile = ProfileHelper::GetSigninProfile();
scoped_refptr<net::URLRequestContextGetter> signin_profile_context_getter =
signin_profile->GetRequestContext();
DCHECK(browser_process_context_getter.get());
DCHECK(signin_profile_context_getter.get());
content::StoragePartition* signin_partition = login::GetSigninPartition();
scoped_refptr<net::URLRequestContextGetter> webview_context_getter;
if (signin_partition) {
webview_context_getter = signin_partition->GetURLRequestContext();
DCHECK(webview_context_getter.get());
}
base::PostDelayedTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&TransferContextAuthenticationsOnIOThread,
base::RetainedRef(signin_profile_context_getter),
base::RetainedRef(webview_context_getter),
base::RetainedRef(browser_process_context_getter)),
base::PostDelayedTask(
FROM_HERE, base::BindOnce(&TransferHttpAuthCaches),
base::TimeDelta::FromMilliseconds(kAuthCacheTransferDelayMs));
}
}
......
......@@ -19,7 +19,6 @@
-DownloadNotificationTest.InterruptDownloadAfterClosingNotification
-DownloadNotificationTest.SimultaneousIncognitoAndNormalDownloads
-MultiProfileDownloadNotificationTest.DownloadMultipleFiles
-OobeTest.NewUser
# NOTE: if adding an exclusion for an existing failure (e.g. additional test for
# feature X that is already not working), please add it beside the existing
......
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