profile_identity_provider.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_INVALIDATION_IMPL_PROFILE_IDENTITY_PROVIDER_H_
  5. #define COMPONENTS_INVALIDATION_IMPL_PROFILE_IDENTITY_PROVIDER_H_
  6. #include "base/memory/raw_ptr.h"
  7. #include "build/build_config.h"
  8. #include "components/invalidation/public/identity_provider.h"
  9. #include "components/signin/public/identity_manager/identity_manager.h"
  10. namespace invalidation {
  11. // An identity provider implementation that's backed by IdentityManager
  12. class ProfileIdentityProvider : public IdentityProvider,
  13. public signin::IdentityManager::Observer {
  14. public:
  15. explicit ProfileIdentityProvider(signin::IdentityManager* identity_manager);
  16. ProfileIdentityProvider(const ProfileIdentityProvider& other) = delete;
  17. ProfileIdentityProvider& operator=(const ProfileIdentityProvider& other) =
  18. delete;
  19. ~ProfileIdentityProvider() override;
  20. // IdentityProvider:
  21. CoreAccountId GetActiveAccountId() override;
  22. bool IsActiveAccountWithRefreshToken() override;
  23. std::unique_ptr<ActiveAccountAccessTokenFetcher> FetchAccessToken(
  24. const std::string& oauth_consumer_name,
  25. const signin::ScopeSet& scopes,
  26. ActiveAccountAccessTokenCallback callback) override;
  27. void InvalidateAccessToken(const signin::ScopeSet& scopes,
  28. const std::string& access_token) override;
  29. // signin::IdentityManager::Observer:
  30. void OnPrimaryAccountChanged(
  31. const signin::PrimaryAccountChangeEvent& event_details) override;
  32. void OnRefreshTokenUpdatedForAccount(
  33. const CoreAccountInfo& account_info) override;
  34. void OnRefreshTokenRemovedForAccount(
  35. const CoreAccountId& account_id) override;
  36. private:
  37. const raw_ptr<signin::IdentityManager> identity_manager_;
  38. CoreAccountId active_account_id_;
  39. };
  40. } // namespace invalidation
  41. #endif // COMPONENTS_INVALIDATION_IMPL_PROFILE_IDENTITY_PROVIDER_H_