summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormsarda@chromium.org <msarda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-20 17:35:23 +0000
committermsarda@chromium.org <msarda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-20 17:35:23 +0000
commitfdd91ad2e68f187bc301c30ecda7e503dae32126 (patch)
tree46d0b93f616443444f6847f71fa17b578c153ec2
parent101d03077b32229ead65bf787f6682fc9ca10fda (diff)
downloadchromium_src-fdd91ad2e68f187bc301c30ecda7e503dae32126.zip
chromium_src-fdd91ad2e68f187bc301c30ecda7e503dae32126.tar.gz
chromium_src-fdd91ad2e68f187bc301c30ecda7e503dae32126.tar.bz2
Move RevokeCredentialsOnServer to MutableProfileOAuth2TokenService
This CL moves RevokeCredentialsOnServer and GetRequestContext from ProfileOAuth2TokenService to MutableProfileOAuth2TokenService. BUG=320625 Review URL: https://codereview.chromium.org/101633009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242113 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/signin/fake_profile_oauth2_token_service.cc10
-rw-r--r--chrome/browser/signin/fake_profile_oauth2_token_service.h5
-rw-r--r--chrome/browser/signin/mutable_profile_oauth2_token_service.cc47
-rw-r--r--chrome/browser/signin/mutable_profile_oauth2_token_service.h7
-rw-r--r--chrome/browser/signin/profile_oauth2_token_service.cc46
-rw-r--r--chrome/browser/signin/profile_oauth2_token_service.h3
6 files changed, 59 insertions, 59 deletions
diff --git a/chrome/browser/signin/fake_profile_oauth2_token_service.cc b/chrome/browser/signin/fake_profile_oauth2_token_service.cc
index 6d721f0..8c7d3f3 100644
--- a/chrome/browser/signin/fake_profile_oauth2_token_service.cc
+++ b/chrome/browser/signin/fake_profile_oauth2_token_service.cc
@@ -140,16 +140,6 @@ std::string FakeProfileOAuth2TokenService::GetRefreshToken(
std::string();
}
-net::URLRequestContextGetter*
-FakeProfileOAuth2TokenService::GetRequestContext() {
- return NULL;
-}
-
-void FakeProfileOAuth2TokenService::RevokeCredentialsOnServer(
- const std::string& refresh_token) {
- // Don't try to contact server in tests.
-}
-
std::vector<FakeProfileOAuth2TokenService::PendingRequest>
FakeProfileOAuth2TokenService::GetPendingRequests() {
std::vector<PendingRequest> valid_requests;
diff --git a/chrome/browser/signin/fake_profile_oauth2_token_service.h b/chrome/browser/signin/fake_profile_oauth2_token_service.h
index 682ec2b..0acc172 100644
--- a/chrome/browser/signin/fake_profile_oauth2_token_service.h
+++ b/chrome/browser/signin/fake_profile_oauth2_token_service.h
@@ -124,11 +124,6 @@ class FakeProfileOAuth2TokenService
virtual std::string GetRefreshToken(const std::string& account_id) OVERRIDE;
- virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
-
- virtual void RevokeCredentialsOnServer(
- const std::string& refresh_token) OVERRIDE;
-
private:
// Helper function to complete pending requests - if |all_scopes| is true,
// then all pending requests are completed, otherwise, only those requests
diff --git a/chrome/browser/signin/mutable_profile_oauth2_token_service.cc b/chrome/browser/signin/mutable_profile_oauth2_token_service.cc
index fe6eb88..f940bcc 100644
--- a/chrome/browser/signin/mutable_profile_oauth2_token_service.cc
+++ b/chrome/browser/signin/mutable_profile_oauth2_token_service.cc
@@ -7,7 +7,10 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/webdata/token_web_data.h"
#include "components/webdata/common/web_data_service_base.h"
+#include "google_apis/gaia/gaia_auth_fetcher.h"
#include "google_apis/gaia/gaia_constants.h"
+#include "google_apis/gaia/google_service_auth_error.h"
+#include "net/url_request/url_request_context_getter.h"
#if defined(ENABLE_MANAGED_USERS)
#include "chrome/browser/managed_mode/managed_user_constants.h"
@@ -34,6 +37,39 @@ std::string RemoveAccountIdPrefix(const std::string& prefixed_account_id) {
return prefixed_account_id.substr(kAccountIdPrefixLength);
}
+// This class sends a request to GAIA to revoke the given refresh token from
+// the server. This is a best effort attempt only. This class deletes itself
+// when done sucessfully or otherwise.
+class RevokeServerRefreshToken : public GaiaAuthConsumer {
+ public:
+ RevokeServerRefreshToken(const std::string& account_id,
+ net::URLRequestContextGetter* request_context);
+ virtual ~RevokeServerRefreshToken();
+
+ private:
+ // GaiaAuthConsumer overrides:
+ virtual void OnOAuth2RevokeTokenCompleted() OVERRIDE;
+
+ scoped_refptr<net::URLRequestContextGetter> request_context_;
+ GaiaAuthFetcher fetcher_;
+
+ DISALLOW_COPY_AND_ASSIGN(RevokeServerRefreshToken);
+};
+
+RevokeServerRefreshToken::RevokeServerRefreshToken(
+ const std::string& refresh_token,
+ net::URLRequestContextGetter* request_context)
+ : request_context_(request_context),
+ fetcher_(this, GaiaConstants::kChromeSource, request_context) {
+ fetcher_.StartRevokeOAuth2Token(refresh_token);
+}
+
+RevokeServerRefreshToken::~RevokeServerRefreshToken() {}
+
+void RevokeServerRefreshToken::OnOAuth2RevokeTokenCompleted() {
+ delete this;
+}
+
} // namespace
MutableProfileOAuth2TokenService::MutableProfileOAuth2TokenService()
@@ -54,6 +90,11 @@ void MutableProfileOAuth2TokenService::Shutdown() {
ProfileOAuth2TokenService::Shutdown();
}
+net::URLRequestContextGetter*
+MutableProfileOAuth2TokenService::GetRequestContext() {
+ return profile()->GetRequestContext();
+}
+
void MutableProfileOAuth2TokenService::LoadCredentials() {
DCHECK_EQ(0, web_data_service_request_);
@@ -168,3 +209,9 @@ MutableProfileOAuth2TokenService::GetAccountIdForMigratingRefreshToken() {
return GetPrimaryAccountId();
}
+
+void MutableProfileOAuth2TokenService::RevokeCredentialsOnServer(
+ const std::string& refresh_token) {
+ // RevokeServerRefreshToken deletes itself when done.
+ new RevokeServerRefreshToken(refresh_token, GetRequestContext());
+}
diff --git a/chrome/browser/signin/mutable_profile_oauth2_token_service.h b/chrome/browser/signin/mutable_profile_oauth2_token_service.h
index a2760ea..81e332c 100644
--- a/chrome/browser/signin/mutable_profile_oauth2_token_service.h
+++ b/chrome/browser/signin/mutable_profile_oauth2_token_service.h
@@ -26,6 +26,9 @@ class MutableProfileOAuth2TokenService : public ProfileOAuth2TokenService,
MutableProfileOAuth2TokenService();
virtual ~MutableProfileOAuth2TokenService();
+ // OAuth2TokenService implementation.
+ virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
+
private:
FRIEND_TEST_ALL_PREFIXES(MutableProfileOAuth2TokenServiceTest,
TokenServiceUpdateClearsCache);
@@ -57,6 +60,10 @@ class MutableProfileOAuth2TokenService : public ProfileOAuth2TokenService,
virtual void ClearPersistedCredentials(
const std::string& account_id) OVERRIDE;
+ // Revokes the refresh token on the server.
+ virtual void RevokeCredentialsOnServer(
+ const std::string& refresh_token) OVERRIDE;
+
// Handle to the request reading tokens from database.
WebDataServiceBase::Handle web_data_service_request_;
diff --git a/chrome/browser/signin/profile_oauth2_token_service.cc b/chrome/browser/signin/profile_oauth2_token_service.cc
index 91dc61f..07c6de6 100644
--- a/chrome/browser/signin/profile_oauth2_token_service.cc
+++ b/chrome/browser/signin/profile_oauth2_token_service.cc
@@ -23,47 +23,6 @@
#include "google_apis/gaia/google_service_auth_error.h"
#include "net/url_request/url_request_context_getter.h"
-namespace {
-
-// This class sends a request to GAIA to revoke the given refresh token from
-// the server. This is a best effort attempt only. This class deletes itself
-// when done sucessfully or otherwise.
-class RevokeServerRefreshToken : public GaiaAuthConsumer {
- public:
- RevokeServerRefreshToken(const std::string& account_id,
- net::URLRequestContextGetter* request_context);
- virtual ~RevokeServerRefreshToken();
-
- private:
- // GaiaAuthConsumer overrides:
- virtual void OnOAuth2RevokeTokenCompleted() OVERRIDE;
-
- scoped_refptr<net::URLRequestContextGetter> request_context_;
- scoped_ptr<GaiaAuthFetcher> fetcher_;
-
- DISALLOW_COPY_AND_ASSIGN(RevokeServerRefreshToken);
-};
-
-RevokeServerRefreshToken::RevokeServerRefreshToken(
- const std::string& refresh_token,
- net::URLRequestContextGetter* request_context)
- : request_context_(request_context) {
- fetcher_.reset(
- new GaiaAuthFetcher(this,
- GaiaConstants::kChromeSource,
- request_context_.get()));
- fetcher_->StartRevokeOAuth2Token(refresh_token);
-}
-
-RevokeServerRefreshToken::~RevokeServerRefreshToken() {}
-
-void RevokeServerRefreshToken::OnOAuth2RevokeTokenCompleted() {
- delete this;
-}
-
-} // namespace
-
-
ProfileOAuth2TokenService::AccountInfo::AccountInfo(
ProfileOAuth2TokenService* token_service,
const std::string& account_id,
@@ -136,7 +95,7 @@ std::string ProfileOAuth2TokenService::GetRefreshToken(
}
net::URLRequestContextGetter* ProfileOAuth2TokenService::GetRequestContext() {
- return profile_->GetRequestContext();
+ return NULL;
}
void ProfileOAuth2TokenService::UpdateAuthError(
@@ -261,6 +220,5 @@ void ProfileOAuth2TokenService::LoadCredentials() {
void ProfileOAuth2TokenService::RevokeCredentialsOnServer(
const std::string& refresh_token) {
- // RevokeServerRefreshToken deletes itself when done.
- new RevokeServerRefreshToken(refresh_token, GetRequestContext());
+ // Empty implementation by default.
}
diff --git a/chrome/browser/signin/profile_oauth2_token_service.h b/chrome/browser/signin/profile_oauth2_token_service.h
index a06b859..e661b52 100644
--- a/chrome/browser/signin/profile_oauth2_token_service.h
+++ b/chrome/browser/signin/profile_oauth2_token_service.h
@@ -151,6 +151,9 @@ class ProfileOAuth2TokenService : public OAuth2TokenService,
PersistenceLoadCredentials);
// Revokes the refresh token on the server.
+ //
+ // Note: Empty implementation as all credentials logic is being migrated to
+ // MutableProfileOAuth2TokenService.
virtual void RevokeCredentialsOnServer(const std::string& refresh_token);
// The profile with which this instance was initialized, or NULL.