| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CRYPTAUTH_CHROME_CRYPTAUTH_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CRYPTAUTH_CHROME_CRYPTAUTH_SERVICE_H_ |
| 6 #define CHROME_BROWSER_CRYPTAUTH_CHROME_CRYPTAUTH_SERVICE_H_ | 6 #define CHROME_BROWSER_CRYPTAUTH_CHROME_CRYPTAUTH_SERVICE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "components/cryptauth/cryptauth_enrollment_manager.h" |
| 11 #include "components/cryptauth/cryptauth_service.h" | 12 #include "components/cryptauth/cryptauth_service.h" |
| 12 #include "components/cryptauth/proto/cryptauth_api.pb.h" | 13 #include "components/cryptauth/proto/cryptauth_api.pb.h" |
| 13 #include "components/keyed_service/core/keyed_service.h" | 14 #include "components/keyed_service/core/keyed_service.h" |
| 14 #include "google_apis/gaia/oauth2_token_service.h" | 15 #include "google_apis/gaia/oauth2_token_service.h" |
| 15 | 16 |
| 16 class Profile; | 17 class Profile; |
| 17 | 18 |
| 18 namespace cryptauth { | 19 namespace cryptauth { |
| 19 class CryptAuthGCMManager; | 20 class CryptAuthGCMManager; |
| 20 } // namespace cryptauth | 21 } // namespace cryptauth |
| 21 | 22 |
| 22 // Implementation of cryptauth::CryptAuthService. | 23 // Implementation of cryptauth::CryptAuthService. |
| 23 class ChromeCryptAuthService : public KeyedService, | 24 class ChromeCryptAuthService |
| 24 public cryptauth::CryptAuthService, | 25 : public KeyedService, |
| 25 public OAuth2TokenService::Observer { | 26 public cryptauth::CryptAuthService, |
| 27 public cryptauth::CryptAuthEnrollmentManager::Observer, |
| 28 public OAuth2TokenService::Observer { |
| 26 public: | 29 public: |
| 27 static std::unique_ptr<ChromeCryptAuthService> Create(Profile* profile); | 30 static std::unique_ptr<ChromeCryptAuthService> Create(Profile* profile); |
| 28 ~ChromeCryptAuthService() override; | 31 ~ChromeCryptAuthService() override; |
| 29 | 32 |
| 30 // KeyedService: | 33 // KeyedService: |
| 31 void Shutdown() override; | 34 void Shutdown() override; |
| 32 | 35 |
| 33 // cryptauth::CryptAuthService: | 36 // cryptauth::CryptAuthService: |
| 34 cryptauth::CryptAuthDeviceManager* GetCryptAuthDeviceManager() override; | 37 cryptauth::CryptAuthDeviceManager* GetCryptAuthDeviceManager() override; |
| 35 cryptauth::CryptAuthEnrollmentManager* GetCryptAuthEnrollmentManager() | 38 cryptauth::CryptAuthEnrollmentManager* GetCryptAuthEnrollmentManager() |
| 36 override; | 39 override; |
| 37 cryptauth::DeviceClassifier GetDeviceClassifier() override; | 40 cryptauth::DeviceClassifier GetDeviceClassifier() override; |
| 38 std::string GetAccountId() override; | 41 std::string GetAccountId() override; |
| 39 std::unique_ptr<cryptauth::SecureMessageDelegate> | 42 std::unique_ptr<cryptauth::SecureMessageDelegate> |
| 40 CreateSecureMessageDelegate() override; | 43 CreateSecureMessageDelegate() override; |
| 41 std::unique_ptr<cryptauth::CryptAuthClientFactory> | 44 std::unique_ptr<cryptauth::CryptAuthClientFactory> |
| 42 CreateCryptAuthClientFactory() override; | 45 CreateCryptAuthClientFactory() override; |
| 43 | 46 |
| 47 // cryptauth::CryptAuthEnrollmentManager::Observer: |
| 48 void OnEnrollmentStarted() override; |
| 49 void OnEnrollmentFinished(bool success) override; |
| 50 |
| 44 protected: | 51 protected: |
| 45 // Note: ChromeCryptAuthServiceFactory DependsOn(OAuth2TokenServiceFactory), | 52 // Note: ChromeCryptAuthServiceFactory DependsOn(OAuth2TokenServiceFactory), |
| 46 // so |token_service| is guaranteed to outlast this service. | 53 // so |token_service| is guaranteed to outlast this service. |
| 47 ChromeCryptAuthService( | 54 ChromeCryptAuthService( |
| 48 std::unique_ptr<cryptauth::CryptAuthGCMManager> gcm_manager, | 55 std::unique_ptr<cryptauth::CryptAuthGCMManager> gcm_manager, |
| 49 std::unique_ptr<cryptauth::CryptAuthDeviceManager> device_manager, | 56 std::unique_ptr<cryptauth::CryptAuthDeviceManager> device_manager, |
| 50 std::unique_ptr<cryptauth::CryptAuthEnrollmentManager> enrollment_manager, | 57 std::unique_ptr<cryptauth::CryptAuthEnrollmentManager> enrollment_manager, |
| 51 Profile* profile, | 58 Profile* profile, |
| 52 OAuth2TokenService* token_service); | 59 OAuth2TokenService* token_service); |
| 53 | 60 |
| 54 private: | 61 private: |
| 55 // OAuth2TokenService::Observer: | 62 // OAuth2TokenService::Observer: |
| 56 void OnRefreshTokenAvailable(const std::string& account_id) override; | 63 void OnRefreshTokenAvailable(const std::string& account_id) override; |
| 57 | 64 |
| 65 void PerformEnrollmentAndDeviceSync(); |
| 66 |
| 58 std::unique_ptr<cryptauth::CryptAuthGCMManager> gcm_manager_; | 67 std::unique_ptr<cryptauth::CryptAuthGCMManager> gcm_manager_; |
| 59 std::unique_ptr<cryptauth::CryptAuthEnrollmentManager> enrollment_manager_; | 68 std::unique_ptr<cryptauth::CryptAuthEnrollmentManager> enrollment_manager_; |
| 60 std::unique_ptr<cryptauth::CryptAuthDeviceManager> device_manager_; | 69 std::unique_ptr<cryptauth::CryptAuthDeviceManager> device_manager_; |
| 61 Profile* profile_; | 70 Profile* profile_; |
| 62 OAuth2TokenService* token_service_; | 71 OAuth2TokenService* token_service_; |
| 63 | 72 |
| 64 DISALLOW_COPY_AND_ASSIGN(ChromeCryptAuthService); | 73 DISALLOW_COPY_AND_ASSIGN(ChromeCryptAuthService); |
| 65 }; | 74 }; |
| 66 | 75 |
| 67 #endif // CHROME_BROWSER_CRYPTAUTH_CHROME_CRYPTAUTH_SERVICE_H_ | 76 #endif // CHROME_BROWSER_CRYPTAUTH_CHROME_CRYPTAUTH_SERVICE_H_ |
| OLD | NEW |