Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / chromeos / login / enrollment / enterprise_enrollment_helper_impl.h
blob08e5cd147325bc738b02149b6911155ab95efed2
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_LOGIN_ENROLLMENT_ENTERPRISE_ENROLLMENT_HELPER_IMPL_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_ENTERPRISE_ENROLLMENT_HELPER_IMPL_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/macros.h"
14 #include "base/memory/scoped_vector.h"
15 #include "base/memory/weak_ptr.h"
16 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_helper.h"
17 #include "chrome/browser/chromeos/policy/enrollment_config.h"
18 #include "components/policy/core/common/cloud/enterprise_metrics.h"
19 #include "google_apis/gaia/google_service_auth_error.h"
21 class Profile;
23 namespace policy {
24 class PolicyOAuth2TokenFetcher;
27 namespace chromeos {
29 class EnterpriseEnrollmentHelperImpl : public EnterpriseEnrollmentHelper {
30 public:
31 EnterpriseEnrollmentHelperImpl(
32 EnrollmentStatusConsumer* status_consumer,
33 const policy::EnrollmentConfig& enrollment_config,
34 const std::string& enrolling_user_domain);
35 ~EnterpriseEnrollmentHelperImpl() override;
37 // Overridden from EnterpriseEnrollmentHelper:
38 void EnrollUsingAuthCode(const std::string& auth_code,
39 bool fetch_additional_token) override;
40 void EnrollUsingToken(const std::string& token) override;
41 void ClearAuth(const base::Closure& callback) override;
42 void GetDeviceAttributeUpdatePermission() override;
43 void UpdateDeviceAttributes(const std::string& asset_id,
44 const std::string& location) override;
46 private:
47 void DoEnrollUsingToken(const std::string& token);
49 // Handles completion of the OAuth2 token fetch attempt.
50 void OnTokenFetched(bool is_additional_token,
51 const std::string& token,
52 const GoogleServiceAuthError& error);
54 // Handles completion of the enrollment attempt.
55 void OnEnrollmentFinished(policy::EnrollmentStatus status);
57 // Handles completion of the device attribute update permission request.
58 void OnDeviceAttributeUpdatePermission(bool granted);
60 // Handles completion of the device attribute update attempt.
61 void OnDeviceAttributeUploadCompleted(bool success);
63 void ReportAuthStatus(const GoogleServiceAuthError& error);
64 void ReportEnrollmentStatus(policy::EnrollmentStatus status);
66 // Logs an UMA event in the kMetricEnrollment or the kMetricEnrollmentRecovery
67 // histogram, depending on |enrollment_mode_|.
68 void UMA(policy::MetricEnrollment sample);
70 // Called by ProfileHelper when a signin profile clearance has finished.
71 // |callback| is a callback, that was passed to ClearAuth() before.
72 void OnSigninProfileCleared(const base::Closure& callback);
74 const policy::EnrollmentConfig enrollment_config_;
75 const std::string enrolling_user_domain_;
76 bool fetch_additional_token_;
78 bool started_;
79 std::string additional_token_;
80 bool finished_;
81 bool success_;
82 bool auth_data_cleared_;
83 std::string oauth_token_;
85 scoped_ptr<policy::PolicyOAuth2TokenFetcher> oauth_fetcher_;
87 base::WeakPtrFactory<EnterpriseEnrollmentHelperImpl> weak_ptr_factory_;
89 DISALLOW_COPY_AND_ASSIGN(EnterpriseEnrollmentHelperImpl);
92 } // namespace chromeos
94 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_ENTERPRISE_ENROLLMENT_HELPER_IMPL_H_