ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / chrome / browser / chromeos / login / enrollment / auto_enrollment_check_screen.h
blobf903b9523370ddaf34b35a40688e74364451c0f8
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_AUTO_ENROLLMENT_CHECK_SCREEN_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_AUTO_ENROLLMENT_CHECK_SCREEN_H_
8 #include "base/compiler_specific.h"
9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_check_screen_actor.h"
13 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h"
14 #include "chrome/browser/chromeos/login/screens/base_screen.h"
15 #include "chrome/browser/chromeos/login/screens/network_error.h"
16 #include "chromeos/network/portal_detector/network_portal_detector.h"
18 namespace chromeos {
20 class BaseScreenDelegate;
21 class ErrorScreensHistogramHelper;
22 class ScreenManager;
24 // Handles the control flow after OOBE auto-update completes to wait for the
25 // enterprise auto-enrollment check that happens as part of OOBE. This includes
26 // keeping track of current auto-enrollment state and displaying and updating
27 // the error screen upon failures. Similar to a screen controller, but it
28 // doesn't actually drive a dedicated screen.
29 class AutoEnrollmentCheckScreen
30 : public AutoEnrollmentCheckScreenActor::Delegate,
31 public BaseScreen,
32 public NetworkPortalDetector::Observer {
33 public:
34 AutoEnrollmentCheckScreen(BaseScreenDelegate* base_screen_delegate,
35 AutoEnrollmentCheckScreenActor* actor);
36 ~AutoEnrollmentCheckScreen() override;
38 static AutoEnrollmentCheckScreen* Get(ScreenManager* manager);
40 // Clears the cached state causing the forced enrollment check to be retried.
41 void ClearState();
43 void set_auto_enrollment_controller(
44 AutoEnrollmentController* auto_enrollment_controller) {
45 auto_enrollment_controller_ = auto_enrollment_controller;
48 // BaseScreen implementation:
49 void PrepareToShow() override;
50 void Show() override;
51 void Hide() override;
52 std::string GetName() const override;
54 // AutoEnrollmentCheckScreenActor::Delegate implementation:
55 void OnActorDestroyed(AutoEnrollmentCheckScreenActor* actor) override;
57 // NetworkPortalDetector::Observer implementation:
58 void OnPortalDetectionCompleted(
59 const NetworkState* network,
60 const NetworkPortalDetector::CaptivePortalState& state) override;
62 private:
63 // Handles update notifications regarding the auto-enrollment check.
64 void OnAutoEnrollmentCheckProgressed(policy::AutoEnrollmentState state);
66 // Handles a state update, updating the UI and saving the state.
67 void UpdateState();
69 // Configures the UI to reflect |new_captive_portal_status|. Returns true if
70 // and only if a UI change has been made.
71 bool UpdateCaptivePortalStatus(
72 NetworkPortalDetector::CaptivePortalStatus new_captive_portal_status);
74 // Configures the UI to reflect |auto_enrollment_state|. Returns true if and
75 // only if a UI change has been made.
76 bool UpdateAutoEnrollmentState(
77 policy::AutoEnrollmentState auto_enrollment_state);
79 // Configures the error screen.
80 void ShowErrorScreen(NetworkError::ErrorState error_state);
82 // Asynchronously signals completion. The owner might destroy |this| in
83 // response, so no code should be run after the completion of a message loop
84 // task, in which this function was called.
85 void SignalCompletion();
87 // Returns whether enrollment check was completed and decision was made.
88 bool IsCompleted() const;
90 AutoEnrollmentCheckScreenActor* actor_;
91 AutoEnrollmentController* auto_enrollment_controller_;
93 scoped_ptr<AutoEnrollmentController::ProgressCallbackList::Subscription>
94 auto_enrollment_progress_subscription_;
96 NetworkPortalDetector::CaptivePortalStatus captive_portal_status_;
97 policy::AutoEnrollmentState auto_enrollment_state_;
99 scoped_ptr<ErrorScreensHistogramHelper> histogram_helper_;
101 base::WeakPtrFactory<AutoEnrollmentCheckScreen> weak_ptr_factory_;
103 DISALLOW_COPY_AND_ASSIGN(AutoEnrollmentCheckScreen);
106 } // namespace chromeos
108 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_AUTO_ENROLLMENT_CHECK_SCREEN_H_