Commit 94c42a4f authored by Kush Sinha's avatar Kush Sinha Committed by Commit Bot

Code Cleanup: Dedup usages of AccountManager's URL Context

|InlineLoginHandlerChromeOS| and |ChromeOSOAuth2TokenServiceDelegate|
use the system URL context because they 'know' that AccountManager is
going to use the same. This is a leaky abstraction.

Add a method in AccountManager that returns its URL Request Context.
This request context happens to be the system URL context for now.

Bug: 820046
Change-Id: I668769167893c995f73df63acc575eb410c0f986
Reviewed-on: https://chromium-review.googlesource.com/1088617
Commit-Queue: Kush Sinha <sinhak@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarLutz Justen <ljusten@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566998}
parent 881a8dd0
......@@ -9,7 +9,6 @@
#include "base/bind.h"
#include "base/logging.h"
#include "chrome/browser/browser_process.h"
#include "chromeos/account_manager/account_manager.h"
#include "components/signin/core/browser/account_tracker_service.h"
......@@ -140,13 +139,7 @@ void ChromeOSOAuth2TokenServiceDelegate::UpdateCredentials(
net::URLRequestContextGetter*
ChromeOSOAuth2TokenServiceDelegate::GetRequestContext() const {
// LSTs on Chrome are not channel/token bound for now and hence we can use
// the system request context.
// Note that we cannot use the Profile's request context since
// |AccountManager| acts outside the scope of Profiles.
// TODO(sinhak): Create a new |URLRequestContext| for |AccountManager| which
// conforms to token binding when those details are finalized.
return g_browser_process->system_request_context();
return account_manager_->GetUrlRequestContext();
}
OAuth2TokenServiceDelegate::LoadCredentialsState
......
......@@ -121,10 +121,6 @@ void InlineLoginHandlerChromeOS::CompleteLogin(const base::ListValue* args) {
const std::string& email = auth_data->FindKey("email")->GetString();
CHECK(!email.empty());
// TODO(sinhak): Get URL Context from Account Manager when that is available.
net::URLRequestContextGetter* request_context =
g_browser_process->system_request_context();
// TODO(sinhak): Do not depend on Profile unnecessarily.
Profile* profile = Profile::FromWebUI(web_ui());
......@@ -137,7 +133,8 @@ void InlineLoginHandlerChromeOS::CompleteLogin(const base::ListValue* args) {
->GetAccountManager(profile->GetPath().value());
// SigninHelper deletes itself after its work is done.
new SigninHelper(profile, account_manager, request_context, gaia_id, email,
new SigninHelper(profile, account_manager,
account_manager->GetUrlRequestContext(), gaia_id, email,
auth_code);
}
......
......@@ -329,6 +329,12 @@ void AccountManager::RemoveObserver(AccountManager::Observer* observer) {
}
net::URLRequestContextGetter* AccountManager::GetUrlRequestContext() {
// LSTs on Chrome are not channel/token bound for now and hence we can use
// the system request context.
// Note that we cannot use the Profile's request context since
// |AccountManager| acts outside the scope of Profiles.
// TODO(sinhak): Create a new |URLRequestContext| for |AccountManager| which
// conforms to token binding when those details are finalized.
DCHECK(request_context_);
return request_context_;
}
......
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