Elim cr-checkbox
[chromium-blink-merge.git] / chrome / browser / chromeos / login / enrollment / auto_enrollment_check_screen.h
blob292e5a73d098bdf009e435076a83b6be9c12c273
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/error_screen.h"
16 #include "chrome/browser/chromeos/login/screens/network_error.h"
17 #include "chromeos/network/portal_detector/network_portal_detector.h"
19 namespace chromeos {
21 class BaseScreenDelegate;
22 class ErrorScreensHistogramHelper;
23 class ScreenManager;
25 // Handles the control flow after OOBE auto-update completes to wait for the
26 // enterprise auto-enrollment check that happens as part of OOBE. This includes
27 // keeping track of current auto-enrollment state and displaying and updating
28 // the error screen upon failures. Similar to a screen controller, but it
29 // doesn't actually drive a dedicated screen.
30 class AutoEnrollmentCheckScreen
31 : public AutoEnrollmentCheckScreenActor::Delegate,
32 public BaseScreen,
33 public NetworkPortalDetector::Observer {
34 public:
35 AutoEnrollmentCheckScreen(BaseScreenDelegate* base_screen_delegate,
36 AutoEnrollmentCheckScreenActor* actor);
37 ~AutoEnrollmentCheckScreen() override;
39 static AutoEnrollmentCheckScreen* Get(ScreenManager* manager);
41 // Clears the cached state causing the forced enrollment check to be retried.
42 void ClearState();
44 void set_auto_enrollment_controller(
45 AutoEnrollmentController* auto_enrollment_controller) {
46 auto_enrollment_controller_ = auto_enrollment_controller;
49 // BaseScreen implementation:
50 void PrepareToShow() override;
51 void Show() override;
52 void Hide() override;
53 std::string GetName() const override;
55 // AutoEnrollmentCheckScreenActor::Delegate implementation:
56 void OnActorDestroyed(AutoEnrollmentCheckScreenActor* actor) override;
58 // NetworkPortalDetector::Observer implementation:
59 void OnPortalDetectionCompleted(
60 const NetworkState* network,
61 const NetworkPortalDetector::CaptivePortalState& state) override;
63 private:
64 // Handles update notifications regarding the auto-enrollment check.
65 void OnAutoEnrollmentCheckProgressed(policy::AutoEnrollmentState state);
67 // Handles a state update, updating the UI and saving the state.
68 void UpdateState();
70 // Configures the UI to reflect |new_captive_portal_status|. Returns true if
71 // and only if a UI change has been made.
72 bool UpdateCaptivePortalStatus(
73 NetworkPortalDetector::CaptivePortalStatus new_captive_portal_status);
75 // Configures the UI to reflect |auto_enrollment_state|. Returns true if and
76 // only if a UI change has been made.
77 bool UpdateAutoEnrollmentState(
78 policy::AutoEnrollmentState auto_enrollment_state);
80 // Configures the error screen.
81 void ShowErrorScreen(NetworkError::ErrorState error_state);
83 // Asynchronously signals completion. The owner might destroy |this| in
84 // response, so no code should be run after the completion of a message loop
85 // task, in which this function was called.
86 void SignalCompletion();
88 // Returns whether enrollment check was completed and decision was made.
89 bool IsCompleted() const;
91 // The user requested a connection attempt to be performed.
92 void OnConnectRequested();
94 AutoEnrollmentCheckScreenActor* actor_;
95 AutoEnrollmentController* auto_enrollment_controller_;
97 scoped_ptr<AutoEnrollmentController::ProgressCallbackList::Subscription>
98 auto_enrollment_progress_subscription_;
100 NetworkPortalDetector::CaptivePortalStatus captive_portal_status_;
101 policy::AutoEnrollmentState auto_enrollment_state_;
103 scoped_ptr<ErrorScreensHistogramHelper> histogram_helper_;
105 ErrorScreen::ConnectRequestCallbackSubscription connect_request_subscription_;
107 base::WeakPtrFactory<AutoEnrollmentCheckScreen> weak_ptr_factory_;
109 DISALLOW_COPY_AND_ASSIGN(AutoEnrollmentCheckScreen);
112 } // namespace chromeos
114 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_AUTO_ENROLLMENT_CHECK_SCREEN_H_