summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-23 19:46:53 +0000
committerbartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-23 19:46:53 +0000
commita263ff59f18b9ab39601fafe4e60e44e9a20d20f (patch)
tree027c91e3e5811572d8d9bc111f962ca69a61d0e7
parent2442605058353f23d08db64f39cff92c48f7e8e6 (diff)
downloadchromium_src-a263ff59f18b9ab39601fafe4e60e44e9a20d20f.zip
chromium_src-a263ff59f18b9ab39601fafe4e60e44e9a20d20f.tar.gz
chromium_src-a263ff59f18b9ab39601fafe4e60e44e9a20d20f.tar.bz2
Rename InvalidationAuthProvider to IdentityProvider
The InvalidationAuthProvider is useful outside the area of invalidation: It provides an abstract interface for accessing the logged-in GAIA account and receiving notifications about login/logout events. This CL renames the InvalidationAuthProvider to IdentityProvider and places it in the gaia_apis component. This change is a prerequisite for CL 225403021, which will use the IdentityProvider in GCM. BUG=362083 TEST=Updated tests TBR=atwilson (for chrome/browser/sync/test/integration/sync_test.cc) Review URL: https://codereview.chromium.org/235273002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@265706 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/settings/device_identity_provider.cc33
-rw-r--r--chrome/browser/chromeos/settings/device_identity_provider.h36
-rw-r--r--chrome/browser/extensions/api/push_messaging/push_messaging_api.cc28
-rw-r--r--chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler_unittest.cc3
-rw-r--r--chrome/browser/invalidation/device_invalidation_auth_provider_chromeos.cc27
-rw-r--r--chrome/browser/invalidation/device_invalidation_auth_provider_chromeos.h37
-rw-r--r--chrome/browser/invalidation/fake_invalidation_service.cc25
-rw-r--r--chrome/browser/invalidation/fake_invalidation_service.h28
-rw-r--r--chrome/browser/invalidation/gcm_invalidation_bridge.cc14
-rw-r--r--chrome/browser/invalidation/gcm_invalidation_bridge.h8
-rw-r--r--chrome/browser/invalidation/gcm_invalidation_bridge_unittest.cc32
-rw-r--r--chrome/browser/invalidation/invalidation_auth_provider.cc27
-rw-r--r--chrome/browser/invalidation/invalidation_auth_provider.h58
-rw-r--r--chrome/browser/invalidation/invalidation_service.h7
-rw-r--r--chrome/browser/invalidation/invalidation_service_android.cc3
-rw-r--r--chrome/browser/invalidation/invalidation_service_android.h2
-rw-r--r--chrome/browser/invalidation/invalidation_service_factory.cc14
-rw-r--r--chrome/browser/invalidation/p2p_invalidation_service.cc11
-rw-r--r--chrome/browser/invalidation/p2p_invalidation_service.h6
-rw-r--r--chrome/browser/invalidation/profile_invalidation_auth_provider.h45
-rw-r--r--chrome/browser/invalidation/ticl_invalidation_service.cc54
-rw-r--r--chrome/browser/invalidation/ticl_invalidation_service.h14
-rw-r--r--chrome/browser/invalidation/ticl_invalidation_service_unittest.cc18
-rw-r--r--chrome/browser/signin/profile_identity_provider.cc (renamed from chrome/browser/invalidation/profile_invalidation_auth_provider.cc)29
-rw-r--r--chrome/browser/signin/profile_identity_provider.h44
-rw-r--r--chrome/browser/sync/test/integration/sync_test.cc11
-rw-r--r--chrome/chrome_browser.gypi8
-rw-r--r--chrome/chrome_browser_chromeos.gypi2
-rw-r--r--google_apis/gaia/fake_identity_provider.cc40
-rw-r--r--google_apis/gaia/fake_identity_provider.h38
-rw-r--r--google_apis/gaia/identity_provider.cc71
-rw-r--r--google_apis/gaia/identity_provider.h93
-rw-r--r--google_apis/google_apis.gyp4
33 files changed, 484 insertions, 386 deletions
diff --git a/chrome/browser/chromeos/settings/device_identity_provider.cc b/chrome/browser/chromeos/settings/device_identity_provider.cc
new file mode 100644
index 0000000..22d3150
--- /dev/null
+++ b/chrome/browser/chromeos/settings/device_identity_provider.cc
@@ -0,0 +1,33 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/settings/device_identity_provider.h"
+
+#include "chrome/browser/chromeos/settings/device_oauth2_token_service.h"
+
+namespace chromeos {
+
+DeviceIdentityProvider::DeviceIdentityProvider(
+ chromeos::DeviceOAuth2TokenService* token_service)
+ : token_service_(token_service) {}
+
+DeviceIdentityProvider::~DeviceIdentityProvider() {}
+
+std::string DeviceIdentityProvider::GetActiveUsername() {
+ return token_service_->GetRobotAccountId();
+}
+
+std::string DeviceIdentityProvider::GetActiveAccountId() {
+ return token_service_->GetRobotAccountId();
+}
+
+OAuth2TokenService* DeviceIdentityProvider::GetTokenService() {
+ return token_service_;
+}
+
+bool DeviceIdentityProvider::RequestLogin() {
+ return false;
+}
+
+} // namespace chromeos
diff --git a/chrome/browser/chromeos/settings/device_identity_provider.h b/chrome/browser/chromeos/settings/device_identity_provider.h
new file mode 100644
index 0000000..8007574
--- /dev/null
+++ b/chrome/browser/chromeos/settings/device_identity_provider.h
@@ -0,0 +1,36 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_IDENTITY_PROVIDER_H_
+#define CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_IDENTITY_PROVIDER_H_
+
+#include "base/macros.h"
+#include "google_apis/gaia/identity_provider.h"
+
+namespace chromeos {
+
+class DeviceOAuth2TokenService;
+
+// Identity provider implementation backed by DeviceOAuth2TokenService.
+class DeviceIdentityProvider : public IdentityProvider {
+ public:
+ explicit DeviceIdentityProvider(
+ chromeos::DeviceOAuth2TokenService* token_service);
+ virtual ~DeviceIdentityProvider();
+
+ // IdentityProvider:
+ virtual std::string GetActiveUsername() OVERRIDE;
+ virtual std::string GetActiveAccountId() OVERRIDE;
+ virtual OAuth2TokenService* GetTokenService() OVERRIDE;
+ virtual bool RequestLogin() OVERRIDE;
+
+ private:
+ chromeos::DeviceOAuth2TokenService* token_service_;
+
+ DISALLOW_COPY_AND_ASSIGN(DeviceIdentityProvider);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_IDENTITY_PROVIDER_H_
diff --git a/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc b/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc
index b47f7b0..5ed1365b 100644
--- a/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc
+++ b/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc
@@ -16,7 +16,6 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/token_cache/token_cache_service.h"
#include "chrome/browser/extensions/token_cache/token_cache_service_factory.h"
-#include "chrome/browser/invalidation/invalidation_auth_provider.h"
#include "chrome/browser/invalidation/invalidation_service.h"
#include "chrome/browser/invalidation/invalidation_service_factory.h"
#include "chrome/browser/profiles/profile.h"
@@ -34,6 +33,7 @@
#include "extensions/common/extension.h"
#include "extensions/common/permissions/api_permission.h"
#include "google_apis/gaia/gaia_constants.h"
+#include "google_apis/gaia/identity_provider.h"
using content::BrowserThread;
@@ -111,12 +111,12 @@ bool PushMessagingGetChannelIdFunction::RunImpl() {
return false;
}
- invalidation::InvalidationAuthProvider* auth_provider =
- invalidation_service->GetInvalidationAuthProvider();
- if (!auth_provider->GetTokenService()->RefreshTokenIsAvailable(
- auth_provider->GetAccountId())) {
- if (interactive_ && auth_provider->ShowLoginUI()) {
- auth_provider->GetTokenService()->AddObserver(this);
+ IdentityProvider* identity_provider =
+ invalidation_service->GetIdentityProvider();
+ if (!identity_provider->GetTokenService()->RefreshTokenIsAvailable(
+ identity_provider->GetActiveAccountId())) {
+ if (interactive_ && identity_provider->RequestLogin()) {
+ identity_provider->AddActiveAccountRefreshTokenObserver(this);
return true;
} else {
error_ = kUserNotSignedIn;
@@ -135,15 +135,15 @@ void PushMessagingGetChannelIdFunction::StartAccessTokenFetch() {
invalidation::InvalidationService* invalidation_service =
invalidation::InvalidationServiceFactory::GetForProfile(GetProfile());
CHECK(invalidation_service);
- invalidation::InvalidationAuthProvider* auth_provider =
- invalidation_service->GetInvalidationAuthProvider();
+ IdentityProvider* identity_provider =
+ invalidation_service->GetIdentityProvider();
std::vector<std::string> scope_vector =
extensions::ObfuscatedGaiaIdFetcher::GetScopes();
OAuth2TokenService::ScopeSet scopes(scope_vector.begin(), scope_vector.end());
fetcher_access_token_request_ =
- auth_provider->GetTokenService()->StartRequest(
- auth_provider->GetAccountId(), scopes, this);
+ identity_provider->GetTokenService()->StartRequest(
+ identity_provider->GetActiveAccountId(), scopes, this);
}
void PushMessagingGetChannelIdFunction::OnRefreshTokenAvailable(
@@ -151,8 +151,8 @@ void PushMessagingGetChannelIdFunction::OnRefreshTokenAvailable(
invalidation::InvalidationService* invalidation_service =
invalidation::InvalidationServiceFactory::GetForProfile(GetProfile());
CHECK(invalidation_service);
- invalidation_service->GetInvalidationAuthProvider()->GetTokenService()->
- RemoveObserver(this);
+ invalidation_service->GetIdentityProvider()->
+ RemoveActiveAccountRefreshTokenObserver(this);
DVLOG(2) << "Newly logged in: " << GetProfile()->GetProfileName();
StartAccessTokenFetch();
}
@@ -274,7 +274,7 @@ void PushMessagingGetChannelIdFunction::OnObfuscatedGaiaIdFetchFailure(
invalidation::InvalidationServiceFactory::GetForProfile(GetProfile());
CHECK(invalidation_service);
if (!interactive_ ||
- !invalidation_service->GetInvalidationAuthProvider()->ShowLoginUI()) {
+ !invalidation_service->GetIdentityProvider()->RequestLogin()) {
ReportResult(std::string(), error_text);
}
return;
diff --git a/chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler_unittest.cc b/chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler_unittest.cc
index 018f2f6..e8ae2ae 100644
--- a/chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler_unittest.cc
+++ b/chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler_unittest.cc
@@ -38,8 +38,7 @@ class MockInvalidationService : public invalidation::InvalidationService {
MOCK_METHOD0(GetInvalidationLogger, invalidation::InvalidationLogger*());
MOCK_CONST_METHOD1(RequestDetailedStatus,
void(base::Callback<void(const base::DictionaryValue&)>));
- MOCK_METHOD0(GetInvalidationAuthProvider,
- invalidation::InvalidationAuthProvider*());
+ MOCK_METHOD0(GetIdentityProvider, IdentityProvider*());
private:
DISALLOW_COPY_AND_ASSIGN(MockInvalidationService);
diff --git a/chrome/browser/invalidation/device_invalidation_auth_provider_chromeos.cc b/chrome/browser/invalidation/device_invalidation_auth_provider_chromeos.cc
deleted file mode 100644
index 11aa3c6..0000000
--- a/chrome/browser/invalidation/device_invalidation_auth_provider_chromeos.cc
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/invalidation/device_invalidation_auth_provider_chromeos.h"
-
-#include "chrome/browser/chromeos/settings/device_oauth2_token_service.h"
-
-namespace invalidation {
-
-DeviceInvalidationAuthProvider::DeviceInvalidationAuthProvider(
- chromeos::DeviceOAuth2TokenService* token_service)
- : token_service_(token_service) {}
-
-DeviceInvalidationAuthProvider::~DeviceInvalidationAuthProvider() {}
-
-std::string DeviceInvalidationAuthProvider::GetAccountId() {
- return token_service_->GetRobotAccountId();
-}
-
-OAuth2TokenService* DeviceInvalidationAuthProvider::GetTokenService() {
- return token_service_;
-}
-
-bool DeviceInvalidationAuthProvider::ShowLoginUI() { return false; }
-
-} // namespace invalidation
diff --git a/chrome/browser/invalidation/device_invalidation_auth_provider_chromeos.h b/chrome/browser/invalidation/device_invalidation_auth_provider_chromeos.h
deleted file mode 100644
index ecd1334..0000000
--- a/chrome/browser/invalidation/device_invalidation_auth_provider_chromeos.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_INVALIDATION_DEVICE_INVALIDATION_AUTH_PROVIDER_CHROMEOS_H_
-#define CHROME_BROWSER_INVALIDATION_DEVICE_INVALIDATION_AUTH_PROVIDER_CHROMEOS_H_
-
-#include "base/macros.h"
-#include "chrome/browser/invalidation/invalidation_auth_provider.h"
-
-namespace chromeos {
-class DeviceOAuth2TokenService;
-}
-
-namespace invalidation {
-
-// Authentication provider implementation backed by DeviceOAuth2TokenService.
-class DeviceInvalidationAuthProvider : public InvalidationAuthProvider {
- public:
- DeviceInvalidationAuthProvider(
- chromeos::DeviceOAuth2TokenService* token_service);
- virtual ~DeviceInvalidationAuthProvider();
-
- // InvalidationAuthProvider:
- virtual std::string GetAccountId() OVERRIDE;
- virtual OAuth2TokenService* GetTokenService() OVERRIDE;
- virtual bool ShowLoginUI() OVERRIDE;
-
- private:
- chromeos::DeviceOAuth2TokenService* token_service_;
-
- DISALLOW_COPY_AND_ASSIGN(DeviceInvalidationAuthProvider);
-};
-
-} // namespace invalidation
-
-#endif // CHROME_BROWSER_INVALIDATION_DEVICE_INVALIDATION_AUTH_PROVIDER_CHROMEOS_H_
diff --git a/chrome/browser/invalidation/fake_invalidation_service.cc b/chrome/browser/invalidation/fake_invalidation_service.cc
index 8c34f00..ced8d72 100644
--- a/chrome/browser/invalidation/fake_invalidation_service.cc
+++ b/chrome/browser/invalidation/fake_invalidation_service.cc
@@ -10,25 +10,11 @@
namespace invalidation {
-FakeInvalidationAuthProvider::FakeInvalidationAuthProvider() {
- token_service_.set_auto_post_fetch_response_on_message_loop(true);
-}
-
-FakeInvalidationAuthProvider::~FakeInvalidationAuthProvider() {}
-
-OAuth2TokenService* FakeInvalidationAuthProvider::GetTokenService() {
- return &token_service_;
-}
-
-std::string FakeInvalidationAuthProvider::GetAccountId() {
- return "fake@example.com";
-}
-
-bool FakeInvalidationAuthProvider::ShowLoginUI() { return false; }
-
FakeInvalidationService::FakeInvalidationService()
- : client_id_(GenerateInvalidatorClientId()) {
+ : client_id_(GenerateInvalidatorClientId()),
+ identity_provider_(&token_service_) {
invalidator_registrar_.UpdateInvalidatorState(syncer::INVALIDATIONS_ENABLED);
+ token_service_.set_auto_post_fetch_response_on_message_loop(true);
}
FakeInvalidationService::~FakeInvalidationService() {
@@ -73,9 +59,8 @@ void FakeInvalidationService::RequestDetailedStatus(
caller.Run(value);
}
-InvalidationAuthProvider*
-FakeInvalidationService::GetInvalidationAuthProvider() {
- return &auth_provider_;
+IdentityProvider* FakeInvalidationService::GetIdentityProvider() {
+ return &identity_provider_;
}
void FakeInvalidationService::SetInvalidatorState(
diff --git a/chrome/browser/invalidation/fake_invalidation_service.h b/chrome/browser/invalidation/fake_invalidation_service.h
index d958bf5..eb7e20d 100644
--- a/chrome/browser/invalidation/fake_invalidation_service.h
+++ b/chrome/browser/invalidation/fake_invalidation_service.h
@@ -10,9 +10,9 @@
#include "base/basictypes.h"
#include "base/callback_forward.h"
-#include "chrome/browser/invalidation/invalidation_auth_provider.h"
#include "chrome/browser/invalidation/invalidation_service.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
+#include "google_apis/gaia/fake_identity_provider.h"
#include "sync/notifier/invalidator_registrar.h"
#include "sync/notifier/mock_ack_handler.h"
@@ -28,27 +28,6 @@ namespace invalidation {
class InvalidationLogger;
-// Fake invalidation auth provider implementation.
-class FakeInvalidationAuthProvider : public InvalidationAuthProvider {
- public:
- FakeInvalidationAuthProvider();
- virtual ~FakeInvalidationAuthProvider();
-
- // InvalidationAuthProvider:
- virtual OAuth2TokenService* GetTokenService() OVERRIDE;
- virtual std::string GetAccountId() OVERRIDE;
- virtual bool ShowLoginUI() OVERRIDE;
-
- FakeProfileOAuth2TokenService* fake_token_service() {
- return &token_service_;
- }
-
- private:
- FakeProfileOAuth2TokenService token_service_;
-
- DISALLOW_COPY_AND_ASSIGN(FakeInvalidationAuthProvider);
-};
-
// An InvalidationService that emits invalidations only when
// its EmitInvalidationForTest method is called.
class FakeInvalidationService : public InvalidationService {
@@ -71,7 +50,7 @@ class FakeInvalidationService : public InvalidationService {
virtual InvalidationLogger* GetInvalidationLogger() OVERRIDE;
virtual void RequestDetailedStatus(
base::Callback<void(const base::DictionaryValue&)> caller) const OVERRIDE;
- virtual InvalidationAuthProvider* GetInvalidationAuthProvider() OVERRIDE;
+ virtual IdentityProvider* GetIdentityProvider() OVERRIDE;
void SetInvalidatorState(syncer::InvalidatorState state);
@@ -89,7 +68,8 @@ class FakeInvalidationService : public InvalidationService {
std::string client_id_;
syncer::InvalidatorRegistrar invalidator_registrar_;
syncer::MockAckHandler mock_ack_handler_;
- FakeInvalidationAuthProvider auth_provider_;
+ FakeProfileOAuth2TokenService token_service_;
+ FakeIdentityProvider identity_provider_;
DISALLOW_COPY_AND_ASSIGN(FakeInvalidationService);
};
diff --git a/chrome/browser/invalidation/gcm_invalidation_bridge.cc b/chrome/browser/invalidation/gcm_invalidation_bridge.cc
index dd1b5d8..5925eda 100644
--- a/chrome/browser/invalidation/gcm_invalidation_bridge.cc
+++ b/chrome/browser/invalidation/gcm_invalidation_bridge.cc
@@ -7,13 +7,13 @@
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
#include "chrome/browser/invalidation/gcm_invalidation_bridge.h"
-#include "chrome/browser/invalidation/invalidation_auth_provider.h"
#include "chrome/browser/services/gcm/gcm_profile_service.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "google_apis/gaia/gaia_constants.h"
+#include "google_apis/gaia/identity_provider.h"
namespace invalidation {
namespace {
@@ -149,10 +149,10 @@ void GCMInvalidationBridge::Core::OnIncomingMessage(
GCMInvalidationBridge::GCMInvalidationBridge(
gcm::GCMProfileService* gcm_profile_service,
- InvalidationAuthProvider* auth_provider)
+ IdentityProvider* identity_provider)
: OAuth2TokenService::Consumer("gcm_network_channel"),
gcm_profile_service_(gcm_profile_service),
- auth_provider_(auth_provider),
+ identity_provider_(identity_provider),
subscribed_for_incoming_messages_(false),
weak_factory_(this) {}
@@ -195,8 +195,8 @@ void GCMInvalidationBridge::RequestToken(
request_token_callback_ = callback;
OAuth2TokenService::ScopeSet scopes;
scopes.insert(GaiaConstants::kChromeSyncOAuth2Scope);
- access_token_request_ = auth_provider_->GetTokenService()->StartRequest(
- auth_provider_->GetAccountId(), scopes, this);
+ access_token_request_ = identity_provider_->GetTokenService()->StartRequest(
+ identity_provider_->GetActiveAccountId(), scopes, this);
}
void GCMInvalidationBridge::OnGetTokenSuccess(
@@ -236,8 +236,8 @@ void GCMInvalidationBridge::InvalidateToken(const std::string& token) {
DCHECK(CalledOnValidThread());
OAuth2TokenService::ScopeSet scopes;
scopes.insert(GaiaConstants::kChromeSyncOAuth2Scope);
- auth_provider_->GetTokenService()->InvalidateToken(
- auth_provider_->GetAccountId(), scopes, token);
+ identity_provider_->GetTokenService()->InvalidateToken(
+ identity_provider_->GetActiveAccountId(), scopes, token);
}
void GCMInvalidationBridge::Register(
diff --git a/chrome/browser/invalidation/gcm_invalidation_bridge.h b/chrome/browser/invalidation/gcm_invalidation_bridge.h
index 9bbaf97..c72c6a1 100644
--- a/chrome/browser/invalidation/gcm_invalidation_bridge.h
+++ b/chrome/browser/invalidation/gcm_invalidation_bridge.h
@@ -14,6 +14,8 @@
#include "google_apis/gcm/gcm_client.h"
#include "sync/notifier/gcm_network_channel_delegate.h"
+class IdentityProvider;
+
namespace base {
class SingleThreadTaskRunner;
} // namespace base
@@ -24,8 +26,6 @@ class GCMProfileService;
namespace invalidation {
-class InvalidationAuthProvider;
-
// GCMInvalidationBridge and GCMInvalidationBridge::Core implement functions
// needed for GCMNetworkChannel. GCMInvalidationBridge lives on UI thread while
// Core lives on IO thread. Core implements GCMNetworkChannelDelegate and posts
@@ -38,7 +38,7 @@ class GCMInvalidationBridge : public gcm::GCMAppHandler,
class Core;
GCMInvalidationBridge(gcm::GCMProfileService* gcm_profile_service,
- InvalidationAuthProvider* auth_provider);
+ IdentityProvider* identity_provider);
virtual ~GCMInvalidationBridge();
// OAuth2TokenService::Consumer implementation.
@@ -81,7 +81,7 @@ class GCMInvalidationBridge : public gcm::GCMAppHandler,
private:
gcm::GCMProfileService* const gcm_profile_service_;
- InvalidationAuthProvider* const auth_provider_;
+ IdentityProvider* const identity_provider_;
base::WeakPtr<Core> core_;
scoped_refptr<base::SingleThreadTaskRunner> core_thread_task_runner_;
diff --git a/chrome/browser/invalidation/gcm_invalidation_bridge_unittest.cc b/chrome/browser/invalidation/gcm_invalidation_bridge_unittest.cc
index 22243e0..6ab650e 100644
--- a/chrome/browser/invalidation/gcm_invalidation_bridge_unittest.cc
+++ b/chrome/browser/invalidation/gcm_invalidation_bridge_unittest.cc
@@ -4,15 +4,14 @@
#include "base/run_loop.h"
#include "chrome/browser/invalidation/gcm_invalidation_bridge.h"
-#include "chrome/browser/invalidation/invalidation_auth_provider.h"
#include "chrome/browser/services/gcm/gcm_profile_service.h"
#include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/test/base/testing_profile.h"
-#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "content/public/test/test_browser_thread_bundle.h"
+#include "google_apis/gaia/fake_identity_provider.h"
#include "google_apis/gaia/google_service_auth_error.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -44,27 +43,6 @@ class FakeGCMProfileService : public gcm::GCMProfileService {
DISALLOW_COPY_AND_ASSIGN(FakeGCMProfileService);
};
-// Fake invalidation auth provider implementation.
-class FakeInvalidationAuthProvider : public InvalidationAuthProvider {
- public:
- explicit FakeInvalidationAuthProvider(
- ProfileOAuth2TokenService* token_service)
- : token_service_(token_service) {}
- virtual ~FakeInvalidationAuthProvider() {}
-
- // InvalidationAuthProvider:
- virtual OAuth2TokenService* GetTokenService() OVERRIDE {
- return token_service_;
- }
- virtual std::string GetAccountId() OVERRIDE { return std::string(); }
- virtual bool ShowLoginUI() OVERRIDE { return false; }
-
- private:
- OAuth2TokenService* token_service_;
-
- DISALLOW_COPY_AND_ASSIGN(FakeInvalidationAuthProvider);
-};
-
class GCMInvalidationBridgeTest : public ::testing::Test {
protected:
GCMInvalidationBridgeTest() {}
@@ -87,9 +65,9 @@ class GCMInvalidationBridgeTest : public ::testing::Test {
(FakeGCMProfileService*)gcm::GCMProfileServiceFactory::GetForProfile(
profile_.get());
- auth_provider_.reset(new FakeInvalidationAuthProvider(token_service));
- bridge_.reset(
- new GCMInvalidationBridge(gcm_profile_service_, auth_provider_.get()));
+ identity_provider_.reset(new FakeIdentityProvider(token_service));
+ bridge_.reset(new GCMInvalidationBridge(gcm_profile_service_,
+ identity_provider_.get()));
delegate_ = bridge_->CreateDelegate();
delegate_->Initialize();
@@ -112,7 +90,7 @@ class GCMInvalidationBridgeTest : public ::testing::Test {
content::TestBrowserThreadBundle thread_bundle_;
scoped_ptr<Profile> profile_;
FakeGCMProfileService* gcm_profile_service_;
- scoped_ptr<FakeInvalidationAuthProvider> auth_provider_;
+ scoped_ptr<FakeIdentityProvider> identity_provider_;
std::vector<std::string> issued_tokens_;
std::vector<GoogleServiceAuthError> request_token_errors_;
diff --git a/chrome/browser/invalidation/invalidation_auth_provider.cc b/chrome/browser/invalidation/invalidation_auth_provider.cc
deleted file mode 100644
index d8f495f..0000000
--- a/chrome/browser/invalidation/invalidation_auth_provider.cc
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/invalidation/invalidation_auth_provider.h"
-
-namespace invalidation {
-
-InvalidationAuthProvider::Observer::~Observer() {}
-
-InvalidationAuthProvider::~InvalidationAuthProvider() {}
-
-void InvalidationAuthProvider::AddObserver(Observer* observer) {
- observers_.AddObserver(observer);
-}
-
-void InvalidationAuthProvider::RemoveObserver(Observer* observer) {
- observers_.RemoveObserver(observer);
-}
-
-InvalidationAuthProvider::InvalidationAuthProvider() {}
-
-void InvalidationAuthProvider::FireInvalidationAuthLogout() {
- FOR_EACH_OBSERVER(Observer, observers_, OnInvalidationAuthLogout());
-}
-
-} // namespace invalidation
diff --git a/chrome/browser/invalidation/invalidation_auth_provider.h b/chrome/browser/invalidation/invalidation_auth_provider.h
deleted file mode 100644
index 33c1455..0000000
--- a/chrome/browser/invalidation/invalidation_auth_provider.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_INVALIDATION_INVALIDATION_AUTH_PROVIDER_H_
-#define CHROME_BROWSER_INVALIDATION_INVALIDATION_AUTH_PROVIDER_H_
-
-#include <string>
-
-#include "base/macros.h"
-#include "base/observer_list.h"
-
-class OAuth2TokenService;
-
-namespace invalidation {
-
-// Encapsulates authentication-related dependencies of InvalidationService
-// implementations so different implementations can be used for regular Profiles
-// and Chrome OS Kiosk Apps.
-class InvalidationAuthProvider {
- public:
- class Observer {
- public:
- virtual ~Observer();
-
- // Called when the user logs out.
- virtual void OnInvalidationAuthLogout() = 0;
- };
-
- virtual ~InvalidationAuthProvider();
-
- // Gets the token service vending tokens for authentication to the cloud.
- virtual OAuth2TokenService* GetTokenService() = 0;
-
- // Gets the account ID to use for authentication.
- virtual std::string GetAccountId() = 0;
-
- // Shows the login popup, returns true if successful.
- virtual bool ShowLoginUI() = 0;
-
- void AddObserver(Observer* observer);
- void RemoveObserver(Observer* observer);
-
- protected:
- InvalidationAuthProvider();
-
- // Fires an OnInvalidationAuthLogout notification.
- void FireInvalidationAuthLogout();
-
- private:
- ObserverList<Observer, true> observers_;
-
- DISALLOW_COPY_AND_ASSIGN(InvalidationAuthProvider);
-};
-
-} // namespace invalidation
-
-#endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_AUTH_PROVIDER_H_
diff --git a/chrome/browser/invalidation/invalidation_service.h b/chrome/browser/invalidation/invalidation_service.h
index f5f8717..d964f79 100644
--- a/chrome/browser/invalidation/invalidation_service.h
+++ b/chrome/browser/invalidation/invalidation_service.h
@@ -10,12 +10,13 @@
#include "sync/notifier/invalidation_util.h"
#include "sync/notifier/invalidator_state.h"
+class IdentityProvider;
+
namespace syncer {
class InvalidationHandler;
} // namespace syncer
namespace invalidation {
-class InvalidationAuthProvider;
class InvalidationLogger;
// Interface for classes that handle invalidation registrations and send out
@@ -109,8 +110,8 @@ class InvalidationService : public KeyedService {
virtual void RequestDetailedStatus(
base::Callback<void(const base::DictionaryValue&)> post_caller) const = 0;
- // Returns the authentication provider.
- virtual InvalidationAuthProvider* GetInvalidationAuthProvider() = 0;
+ // Returns the identity provider.
+ virtual IdentityProvider* GetIdentityProvider() = 0;
protected:
virtual ~InvalidationService() { }
diff --git a/chrome/browser/invalidation/invalidation_service_android.cc b/chrome/browser/invalidation/invalidation_service_android.cc
index f53f5be..57a34bd 100644
--- a/chrome/browser/invalidation/invalidation_service_android.cc
+++ b/chrome/browser/invalidation/invalidation_service_android.cc
@@ -68,8 +68,7 @@ void InvalidationServiceAndroid::RequestDetailedStatus(
base::Callback<void(const base::DictionaryValue&)> return_callback) const {
}
-InvalidationAuthProvider*
-InvalidationServiceAndroid::GetInvalidationAuthProvider() {
+IdentityProvider* InvalidationServiceAndroid::GetIdentityProvider() {
return NULL;
}
diff --git a/chrome/browser/invalidation/invalidation_service_android.h b/chrome/browser/invalidation/invalidation_service_android.h
index 039bacb..fe94476 100644
--- a/chrome/browser/invalidation/invalidation_service_android.h
+++ b/chrome/browser/invalidation/invalidation_service_android.h
@@ -55,7 +55,7 @@ class InvalidationServiceAndroid
virtual void RequestDetailedStatus(
base::Callback<void(const base::DictionaryValue&)> caller) const
OVERRIDE;
- virtual InvalidationAuthProvider* GetInvalidationAuthProvider() OVERRIDE;
+ virtual IdentityProvider* GetIdentityProvider() OVERRIDE;
// content::NotificationObserver implementation.
virtual void Observe(int type,
diff --git a/chrome/browser/invalidation/invalidation_service_factory.cc b/chrome/browser/invalidation/invalidation_service_factory.cc
index 91ea1fd..61b2e07 100644
--- a/chrome/browser/invalidation/invalidation_service_factory.cc
+++ b/chrome/browser/invalidation/invalidation_service_factory.cc
@@ -11,10 +11,10 @@
#include "chrome/browser/invalidation/invalidation_service.h"
#include "chrome/browser/invalidation/invalidation_service_android.h"
#include "chrome/browser/invalidation/invalidator_storage.h"
-#include "chrome/browser/invalidation/profile_invalidation_auth_provider.h"
#include "chrome/browser/invalidation/ticl_invalidation_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
+#include "chrome/browser/signin/profile_identity_provider.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
@@ -35,8 +35,8 @@
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/chromeos/settings/device_identity_provider.h"
#include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h"
-#include "chrome/browser/invalidation/device_invalidation_auth_provider_chromeos.h"
#endif
namespace invalidation {
@@ -98,7 +98,7 @@ KeyedService* InvalidationServiceFactory::BuildServiceInstanceFor(
new InvalidationControllerAndroid());
#else
- scoped_ptr<InvalidationAuthProvider> auth_provider;
+ scoped_ptr<IdentityProvider> identity_provider;
#if defined(OS_CHROMEOS)
policy::BrowserPolicyConnectorChromeOS* connector =
@@ -106,20 +106,20 @@ KeyedService* InvalidationServiceFactory::BuildServiceInstanceFor(
if (chromeos::UserManager::IsInitialized() &&
chromeos::UserManager::Get()->IsLoggedInAsKioskApp() &&
connector->IsEnterpriseManaged()) {
- auth_provider.reset(new DeviceInvalidationAuthProvider(
+ identity_provider.reset(new chromeos::DeviceIdentityProvider(
chromeos::DeviceOAuth2TokenServiceFactory::Get()));
}
#endif
- if (!auth_provider) {
- auth_provider.reset(new ProfileInvalidationAuthProvider(
+ if (!identity_provider) {
+ identity_provider.reset(new ProfileIdentityProvider(
SigninManagerFactory::GetForProfile(profile),
ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
LoginUIServiceFactory::GetForProfile(profile)));
}
TiclInvalidationService* service = new TiclInvalidationService(
- auth_provider.Pass(),
+ identity_provider.Pass(),
profile->GetRequestContext(),
profile);
service->Init(scoped_ptr<syncer::InvalidationStateTracker>(
diff --git a/chrome/browser/invalidation/p2p_invalidation_service.cc b/chrome/browser/invalidation/p2p_invalidation_service.cc
index 416525a..5b6a87d 100644
--- a/chrome/browser/invalidation/p2p_invalidation_service.cc
+++ b/chrome/browser/invalidation/p2p_invalidation_service.cc
@@ -5,9 +5,9 @@
#include "chrome/browser/invalidation/p2p_invalidation_service.h"
#include "base/command_line.h"
-#include "chrome/browser/invalidation/invalidation_auth_provider.h"
#include "chrome/browser/invalidation/invalidation_service_util.h"
#include "chrome/common/chrome_switches.h"
+#include "google_apis/gaia/identity_provider.h"
#include "jingle/notifier/base/notifier_options.h"
#include "jingle/notifier/listener/push_client.h"
#include "net/url_request/url_request_context_getter.h"
@@ -20,10 +20,10 @@ class URLRequestContextGetter;
namespace invalidation {
P2PInvalidationService::P2PInvalidationService(
- scoped_ptr<InvalidationAuthProvider> auth_provider,
+ scoped_ptr<IdentityProvider> identity_provider,
const scoped_refptr<net::URLRequestContextGetter>& request_context,
syncer::P2PNotificationTarget notification_target)
- : auth_provider_(auth_provider.Pass()) {
+ : identity_provider_(identity_provider.Pass()) {
notifier::NotifierOptions notifier_options =
ParseNotifierOptions(*CommandLine::ForCurrentProcess());
notifier_options.request_context_getter = request_context;
@@ -85,9 +85,8 @@ void P2PInvalidationService::RequestDetailedStatus(
caller.Run(value);
}
-InvalidationAuthProvider*
-P2PInvalidationService::GetInvalidationAuthProvider() {
- return auth_provider_.get();
+IdentityProvider* P2PInvalidationService::GetIdentityProvider() {
+ return identity_provider_.get();
}
} // namespace invalidation
diff --git a/chrome/browser/invalidation/p2p_invalidation_service.h b/chrome/browser/invalidation/p2p_invalidation_service.h
index bd4c695..f19d059 100644
--- a/chrome/browser/invalidation/p2p_invalidation_service.h
+++ b/chrome/browser/invalidation/p2p_invalidation_service.h
@@ -32,7 +32,7 @@ class P2PInvalidationService
public InvalidationService {
public:
P2PInvalidationService(
- scoped_ptr<InvalidationAuthProvider> auth_provider,
+ scoped_ptr<IdentityProvider> identity_provider,
const scoped_refptr<net::URLRequestContextGetter>& request_context,
syncer::P2PNotificationTarget notification_target);
virtual ~P2PInvalidationService();
@@ -54,7 +54,7 @@ class P2PInvalidationService
virtual InvalidationLogger* GetInvalidationLogger() OVERRIDE;
virtual void RequestDetailedStatus(
base::Callback<void(const base::DictionaryValue&)> caller) const OVERRIDE;
- virtual InvalidationAuthProvider* GetInvalidationAuthProvider() OVERRIDE;
+ virtual IdentityProvider* GetIdentityProvider() OVERRIDE;
void UpdateCredentials(const std::string& username,
const std::string& password);
@@ -62,7 +62,7 @@ class P2PInvalidationService
void SendInvalidation(const syncer::ObjectIdSet& ids);
private:
- scoped_ptr<InvalidationAuthProvider> auth_provider_;
+ scoped_ptr<IdentityProvider> identity_provider_;
scoped_ptr<syncer::P2PInvalidator> invalidator_;
std::string invalidator_id_;
diff --git a/chrome/browser/invalidation/profile_invalidation_auth_provider.h b/chrome/browser/invalidation/profile_invalidation_auth_provider.h
deleted file mode 100644
index aa98828..0000000
--- a/chrome/browser/invalidation/profile_invalidation_auth_provider.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_INVALIDATION_PROFILE_INVALIDATION_AUTH_PROVIDER_H_
-#define CHROME_BROWSER_INVALIDATION_PROFILE_INVALIDATION_AUTH_PROVIDER_H_
-
-#include "base/macros.h"
-#include "chrome/browser/invalidation/invalidation_auth_provider.h"
-#include "components/signin/core/browser/signin_manager_base.h"
-
-class LoginUIService;
-class ProfileOAuth2TokenService;
-
-namespace invalidation {
-
-// An authentication provider implementation that's backed by
-// ProfileOAuth2TokenService and SigninManager.
-class ProfileInvalidationAuthProvider : public InvalidationAuthProvider,
- public SigninManagerBase::Observer {
- public:
- ProfileInvalidationAuthProvider(SigninManagerBase* signin_manager,
- ProfileOAuth2TokenService* token_service,
- LoginUIService* login_ui_service);
- virtual ~ProfileInvalidationAuthProvider();
-
- // InvalidationAuthProvider:
- virtual std::string GetAccountId() OVERRIDE;
- virtual OAuth2TokenService* GetTokenService() OVERRIDE;
- virtual bool ShowLoginUI() OVERRIDE;
-
- // SigninManagerBase::Observer:
- virtual void GoogleSignedOut(const std::string& username) OVERRIDE;
-
- private:
- SigninManagerBase* const signin_manager_;
- ProfileOAuth2TokenService* const token_service_;
- LoginUIService* const login_ui_service_;
-
- DISALLOW_COPY_AND_ASSIGN(ProfileInvalidationAuthProvider);
-};
-
-} // namespace invalidation
-
-#endif // CHROME_BROWSER_INVALIDATION_PROFILE_INVALIDATION_AUTH_PROVIDER_H_
diff --git a/chrome/browser/invalidation/ticl_invalidation_service.cc b/chrome/browser/invalidation/ticl_invalidation_service.cc
index 2f0569b..8db9111 100644
--- a/chrome/browser/invalidation/ticl_invalidation_service.cc
+++ b/chrome/browser/invalidation/ticl_invalidation_service.cc
@@ -8,8 +8,6 @@
#include "base/metrics/histogram.h"
#include "base/prefs/pref_service.h"
#include "chrome/browser/invalidation/gcm_invalidation_bridge.h"
-#include "chrome/browser/invalidation/invalidation_auth_provider.h"
-#include "chrome/browser/invalidation/invalidation_logger.h"
#include "chrome/browser/invalidation/invalidation_service_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/services/gcm/gcm_profile_service.h"
@@ -62,12 +60,12 @@ static const net::BackoffEntry::Policy kRequestAccessTokenBackoffPolicy = {
namespace invalidation {
TiclInvalidationService::TiclInvalidationService(
- scoped_ptr<InvalidationAuthProvider> auth_provider,
+ scoped_ptr<IdentityProvider> identity_provider,
const scoped_refptr<net::URLRequestContextGetter>& request_context,
Profile* profile)
: OAuth2TokenService::Consumer("ticl_invalidation"),
profile_(profile),
- auth_provider_(auth_provider.Pass()),
+ identity_provider_(identity_provider.Pass()),
invalidator_registrar_(new syncer::InvalidatorRegistrar()),
request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy),
network_channel_type_(PUSH_CLIENT_CHANNEL),
@@ -107,8 +105,8 @@ void TiclInvalidationService::Init(
StartInvalidator(network_channel_type_);
}
- auth_provider_->AddObserver(this);
- auth_provider_->GetTokenService()->AddObserver(this);
+ identity_provider_->AddObserver(this);
+ identity_provider_->AddActiveAccountRefreshTokenObserver(this);
}
void TiclInvalidationService::InitForTest(
@@ -182,9 +180,8 @@ InvalidationLogger* TiclInvalidationService::GetInvalidationLogger() {
return &logger_;
}
-InvalidationAuthProvider*
-TiclInvalidationService::GetInvalidationAuthProvider() {
- return auth_provider_.get();
+IdentityProvider* TiclInvalidationService::GetIdentityProvider() {
+ return identity_provider_.get();
}
void TiclInvalidationService::RequestDetailedStatus(
@@ -205,8 +202,8 @@ void TiclInvalidationService::RequestAccessToken() {
oauth2_scopes.insert(kOAuth2Scopes[i]);
// Invalidate previous token, otherwise token service will return the same
// token again.
- const std::string& account_id = auth_provider_->GetAccountId();
- OAuth2TokenService* token_service = auth_provider_->GetTokenService();
+ const std::string& account_id = identity_provider_->GetActiveAccountId();
+ OAuth2TokenService* token_service = identity_provider_->GetTokenService();
token_service->InvalidateToken(account_id, oauth2_scopes, access_token_);
access_token_.clear();
access_token_request_ =
@@ -261,24 +258,18 @@ void TiclInvalidationService::OnGetTokenFailure(
void TiclInvalidationService::OnRefreshTokenAvailable(
const std::string& account_id) {
- if (auth_provider_->GetAccountId() == account_id) {
- if (!IsStarted() && IsReadyToStart()) {
- StartInvalidator(network_channel_type_);
- }
- }
+ if (!IsStarted() && IsReadyToStart())
+ StartInvalidator(network_channel_type_);
}
void TiclInvalidationService::OnRefreshTokenRevoked(
const std::string& account_id) {
- if (auth_provider_->GetAccountId() == account_id) {
- access_token_.clear();
- if (IsStarted()) {
- UpdateInvalidatorCredentials();
- }
- }
+ access_token_.clear();
+ if (IsStarted())
+ UpdateInvalidatorCredentials();
}
-void TiclInvalidationService::OnInvalidationAuthLogout() {
+void TiclInvalidationService::OnActiveAccountLogout() {
access_token_request_.reset();
request_access_token_retry_timer_.Stop();
@@ -326,8 +317,8 @@ std::string TiclInvalidationService::GetOwnerName() const { return "TICL"; }
void TiclInvalidationService::Shutdown() {
DCHECK(CalledOnValidThread());
- auth_provider_->GetTokenService()->RemoveObserver(this);
- auth_provider_->RemoveObserver(this);
+ identity_provider_->RemoveActiveAccountRefreshTokenObserver(this);
+ identity_provider_->RemoveObserver(this);
if (IsStarted()) {
StopInvalidator();
}
@@ -341,12 +332,12 @@ bool TiclInvalidationService::IsReadyToStart() {
return false;
}
- if (auth_provider_->GetAccountId().empty()) {
+ if (identity_provider_->GetActiveAccountId().empty()) {
DVLOG(2) << "Not starting TiclInvalidationService: User is not signed in.";
return false;
}
- OAuth2TokenService* token_service = auth_provider_->GetTokenService();
+ OAuth2TokenService* token_service = identity_provider_->GetTokenService();
if (!token_service) {
DVLOG(2)
<< "Not starting TiclInvalidationService: "
@@ -354,7 +345,8 @@ bool TiclInvalidationService::IsReadyToStart() {
return false;
}
- if (!token_service->RefreshTokenIsAvailable(auth_provider_->GetAccountId())) {
+ if (!token_service->RefreshTokenIsAvailable(
+ identity_provider_->GetActiveAccountId())) {
DVLOG(2)
<< "Not starting TiclInvalidationServce: Waiting for refresh token.";
return false;
@@ -404,8 +396,8 @@ void TiclInvalidationService::StartInvalidator(
case GCM_NETWORK_CHANNEL: {
gcm::GCMProfileService* gcm_profile_service =
gcm::GCMProfileServiceFactory::GetForProfile(profile_);
- gcm_invalidation_bridge_.reset(
- new GCMInvalidationBridge(gcm_profile_service, auth_provider_.get()));
+ gcm_invalidation_bridge_.reset(new GCMInvalidationBridge(
+ gcm_profile_service, identity_provider_.get()));
network_channel_creator =
syncer::NonBlockingInvalidator::MakeGCMNetworkChannelCreator(
request_context_,
@@ -454,7 +446,7 @@ void TiclInvalidationService::UpdateInvalidationNetworkChannel() {
}
void TiclInvalidationService::UpdateInvalidatorCredentials() {
- std::string email = auth_provider_->GetAccountId();
+ std::string email = identity_provider_->GetActiveAccountId();
DCHECK(!email.empty()) << "Expected user to be signed in.";
diff --git a/chrome/browser/invalidation/ticl_invalidation_service.h b/chrome/browser/invalidation/ticl_invalidation_service.h
index 290e749..c3af571 100644
--- a/chrome/browser/invalidation/ticl_invalidation_service.h
+++ b/chrome/browser/invalidation/ticl_invalidation_service.h
@@ -13,11 +13,11 @@
#include "base/threading/non_thread_safe.h"
#include "base/timer/timer.h"
#include "base/values.h"
-#include "chrome/browser/invalidation/invalidation_auth_provider.h"
#include "chrome/browser/invalidation/invalidation_logger.h"
#include "chrome/browser/invalidation/invalidation_service.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
+#include "google_apis/gaia/identity_provider.h"
#include "google_apis/gaia/oauth2_token_service.h"
#include "net/base/backoff_entry.h"
#include "sync/notifier/invalidation_handler.h"
@@ -43,7 +43,7 @@ class TiclInvalidationService : public base::NonThreadSafe,
public InvalidationService,
public OAuth2TokenService::Consumer,
public OAuth2TokenService::Observer,
- public InvalidationAuthProvider::Observer,
+ public IdentityProvider::Observer,
public syncer::InvalidationHandler {
public:
enum InvalidationNetworkChannel {
@@ -56,7 +56,7 @@ class TiclInvalidationService : public base::NonThreadSafe,
};
TiclInvalidationService(
- scoped_ptr<InvalidationAuthProvider> auth_provider,
+ scoped_ptr<IdentityProvider> identity_provider,
const scoped_refptr<net::URLRequestContextGetter>& request_context,
Profile* profile);
virtual ~TiclInvalidationService();
@@ -78,7 +78,7 @@ class TiclInvalidationService : public base::NonThreadSafe,
virtual InvalidationLogger* GetInvalidationLogger() OVERRIDE;
virtual void RequestDetailedStatus(
base::Callback<void(const base::DictionaryValue&)> caller) const OVERRIDE;
- virtual InvalidationAuthProvider* GetInvalidationAuthProvider() OVERRIDE;
+ virtual IdentityProvider* GetIdentityProvider() OVERRIDE;
void RequestAccessToken();
@@ -95,8 +95,8 @@ class TiclInvalidationService : public base::NonThreadSafe,
virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE;
virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE;
- // InvalidationAuthProvider::Observer implementation.
- virtual void OnInvalidationAuthLogout() OVERRIDE;
+ // IdentityProvider::Observer implementation.
+ virtual void OnActiveAccountLogout() OVERRIDE;
// syncer::InvalidationHandler implementation.
virtual void OnInvalidatorStateChange(
@@ -127,7 +127,7 @@ class TiclInvalidationService : public base::NonThreadSafe,
void StopInvalidator();
Profile *const profile_;
- scoped_ptr<InvalidationAuthProvider> auth_provider_;
+ scoped_ptr<IdentityProvider> identity_provider_;
scoped_ptr<syncer::InvalidatorRegistrar> invalidator_registrar_;
scoped_ptr<syncer::InvalidationStateTracker> invalidation_state_tracker_;
diff --git a/chrome/browser/invalidation/ticl_invalidation_service_unittest.cc b/chrome/browser/invalidation/ticl_invalidation_service_unittest.cc
index 0c89554..a4588a9 100644
--- a/chrome/browser/invalidation/ticl_invalidation_service_unittest.cc
+++ b/chrome/browser/invalidation/ticl_invalidation_service_unittest.cc
@@ -8,9 +8,9 @@
#include "chrome/browser/invalidation/invalidation_service_factory.h"
#include "chrome/browser/invalidation/invalidation_service_test_template.h"
#include "chrome/browser/invalidation/invalidator_storage.h"
-#include "chrome/browser/invalidation/profile_invalidation_auth_provider.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
#include "chrome/browser/signin/fake_signin_manager.h"
+#include "chrome/browser/signin/profile_identity_provider.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
@@ -42,11 +42,10 @@ class TiclInvalidationServiceTestDelegate {
profile_.reset(new TestingProfile());
token_service_.reset(new FakeProfileOAuth2TokenService);
invalidation_service_.reset(new TiclInvalidationService(
- scoped_ptr<InvalidationAuthProvider>(
- new ProfileInvalidationAuthProvider(
- SigninManagerFactory::GetForProfile(profile_.get()),
- token_service_.get(),
- NULL)),
+ scoped_ptr<IdentityProvider>(new ProfileIdentityProvider(
+ SigninManagerFactory::GetForProfile(profile_.get()),
+ token_service_.get(),
+ NULL)),
profile_->GetRequestContext(),
profile_.get()));
}
@@ -100,11 +99,10 @@ class TiclInvalidationServiceChannelTest : public ::testing::Test {
SigninManagerFactory::GetForProfile(profile_.get()));
token_service_.reset(new FakeProfileOAuth2TokenService);
- scoped_ptr<InvalidationAuthProvider> auth_provider(
- new ProfileInvalidationAuthProvider(
- fake_signin_manager_, token_service_.get(), NULL));
+ scoped_ptr<IdentityProvider> identity_provider(new ProfileIdentityProvider(
+ fake_signin_manager_, token_service_.get(), NULL));
invalidation_service_.reset(new TiclInvalidationService(
- auth_provider.Pass(),
+ identity_provider.Pass(),
profile_->GetRequestContext(),
profile_.get()));
invalidation_service_->Init(scoped_ptr<syncer::InvalidationStateTracker>(
diff --git a/chrome/browser/invalidation/profile_invalidation_auth_provider.cc b/chrome/browser/signin/profile_identity_provider.cc
index 468520d..7ae1a46 100644
--- a/chrome/browser/invalidation/profile_invalidation_auth_provider.cc
+++ b/chrome/browser/signin/profile_identity_provider.cc
@@ -2,14 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/invalidation/profile_invalidation_auth_provider.h"
+#include "chrome/browser/signin/profile_identity_provider.h"
#include "chrome/browser/ui/webui/signin/login_ui_service.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
-namespace invalidation {
-
-ProfileInvalidationAuthProvider::ProfileInvalidationAuthProvider(
+ProfileIdentityProvider::ProfileIdentityProvider(
SigninManagerBase* signin_manager,
ProfileOAuth2TokenService* token_service,
LoginUIService* login_ui_service)
@@ -19,26 +17,33 @@ ProfileInvalidationAuthProvider::ProfileInvalidationAuthProvider(
signin_manager_->AddObserver(this);
}
-ProfileInvalidationAuthProvider::~ProfileInvalidationAuthProvider() {
+ProfileIdentityProvider::~ProfileIdentityProvider() {
signin_manager_->RemoveObserver(this);
}
-std::string ProfileInvalidationAuthProvider::GetAccountId() {
+std::string ProfileIdentityProvider::GetActiveUsername() {
+ return signin_manager_->GetAuthenticatedUsername();
+}
+
+std::string ProfileIdentityProvider::GetActiveAccountId() {
return signin_manager_->GetAuthenticatedAccountId();
}
-OAuth2TokenService* ProfileInvalidationAuthProvider::GetTokenService() {
+OAuth2TokenService* ProfileIdentityProvider::GetTokenService() {
return token_service_;
}
-bool ProfileInvalidationAuthProvider::ShowLoginUI() {
+bool ProfileIdentityProvider::RequestLogin() {
login_ui_service_->ShowLoginPopup();
return true;
}
-void ProfileInvalidationAuthProvider::GoogleSignedOut(
- const std::string& username) {
- FireInvalidationAuthLogout();
+void ProfileIdentityProvider::GoogleSigninSucceeded(
+ const std::string& username,
+ const std::string& password) {
+ FireOnActiveAccountLogin();
}
-} // namespace invalidation
+void ProfileIdentityProvider::GoogleSignedOut(const std::string& username) {
+ FireOnActiveAccountLogout();
+}
diff --git a/chrome/browser/signin/profile_identity_provider.h b/chrome/browser/signin/profile_identity_provider.h
new file mode 100644
index 0000000..ca67ecf
--- /dev/null
+++ b/chrome/browser/signin/profile_identity_provider.h
@@ -0,0 +1,44 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SIGNIN_PROFILE_IDENTITY_PROVIDER_H_
+#define CHROME_BROWSER_SIGNIN_PROFILE_IDENTITY_PROVIDER_H_
+
+#include "base/macros.h"
+#include "components/signin/core/browser/signin_manager_base.h"
+#include "google_apis/gaia/identity_provider.h"
+
+class LoginUIService;
+class ProfileOAuth2TokenService;
+
+// An identity provider implementation that's backed by
+// ProfileOAuth2TokenService and SigninManager.
+class ProfileIdentityProvider : public IdentityProvider,
+ public SigninManagerBase::Observer {
+ public:
+ ProfileIdentityProvider(SigninManagerBase* signin_manager,
+ ProfileOAuth2TokenService* token_service,
+ LoginUIService* login_ui_service);
+ virtual ~ProfileIdentityProvider();
+
+ // IdentityProvider:
+ virtual std::string GetActiveUsername() OVERRIDE;
+ virtual std::string GetActiveAccountId() OVERRIDE;
+ virtual OAuth2TokenService* GetTokenService() OVERRIDE;
+ virtual bool RequestLogin() OVERRIDE;
+
+ // SigninManagerBase::Observer:
+ virtual void GoogleSigninSucceeded(const std::string& username,
+ const std::string& password) OVERRIDE;
+ virtual void GoogleSignedOut(const std::string& username) OVERRIDE;
+
+ private:
+ SigninManagerBase* const signin_manager_;
+ ProfileOAuth2TokenService* const token_service_;
+ LoginUIService* const login_ui_service_;
+
+ DISALLOW_COPY_AND_ASSIGN(ProfileIdentityProvider);
+};
+
+#endif // CHROME_BROWSER_SIGNIN_PROFILE_IDENTITY_PROVIDER_H_
diff --git a/chrome/browser/sync/test/integration/sync_test.cc b/chrome/browser/sync/test/integration/sync_test.cc
index 8572137..dea47a9 100644
--- a/chrome/browser/sync/test/integration/sync_test.cc
+++ b/chrome/browser/sync/test/integration/sync_test.cc
@@ -26,12 +26,12 @@
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/invalidation/invalidation_service_factory.h"
#include "chrome/browser/invalidation/p2p_invalidation_service.h"
-#include "chrome/browser/invalidation/profile_invalidation_auth_provider.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
+#include "chrome/browser/signin/profile_identity_provider.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service.h"
@@ -141,11 +141,10 @@ KeyedService* BuildP2PInvalidationService(
syncer::P2PNotificationTarget notification_target) {
Profile* profile = static_cast<Profile*>(context);
return new invalidation::P2PInvalidationService(
- scoped_ptr<invalidation::InvalidationAuthProvider>(
- new invalidation::ProfileInvalidationAuthProvider(
- SigninManagerFactory::GetForProfile(profile),
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
- LoginUIServiceFactory::GetForProfile(profile))),
+ scoped_ptr<IdentityProvider>(new ProfileIdentityProvider(
+ SigninManagerFactory::GetForProfile(profile),
+ ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
+ LoginUIServiceFactory::GetForProfile(profile))),
profile->GetRequestContext(),
notification_target);
}
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index bdd25d2..00213bf8 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -927,12 +927,8 @@
'browser/internal_auth.h',
'browser/intranet_redirect_detector.cc',
'browser/intranet_redirect_detector.h',
- 'browser/invalidation/device_invalidation_auth_provider_chromeos.cc',
- 'browser/invalidation/device_invalidation_auth_provider_chromeos.h',
'browser/invalidation/gcm_invalidation_bridge.cc',
'browser/invalidation/gcm_invalidation_bridge.h',
- 'browser/invalidation/invalidation_auth_provider.cc',
- 'browser/invalidation/invalidation_auth_provider.h',
'browser/invalidation/invalidation_controller_android.cc',
'browser/invalidation/invalidation_controller_android.h',
'browser/invalidation/invalidation_logger.cc',
@@ -946,8 +942,6 @@
'browser/invalidation/invalidation_service_util.h',
'browser/invalidation/invalidator_storage.cc',
'browser/invalidation/invalidator_storage.h',
- 'browser/invalidation/profile_invalidation_auth_provider.cc',
- 'browser/invalidation/profile_invalidation_auth_provider.h',
'browser/invalidation/ticl_invalidation_service.cc',
'browser/invalidation/ticl_invalidation_service.h',
'browser/io_thread.cc',
@@ -2060,6 +2054,8 @@
'browser/signin/local_auth.h',
'browser/signin/principals_message_filter.cc',
'browser/signin/principals_message_filter.h',
+ 'browser/signin/profile_identity_provider.cc',
+ 'browser/signin/profile_identity_provider.h',
'browser/signin/profile_oauth2_token_service_factory.cc',
'browser/signin/profile_oauth2_token_service_factory.h',
'browser/signin/profile_oauth2_token_service_request.cc',
diff --git a/chrome/chrome_browser_chromeos.gypi b/chrome/chrome_browser_chromeos.gypi
index a9d6a8a..1285027 100644
--- a/chrome/chrome_browser_chromeos.gypi
+++ b/chrome/chrome_browser_chromeos.gypi
@@ -850,6 +850,8 @@
'browser/chromeos/session_length_limiter.h',
'browser/chromeos/settings/cros_settings.cc',
'browser/chromeos/settings/cros_settings.h',
+ 'browser/chromeos/settings/device_identity_provider.cc',
+ 'browser/chromeos/settings/device_identity_provider.h',
'browser/chromeos/settings/device_oauth2_token_service.cc',
'browser/chromeos/settings/device_oauth2_token_service.h',
'browser/chromeos/settings/device_oauth2_token_service_factory.cc',
diff --git a/google_apis/gaia/fake_identity_provider.cc b/google_apis/gaia/fake_identity_provider.cc
new file mode 100644
index 0000000..7360e41
--- /dev/null
+++ b/google_apis/gaia/fake_identity_provider.cc
@@ -0,0 +1,40 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "google_apis/gaia/fake_identity_provider.h"
+
+#include "google_apis/gaia/oauth2_token_service.h"
+
+FakeIdentityProvider::FakeIdentityProvider(OAuth2TokenService* token_service)
+ : token_service_(token_service) {
+}
+
+FakeIdentityProvider::~FakeIdentityProvider() {
+}
+
+void FakeIdentityProvider::LogIn(const std::string& account_id) {
+ account_id_ = account_id;
+ FireOnActiveAccountLogin();
+}
+
+void FakeIdentityProvider::LogOut() {
+ account_id_.clear();
+ FireOnActiveAccountLogout();
+}
+
+std::string FakeIdentityProvider::GetActiveUsername() {
+ return account_id_;
+}
+
+std::string FakeIdentityProvider::GetActiveAccountId() {
+ return account_id_;
+}
+
+OAuth2TokenService* FakeIdentityProvider::GetTokenService() {
+ return token_service_;
+}
+
+bool FakeIdentityProvider::RequestLogin() {
+ return false;
+}
diff --git a/google_apis/gaia/fake_identity_provider.h b/google_apis/gaia/fake_identity_provider.h
new file mode 100644
index 0000000..28d46d9
--- /dev/null
+++ b/google_apis/gaia/fake_identity_provider.h
@@ -0,0 +1,38 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GOOGLE_APIS_GAIA_FAKE_IDENTITY_PROVIDER_H_
+#define GOOGLE_APIS_GAIA_FAKE_IDENTITY_PROVIDER_H_
+
+#include <string>
+
+#include "base/compiler_specific.h"
+#include "base/macros.h"
+#include "google_apis/gaia/identity_provider.h"
+
+class OAuth2TokenService;
+
+// Fake identity provider implementation.
+class FakeIdentityProvider : public IdentityProvider {
+ public:
+ explicit FakeIdentityProvider(OAuth2TokenService* token_service);
+ virtual ~FakeIdentityProvider();
+
+ void LogIn(const std::string& account_id);
+ void LogOut();
+
+ // IdentityProvider:
+ virtual std::string GetActiveUsername() OVERRIDE;
+ virtual std::string GetActiveAccountId() OVERRIDE;
+ virtual OAuth2TokenService* GetTokenService() OVERRIDE;
+ virtual bool RequestLogin() OVERRIDE;
+
+ private:
+ std::string account_id_;
+ OAuth2TokenService* token_service_;
+
+ DISALLOW_COPY_AND_ASSIGN(FakeIdentityProvider);
+};
+
+#endif // GOOGLE_APIS_GAIA_FAKE_IDENTITY_PROVIDER_H_
diff --git a/google_apis/gaia/identity_provider.cc b/google_apis/gaia/identity_provider.cc
new file mode 100644
index 0000000..842891e
--- /dev/null
+++ b/google_apis/gaia/identity_provider.cc
@@ -0,0 +1,71 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "google_apis/gaia/identity_provider.h"
+
+IdentityProvider::Observer::~Observer() {}
+
+IdentityProvider::~IdentityProvider() {}
+
+void IdentityProvider::AddActiveAccountRefreshTokenObserver(
+ OAuth2TokenService::Observer* observer) {
+ OAuth2TokenService* token_service = GetTokenService();
+ if (!token_service || token_service_observers_.HasObserver(observer))
+ return;
+
+ token_service_observers_.AddObserver(observer);
+ if (++token_service_observer_count_ == 1)
+ token_service->AddObserver(this);
+}
+
+void IdentityProvider::RemoveActiveAccountRefreshTokenObserver(
+ OAuth2TokenService::Observer* observer) {
+ OAuth2TokenService* token_service = GetTokenService();
+ if (!token_service || !token_service_observers_.HasObserver(observer))
+ return;
+
+ token_service_observers_.RemoveObserver(observer);
+ if (--token_service_observer_count_ == 0)
+ token_service->RemoveObserver(this);
+}
+
+void IdentityProvider::AddObserver(Observer* observer) {
+ observers_.AddObserver(observer);
+}
+
+void IdentityProvider::RemoveObserver(Observer* observer) {
+ observers_.RemoveObserver(observer);
+}
+
+void IdentityProvider::OnRefreshTokenAvailable(const std::string& account_id) {
+ if (account_id != GetActiveAccountId())
+ return;
+ FOR_EACH_OBSERVER(OAuth2TokenService::Observer,
+ token_service_observers_,
+ OnRefreshTokenAvailable(account_id));
+}
+
+void IdentityProvider::OnRefreshTokenRevoked(const std::string& account_id) {
+ if (account_id != GetActiveAccountId())
+ return;
+ FOR_EACH_OBSERVER(OAuth2TokenService::Observer,
+ token_service_observers_,
+ OnRefreshTokenRevoked(account_id));
+}
+
+void IdentityProvider::OnRefreshTokensLoaded() {
+ FOR_EACH_OBSERVER(OAuth2TokenService::Observer,
+ token_service_observers_,
+ OnRefreshTokensLoaded());
+}
+
+IdentityProvider::IdentityProvider() : token_service_observer_count_(0) {}
+
+void IdentityProvider::FireOnActiveAccountLogin() {
+ FOR_EACH_OBSERVER(Observer, observers_, OnActiveAccountLogin());
+}
+
+void IdentityProvider::FireOnActiveAccountLogout() {
+ FOR_EACH_OBSERVER(Observer, observers_, OnActiveAccountLogout());
+}
diff --git a/google_apis/gaia/identity_provider.h b/google_apis/gaia/identity_provider.h
new file mode 100644
index 0000000..e0e99ee
--- /dev/null
+++ b/google_apis/gaia/identity_provider.h
@@ -0,0 +1,93 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GOOGLE_APIS_GAIA_IDENTITY_PROVIDER_H_
+#define GOOGLE_APIS_GAIA_IDENTITY_PROVIDER_H_
+
+#include <string>
+
+#include "base/compiler_specific.h"
+#include "base/macros.h"
+#include "base/observer_list.h"
+#include "google_apis/gaia/oauth2_token_service.h"
+
+// Helper class that provides access to information about logged-in GAIA
+// accounts. Each instance of this class references an entity who may be logged
+// in to zero, one or multiple GAIA accounts. The class provides access to the
+// OAuth tokens for all logged-in accounts and indicates which of these is
+// currently active.
+// The main purpose of this abstraction layer is to isolate consumers of GAIA
+// information from the different sources and various token service
+// implementations. Whenever possible, consumers of GAIA information should be
+// provided with an instance of this class instead of accessing other GAIA APIs
+// directly.
+class IdentityProvider : public OAuth2TokenService::Observer {
+ public:
+ class Observer {
+ public:
+ // Called when a GAIA account logs in and becomes the active account. All
+ // account information is available when this method is called and all
+ // |IdentityProvider| methods will return valid data.
+ virtual void OnActiveAccountLogin() {}
+
+ // Called when the active GAIA account logs out. The account information may
+ // have been cleared already when this method is called. The
+ // |IdentityProvider| methods may return inconsistent or outdated
+ // information if called from within OnLogout().
+ virtual void OnActiveAccountLogout() {}
+
+ protected:
+ virtual ~Observer();
+ };
+
+ virtual ~IdentityProvider();
+
+ // Adds and removes observers that will be notified of changes to the refresh
+ // token availability for the active account.
+ void AddActiveAccountRefreshTokenObserver(
+ OAuth2TokenService::Observer* observer);
+ void RemoveActiveAccountRefreshTokenObserver(
+ OAuth2TokenService::Observer* observer);
+
+ // Gets the active account's user name.
+ virtual std::string GetActiveUsername() = 0;
+
+ // Gets the active account's account ID.
+ virtual std::string GetActiveAccountId() = 0;
+
+ // Gets the token service vending OAuth tokens for all logged-in accounts.
+ virtual OAuth2TokenService* GetTokenService() = 0;
+
+ // Requests login to a GAIA account. Implementations can show a login UI, log
+ // in automatically if sufficient credentials are available or may ignore the
+ // request. Returns true if the login request was processed and false if it
+ // was ignored.
+ virtual bool RequestLogin() = 0;
+
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
+ // OAuth2TokenService::Observer:
+ virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE;
+ virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE;
+ virtual void OnRefreshTokensLoaded() OVERRIDE;
+
+ protected:
+ IdentityProvider();
+
+ // Fires an OnActiveAccountLogin notification.
+ void FireOnActiveAccountLogin();
+
+ // Fires an OnActiveAccountLogout notification.
+ void FireOnActiveAccountLogout();
+
+ private:
+ ObserverList<Observer, true> observers_;
+ ObserverList<OAuth2TokenService::Observer, true> token_service_observers_;
+ int token_service_observer_count_;
+
+ DISALLOW_COPY_AND_ASSIGN(IdentityProvider);
+};
+
+#endif // GOOGLE_APIS_GAIA_IDENTITY_PROVIDER_H_
diff --git a/google_apis/google_apis.gyp b/google_apis/google_apis.gyp
index be4d517..ec9c8c8 100644
--- a/google_apis/google_apis.gyp
+++ b/google_apis/google_apis.gyp
@@ -111,6 +111,8 @@
'gaia/gaia_urls.h',
'gaia/google_service_auth_error.cc',
'gaia/google_service_auth_error.h',
+ 'gaia/identity_provider.cc',
+ 'gaia/identity_provider.h',
'gaia/merge_session_helper.cc',
'gaia/merge_session_helper.h',
'gaia/oauth_request_signer.cc',
@@ -210,6 +212,8 @@
'drive/test_util.h',
'gaia/fake_gaia.cc',
'gaia/fake_gaia.h',
+ 'gaia/fake_identity_provider.cc',
+ 'gaia/fake_identity_provider.h',
'gaia/fake_oauth2_token_service.cc',
'gaia/fake_oauth2_token_service.h',
'gaia/mock_url_fetcher_factory.h',