summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/api/identity/identity_api.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/extensions/api/identity/identity_api.cc')
-rw-r--r--chrome/browser/extensions/api/identity/identity_api.cc79
1 files changed, 42 insertions, 37 deletions
diff --git a/chrome/browser/extensions/api/identity/identity_api.cc b/chrome/browser/extensions/api/identity/identity_api.cc
index 2be5aed..fbbdca0 100644
--- a/chrome/browser/extensions/api/identity/identity_api.cc
+++ b/chrome/browser/extensions/api/identity/identity_api.cc
@@ -74,7 +74,7 @@ IdentityGetAuthTokenFunction::IdentityGetAuthTokenFunction()
IdentityGetAuthTokenFunction::~IdentityGetAuthTokenFunction() {}
bool IdentityGetAuthTokenFunction::RunImpl() {
- if (profile()->IsOffTheRecord()) {
+ if (GetProfile()->IsOffTheRecord()) {
error_ = identity_constants::kOffTheRecord;
return false;
}
@@ -146,7 +146,8 @@ void IdentityGetAuthTokenFunction::CompleteFunctionWithError(
void IdentityGetAuthTokenFunction::StartSigninFlow() {
// All cached tokens are invalid because the user is not signed in.
IdentityAPI* id_api =
- extensions::IdentityAPI::GetFactoryInstance()->GetForProfile(profile_);
+ extensions::IdentityAPI::GetFactoryInstance()->GetForProfile(
+ GetProfile());
id_api->EraseAllCachedTokens();
// Display a login prompt. If the subsequent mint fails, don't display the
// login prompt again.
@@ -164,7 +165,8 @@ void IdentityGetAuthTokenFunction::StartMintTokenFlow(
std::set<std::string> scopes(oauth2_info.scopes.begin(),
oauth2_info.scopes.end());
IdentityAPI* id_api =
- extensions::IdentityAPI::GetFactoryInstance()->GetForProfile(profile_);
+ extensions::IdentityAPI::GetFactoryInstance()->GetForProfile(
+ GetProfile());
if (!should_prompt_for_scopes_) {
// Caller requested no interaction.
@@ -195,18 +197,17 @@ void IdentityGetAuthTokenFunction::CompleteMintTokenFlow() {
std::set<std::string> scopes(oauth2_info.scopes.begin(),
oauth2_info.scopes.end());
- extensions::IdentityAPI::GetFactoryInstance()->GetForProfile(
- profile_)->mint_queue()->RequestComplete(type,
- GetExtension()->id(),
- scopes,
- this);
+ extensions::IdentityAPI::GetFactoryInstance()
+ ->GetForProfile(GetProfile())
+ ->mint_queue()
+ ->RequestComplete(type, GetExtension()->id(), scopes, this);
}
void IdentityGetAuthTokenFunction::StartMintToken(
IdentityMintRequestQueue::MintType type) {
const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(GetExtension());
- IdentityAPI* id_api = IdentityAPI::GetFactoryInstance()->GetForProfile(
- profile());
+ IdentityAPI* id_api =
+ IdentityAPI::GetFactoryInstance()->GetForProfile(GetProfile());
IdentityTokenCacheValue cache_entry = id_api->GetCachedToken(
GetExtension()->id(), oauth2_info.scopes);
IdentityTokenCacheValue::CacheValueStatus cache_status =
@@ -268,8 +269,9 @@ void IdentityGetAuthTokenFunction::OnMintTokenSuccess(
const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(GetExtension());
IdentityTokenCacheValue token(access_token,
base::TimeDelta::FromSeconds(time_to_live));
- IdentityAPI::GetFactoryInstance()->GetForProfile(profile())->SetCachedToken(
- GetExtension()->id(), oauth2_info.scopes, token);
+ IdentityAPI::GetFactoryInstance()
+ ->GetForProfile(GetProfile())
+ ->SetCachedToken(GetExtension()->id(), oauth2_info.scopes, token);
CompleteMintTokenFlow();
CompleteFunctionWithResult(access_token);
@@ -283,8 +285,9 @@ void IdentityGetAuthTokenFunction::OnMintTokenFailure(
case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS:
case GoogleServiceAuthError::ACCOUNT_DELETED:
case GoogleServiceAuthError::ACCOUNT_DISABLED:
- extensions::IdentityAPI::GetFactoryInstance()->GetForProfile(
- profile())->ReportAuthError(error);
+ extensions::IdentityAPI::GetFactoryInstance()
+ ->GetForProfile(GetProfile())
+ ->ReportAuthError(error);
if (should_prompt_for_signin_) {
// Display a login prompt and try again (once).
StartSigninFlow();
@@ -303,9 +306,11 @@ void IdentityGetAuthTokenFunction::OnMintTokenFailure(
void IdentityGetAuthTokenFunction::OnIssueAdviceSuccess(
const IssueAdviceInfo& issue_advice) {
const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(GetExtension());
- IdentityAPI::GetFactoryInstance()->GetForProfile(profile())->SetCachedToken(
- GetExtension()->id(), oauth2_info.scopes,
- IdentityTokenCacheValue(issue_advice));
+ IdentityAPI::GetFactoryInstance()
+ ->GetForProfile(GetProfile())
+ ->SetCachedToken(GetExtension()->id(),
+ oauth2_info.scopes,
+ IdentityTokenCacheValue(issue_advice));
CompleteMintTokenFlow();
should_prompt_for_signin_ = false;
@@ -370,7 +375,8 @@ void IdentityGetAuthTokenFunction::OnGaiaFlowCompleted(
const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(GetExtension());
IdentityTokenCacheValue token_value(
access_token, base::TimeDelta::FromSeconds(time_to_live));
- IdentityAPI::GetFactoryInstance()->GetForProfile(profile())
+ IdentityAPI::GetFactoryInstance()
+ ->GetForProfile(GetProfile())
->SetCachedToken(GetExtension()->id(), oauth2_info.scopes, token_value);
}
@@ -419,7 +425,7 @@ void IdentityGetAuthTokenFunction::DidGetTokenService(
void IdentityGetAuthTokenFunction::StartLoginAccessTokenRequest() {
ProfileOAuth2TokenService* service =
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile());
+ ProfileOAuth2TokenServiceFactory::GetForProfile(GetProfile());
#if defined(OS_CHROMEOS)
if (chrome::IsRunningInForcedAppMode()) {
std::string app_client_id;
@@ -448,7 +454,7 @@ void IdentityGetAuthTokenFunction::StartGaiaRequest(
}
void IdentityGetAuthTokenFunction::ShowLoginPopup() {
- signin_flow_.reset(new IdentitySigninFlow(this, profile()));
+ signin_flow_.reset(new IdentitySigninFlow(this, GetProfile()));
signin_flow_->Start();
}
@@ -459,7 +465,7 @@ void IdentityGetAuthTokenFunction::ShowOAuthApprovalDialog(
prefs::kApplicationLocale);
gaia_web_auth_flow_.reset(new GaiaWebAuthFlow(
- this, profile(), GetExtension()->id(), oauth2_info, locale));
+ this, GetProfile(), GetExtension()->id(), oauth2_info, locale));
gaia_web_auth_flow_->Start();
}
@@ -467,22 +473,20 @@ OAuth2MintTokenFlow* IdentityGetAuthTokenFunction::CreateMintTokenFlow(
const std::string& login_access_token) {
const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(GetExtension());
- OAuth2MintTokenFlow* mint_token_flow =
- new OAuth2MintTokenFlow(
- profile()->GetRequestContext(),
- this,
- OAuth2MintTokenFlow::Parameters(
- login_access_token,
- GetExtension()->id(),
- oauth2_client_id_,
- oauth2_info.scopes,
- gaia_mint_token_mode_));
+ OAuth2MintTokenFlow* mint_token_flow = new OAuth2MintTokenFlow(
+ GetProfile()->GetRequestContext(),
+ this,
+ OAuth2MintTokenFlow::Parameters(login_access_token,
+ GetExtension()->id(),
+ oauth2_client_id_,
+ oauth2_info.scopes,
+ gaia_mint_token_mode_));
return mint_token_flow;
}
bool IdentityGetAuthTokenFunction::HasLoginToken() const {
ProfileOAuth2TokenService* token_service =
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile());
+ ProfileOAuth2TokenServiceFactory::GetForProfile(GetProfile());
return token_service->RefreshTokenIsAvailable(
token_service->GetPrimaryAccountId());
}
@@ -521,7 +525,7 @@ IdentityRemoveCachedAuthTokenFunction::
}
bool IdentityRemoveCachedAuthTokenFunction::RunImpl() {
- if (profile()->IsOffTheRecord()) {
+ if (GetProfile()->IsOffTheRecord()) {
error_ = identity_constants::kOffTheRecord;
return false;
}
@@ -529,8 +533,9 @@ bool IdentityRemoveCachedAuthTokenFunction::RunImpl() {
scoped_ptr<identity::RemoveCachedAuthToken::Params> params(
identity::RemoveCachedAuthToken::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
- IdentityAPI::GetFactoryInstance()->GetForProfile(profile())->EraseCachedToken(
- GetExtension()->id(), params->details.token);
+ IdentityAPI::GetFactoryInstance()
+ ->GetForProfile(GetProfile())
+ ->EraseCachedToken(GetExtension()->id(), params->details.token);
return true;
}
@@ -542,7 +547,7 @@ IdentityLaunchWebAuthFlowFunction::~IdentityLaunchWebAuthFlowFunction() {
}
bool IdentityLaunchWebAuthFlowFunction::RunImpl() {
- if (profile()->IsOffTheRecord()) {
+ if (GetProfile()->IsOffTheRecord()) {
error_ = identity_constants::kOffTheRecord;
return false;
}
@@ -562,7 +567,7 @@ bool IdentityLaunchWebAuthFlowFunction::RunImpl() {
AddRef(); // Balanced in OnAuthFlowSuccess/Failure.
- auth_flow_.reset(new WebAuthFlow(this, profile(), auth_url, mode));
+ auth_flow_.reset(new WebAuthFlow(this, GetProfile(), auth_url, mode));
auth_flow_->Start();
return true;
}