Commit dbe36faa authored by Reilly Grant's avatar Reilly Grant Committed by Commit Bot

Express ProfileAuthData::Transfer() in terms of storage partitions

With the network service we are deprecating the concept of a
net::URLRequestContextGetter. A content::StoragePartition (which owns a
network::mojom::NetworkContext) is the right layer of abstraction for
expressing what this function operates on.

Bug: 792678
Change-Id: I22caa1f85357c2b482f6973365d52bcfa59d02d5
Reviewed-on: https://chromium-review.googlesource.com/c/1257896Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596223}
parent cda09123
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "net/cookies/canonical_cookie.h" #include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_store.h" #include "net/cookies/cookie_store.h"
#include "net/http/http_auth_cache.h" #include "net/http/http_auth_cache.h"
...@@ -59,8 +60,8 @@ void ImportCookies(const net::CookieList& cookies, ...@@ -59,8 +60,8 @@ void ImportCookies(const net::CookieList& cookies,
class ProfileAuthDataTransferer { class ProfileAuthDataTransferer {
public: public:
ProfileAuthDataTransferer( ProfileAuthDataTransferer(
net::URLRequestContextGetter* from_context, content::StoragePartition* from_partition,
net::URLRequestContextGetter* to_context, content::StoragePartition* to_partition,
bool transfer_auth_cookies_and_channel_ids_on_first_login, bool transfer_auth_cookies_and_channel_ids_on_first_login,
bool transfer_saml_auth_cookies_on_subsequent_login, bool transfer_saml_auth_cookies_on_subsequent_login,
const base::Closure& completion_callback); const base::Closure& completion_callback);
...@@ -138,13 +139,13 @@ class ProfileAuthDataTransferer { ...@@ -138,13 +139,13 @@ class ProfileAuthDataTransferer {
}; };
ProfileAuthDataTransferer::ProfileAuthDataTransferer( ProfileAuthDataTransferer::ProfileAuthDataTransferer(
net::URLRequestContextGetter* from_context, content::StoragePartition* from_partition,
net::URLRequestContextGetter* to_context, content::StoragePartition* to_partition,
bool transfer_auth_cookies_and_channel_ids_on_first_login, bool transfer_auth_cookies_and_channel_ids_on_first_login,
bool transfer_saml_auth_cookies_on_subsequent_login, bool transfer_saml_auth_cookies_on_subsequent_login,
const base::Closure& completion_callback) const base::Closure& completion_callback)
: from_context_(from_context), : from_context_(from_partition->GetURLRequestContext()),
to_context_(to_context), to_context_(to_partition->GetURLRequestContext()),
transfer_auth_cookies_and_channel_ids_on_first_login_( transfer_auth_cookies_and_channel_ids_on_first_login_(
transfer_auth_cookies_and_channel_ids_on_first_login), transfer_auth_cookies_and_channel_ids_on_first_login),
transfer_saml_auth_cookies_on_subsequent_login_( transfer_saml_auth_cookies_on_subsequent_login_(
...@@ -332,14 +333,14 @@ void ProfileAuthDataTransferer::Finish() { ...@@ -332,14 +333,14 @@ void ProfileAuthDataTransferer::Finish() {
} // namespace } // namespace
void ProfileAuthData::Transfer( void ProfileAuthData::Transfer(
net::URLRequestContextGetter* from_context, content::StoragePartition* from_partition,
net::URLRequestContextGetter* to_context, content::StoragePartition* to_partition,
bool transfer_auth_cookies_and_channel_ids_on_first_login, bool transfer_auth_cookies_and_channel_ids_on_first_login,
bool transfer_saml_auth_cookies_on_subsequent_login, bool transfer_saml_auth_cookies_on_subsequent_login,
const base::Closure& completion_callback) { const base::Closure& completion_callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
(new ProfileAuthDataTransferer( (new ProfileAuthDataTransferer(
from_context, to_context, from_partition, to_partition,
transfer_auth_cookies_and_channel_ids_on_first_login, transfer_auth_cookies_and_channel_ids_on_first_login,
transfer_saml_auth_cookies_on_subsequent_login, completion_callback)) transfer_saml_auth_cookies_on_subsequent_login, completion_callback))
->BeginTransfer(); ->BeginTransfer();
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
#include "base/callback_forward.h" #include "base/callback_forward.h"
#include "base/macros.h" #include "base/macros.h"
namespace net { namespace content {
class URLRequestContextGetter; class StoragePartition;
} }
namespace chromeos { namespace chromeos {
...@@ -18,21 +18,21 @@ namespace chromeos { ...@@ -18,21 +18,21 @@ namespace chromeos {
// used for authentication to the user's actual BrowserContext. // used for authentication to the user's actual BrowserContext.
class ProfileAuthData { class ProfileAuthData {
public: public:
// Transfers authentication-related data from |from_context| to |to_context| // Transfers authentication-related data from |from_partition| to
// and invokes |completion_callback| on the UI thread when the operation has // |to_partition| and invokes |completion_callback| on the UI thread when the
// completed. The following data is transferred: // operation has completed. The following data is transferred:
// * The proxy authentication state. // * The proxy authentication state.
// * All authentication cookies and channel IDs, if // * All authentication cookies and channel IDs, if
// |transfer_auth_cookies_and_channel_ids_on_first_login| is true and // |transfer_auth_cookies_and_channel_ids_on_first_login| is true and
// |to_context|'s cookie jar is empty. If the cookie jar is not empty, the // |to_partition|'s cookie jar is empty. If the cookie jar is not empty, the
// authentication states in |from_context| and |to_context| should be merged // authentication states in |from_partition| and |to_partition| should be
// using /MergeSession instead. // merged using /MergeSession instead.
// * The authentication cookies set by a SAML IdP, if // * The authentication cookies set by a SAML IdP, if
// |transfer_saml_auth_cookies_on_subsequent_login| is true and // |transfer_saml_auth_cookies_on_subsequent_login| is true and
// |to_context|'s cookie jar is not empty. // |to_partition|'s cookie jar is not empty.
static void Transfer( static void Transfer(
net::URLRequestContextGetter* from_context, content::StoragePartition* from_partition,
net::URLRequestContextGetter* to_context, content::StoragePartition* to_partition,
bool transfer_auth_cookies_and_channel_ids_on_first_login, bool transfer_auth_cookies_and_channel_ids_on_first_login,
bool transfer_saml_auth_cookies_on_subsequent_login, bool transfer_saml_auth_cookies_on_subsequent_login,
const base::Closure& completion_callback); const base::Closure& completion_callback);
......
...@@ -125,8 +125,10 @@ void ProfileAuthDataTest::Transfer( ...@@ -125,8 +125,10 @@ void ProfileAuthDataTest::Transfer(
bool transfer_saml_auth_cookies_on_subsequent_login) { bool transfer_saml_auth_cookies_on_subsequent_login) {
base::RunLoop run_loop; base::RunLoop run_loop;
ProfileAuthData::Transfer( ProfileAuthData::Transfer(
login_browser_context_.GetRequestContext(), content::BrowserContext::GetDefaultStoragePartition(
user_browser_context_.GetRequestContext(), &login_browser_context_),
content::BrowserContext::GetDefaultStoragePartition(
&user_browser_context_),
transfer_auth_cookies_and_channel_ids_on_first_login, transfer_auth_cookies_and_channel_ids_on_first_login,
transfer_saml_auth_cookies_on_subsequent_login, run_loop.QuitClosure()); transfer_saml_auth_cookies_on_subsequent_login, run_loop.QuitClosure());
run_loop.Run(); run_loop.Run();
......
...@@ -1317,14 +1317,14 @@ void UserSessionManager::UserProfileInitialized(Profile* profile, ...@@ -1317,14 +1317,14 @@ void UserSessionManager::UserProfileInitialized(Profile* profile,
const bool transfer_auth_cookies_and_channel_ids_on_first_login = const bool transfer_auth_cookies_and_channel_ids_on_first_login =
has_auth_cookies_; has_auth_cookies_;
net::URLRequestContextGetter* auth_request_context = content::StoragePartition* signin_partition = login::GetSigninPartition();
GetAuthRequestContext();
// Authentication request context may be missing especially if user didn't // Authentication request context may be missing especially if user didn't
// sign in using GAIA (webview) and webview didn't yet initialize. // sign in using GAIA (webview) and webview didn't yet initialize.
if (auth_request_context) { if (signin_partition) {
ProfileAuthData::Transfer( ProfileAuthData::Transfer(
auth_request_context, profile->GetRequestContext(), signin_partition,
content::BrowserContext::GetDefaultStoragePartition(profile),
transfer_auth_cookies_and_channel_ids_on_first_login, transfer_auth_cookies_and_channel_ids_on_first_login,
transfer_saml_auth_cookies_on_subsequent_login, transfer_saml_auth_cookies_on_subsequent_login,
base::Bind( base::Bind(
...@@ -1881,15 +1881,6 @@ void UserSessionManager::UpdateEasyUnlockKeys(const UserContext& user_context) { ...@@ -1881,15 +1881,6 @@ void UserSessionManager::UpdateEasyUnlockKeys(const UserContext& user_context) {
user_context.GetAccountId().GetUserEmail())); user_context.GetAccountId().GetUserEmail()));
} }
net::URLRequestContextGetter* UserSessionManager::GetAuthRequestContext()
const {
content::StoragePartition* signin_partition = login::GetSigninPartition();
if (!signin_partition)
return nullptr;
return signin_partition->GetURLRequestContext();
}
scoped_refptr<network::SharedURLLoaderFactory> scoped_refptr<network::SharedURLLoaderFactory>
UserSessionManager::GetAuthURLLoaderFactory() const { UserSessionManager::GetAuthURLLoaderFactory() const {
content::StoragePartition* signin_partition = login::GetSigninPartition(); content::StoragePartition* signin_partition = login::GetSigninPartition();
......
...@@ -48,10 +48,6 @@ namespace base { ...@@ -48,10 +48,6 @@ namespace base {
class CommandLine; class CommandLine;
} }
namespace net {
class URLRequestContextGetter;
}
namespace network { namespace network {
class SharedURLLoaderFactory; class SharedURLLoaderFactory;
} }
...@@ -288,7 +284,6 @@ class UserSessionManager ...@@ -288,7 +284,6 @@ class UserSessionManager
// Returns the auth request context/URLLoaderFactory associated with auth // Returns the auth request context/URLLoaderFactory associated with auth
// data. // data.
net::URLRequestContextGetter* GetAuthRequestContext() const;
scoped_refptr<network::SharedURLLoaderFactory> GetAuthURLLoaderFactory() scoped_refptr<network::SharedURLLoaderFactory> GetAuthURLLoaderFactory()
const; const;
......
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