| OLD | NEW |
| (Empty) |
| 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 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_ENROLLMENT_HANDLER_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_ENROLLMENT_HANDLER_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "components/keyed_service/core/keyed_service.h" | |
| 14 #include "google_apis/gaia/oauth2_token_service.h" | |
| 15 | |
| 16 class Profile; | |
| 17 | |
| 18 namespace policy { | |
| 19 | |
| 20 class ConsumerManagementService; | |
| 21 class ConsumerManagementStage; | |
| 22 class DeviceManagementService; | |
| 23 class EnrollmentStatus; | |
| 24 | |
| 25 // Consumer enrollment handler automatically continues the enrollment process | |
| 26 // after the owner ID is stored in the boot lockbox and thw owner signs in. | |
| 27 class ConsumerEnrollmentHandler | |
| 28 : public KeyedService, | |
| 29 public OAuth2TokenService::Consumer, | |
| 30 public OAuth2TokenService::Observer { | |
| 31 public: | |
| 32 ConsumerEnrollmentHandler( | |
| 33 Profile* profile, | |
| 34 ConsumerManagementService* consumer_management_service, | |
| 35 DeviceManagementService* device_management_service); | |
| 36 ~ConsumerEnrollmentHandler() override; | |
| 37 | |
| 38 void Shutdown() override; | |
| 39 | |
| 40 // OAuth2TokenService::Observer: | |
| 41 void OnRefreshTokenAvailable(const std::string& account_id) override; | |
| 42 | |
| 43 // OAuth2TokenService::Consumer: | |
| 44 void OnGetTokenSuccess( | |
| 45 const OAuth2TokenService::Request* request, | |
| 46 const std::string& access_token, | |
| 47 const base::Time& expiration_time) override; | |
| 48 void OnGetTokenFailure( | |
| 49 const OAuth2TokenService::Request* request, | |
| 50 const GoogleServiceAuthError& error) override; | |
| 51 | |
| 52 OAuth2TokenService::Request* GetTokenRequestForTesting() { | |
| 53 return token_request_.get(); | |
| 54 } | |
| 55 | |
| 56 private: | |
| 57 // Continues the enrollment process after the owner ID is stored into the boot | |
| 58 // lockbox and the owner signs in. | |
| 59 void ContinueEnrollmentProcess(); | |
| 60 | |
| 61 // Called when the owner's refresh token is available. | |
| 62 void OnOwnerRefreshTokenAvailable(); | |
| 63 | |
| 64 // Called when the owner's access token for device management is available. | |
| 65 void OnOwnerAccessTokenAvailable(const std::string& access_token); | |
| 66 | |
| 67 // Called upon the completion of the enrollment process. | |
| 68 void OnEnrollmentCompleted(EnrollmentStatus status); | |
| 69 | |
| 70 // Ends the enrollment process. | |
| 71 void EndEnrollment(const ConsumerManagementStage& stage); | |
| 72 | |
| 73 Profile* profile_; | |
| 74 ConsumerManagementService* consumer_management_service_; | |
| 75 DeviceManagementService* device_management_service_; | |
| 76 std::string gaia_account_id_; | |
| 77 | |
| 78 std::unique_ptr<OAuth2TokenService::Request> token_request_; | |
| 79 base::WeakPtrFactory<ConsumerEnrollmentHandler> weak_ptr_factory_; | |
| 80 | |
| 81 DISALLOW_COPY_AND_ASSIGN(ConsumerEnrollmentHandler); | |
| 82 }; | |
| 83 | |
| 84 } // namespace policy | |
| 85 | |
| 86 #endif // CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_ENROLLMENT_HANDLER_H_ | |
| OLD | NEW |