Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / chromeos / policy / consumer_enrollment_handler.h
blob055ba8506728fa584f85c3e0950bb5d086477e60
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.
5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_ENROLLMENT_HANDLER_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_ENROLLMENT_HANDLER_H_
8 #include <string>
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.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"
16 class Profile;
18 namespace policy {
20 class ConsumerManagementService;
21 class ConsumerManagementStage;
22 class DeviceManagementService;
23 class EnrollmentStatus;
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;
38 void Shutdown() override;
40 // OAuth2TokenService::Observer:
41 void OnRefreshTokenAvailable(const std::string& account_id) override;
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;
52 OAuth2TokenService::Request* GetTokenRequestForTesting() {
53 return token_request_.get();
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();
61 // Called when the owner's refresh token is available.
62 void OnOwnerRefreshTokenAvailable();
64 // Called when the owner's access token for device management is available.
65 void OnOwnerAccessTokenAvailable(const std::string& access_token);
67 // Called upon the completion of the enrollment process.
68 void OnEnrollmentCompleted(EnrollmentStatus status);
70 // Ends the enrollment process.
71 void EndEnrollment(const ConsumerManagementStage& stage);
73 Profile* profile_;
74 ConsumerManagementService* consumer_management_service_;
75 DeviceManagementService* device_management_service_;
76 std::string gaia_account_id_;
78 scoped_ptr<OAuth2TokenService::Request> token_request_;
79 base::WeakPtrFactory<ConsumerEnrollmentHandler> weak_ptr_factory_;
81 DISALLOW_COPY_AND_ASSIGN(ConsumerEnrollmentHandler);
84 } // namespace policy
86 #endif // CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_ENROLLMENT_HANDLER_H_