- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / login / enrollment / enrollment_screen.h
1 // Copyright (c) 2012 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_LOGIN_ENROLLMENT_ENROLLMENT_SCREEN_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_ENROLLMENT_SCREEN_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen_actor.h"
14 #include "chrome/browser/chromeos/login/screens/wizard_screen.h"
15 #include "chrome/browser/policy/cloud/cloud_policy_constants.h"
16
17 namespace chromeos {
18
19 class ScreenObserver;
20
21 // The screen implementation that links the enterprise enrollment UI into the
22 // OOBE wizard.
23 class EnrollmentScreen
24     : public WizardScreen,
25       public EnrollmentScreenActor::Controller {
26  public:
27   EnrollmentScreen(ScreenObserver* observer,
28                    EnrollmentScreenActor* actor);
29   virtual ~EnrollmentScreen();
30
31   void SetParameters(bool is_auto_enrollment,
32                      bool can_exit_enrollment,
33                      const std::string& enrollment_user);
34
35   // WizardScreen implementation:
36   virtual void PrepareToShow() OVERRIDE;
37   virtual void Show() OVERRIDE;
38   virtual void Hide() OVERRIDE;
39   virtual std::string GetName() const OVERRIDE;
40
41   // EnrollmentScreenActor::Controller implementation:
42   virtual void OnLoginDone(const std::string& user) OVERRIDE;
43   virtual void OnAuthError(const GoogleServiceAuthError& error) OVERRIDE;
44   virtual void OnOAuthTokenAvailable(const std::string& oauth_token) OVERRIDE;
45   virtual void OnRetry() OVERRIDE;
46   virtual void OnCancel() OVERRIDE;
47   virtual void OnConfirmationClosed() OVERRIDE;
48
49   // Used for testing.
50   EnrollmentScreenActor* GetActor() {
51     return actor_;
52   }
53
54  private:
55   // Starts the Lockbox storage process.
56   void WriteInstallAttributesData();
57
58   // Kicks off the policy infrastructure to register with the service.
59   void RegisterForDevicePolicy(const std::string& token);
60
61   // Handles enrollment completion. Logs a UMA sample and requests the actor to
62   // show the specified enrollment status.
63   void ReportEnrollmentStatus(policy::EnrollmentStatus status);
64
65   // Logs a UMA event in the kMetricEnrollment histogram. If auto-enrollment is
66   // on |sample| is ignored and a kMetricEnrollmentAutoFailed sample is logged
67   // instead.
68   void UMAFailure(int sample);
69
70   // Shows the signin screen. Used as a callback to run after auth reset.
71   void ShowSigninScreen();
72
73   EnrollmentScreenActor* actor_;
74   bool is_auto_enrollment_;
75   bool can_exit_enrollment_;
76   bool enrollment_failed_once_;
77   std::string user_;
78   int lockbox_init_duration_;
79   base::WeakPtrFactory<EnrollmentScreen> weak_ptr_factory_;
80
81   DISALLOW_COPY_AND_ASSIGN(EnrollmentScreen);
82 };
83
84 }  // namespace chromeos
85
86 #endif  // CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_ENROLLMENT_SCREEN_H_