Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / webui / chromeos / login / enrollment_screen_handler.h
blobf72b331c5bd07960466fde4a96e24cc4bb10f821
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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENROLLMENT_SCREEN_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENROLLMENT_SCREEN_HANDLER_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen_actor.h"
13 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_helper.h"
14 #include "chrome/browser/chromeos/login/screens/network_error_model.h"
15 #include "chrome/browser/chromeos/login/ui/webui_login_view.h"
16 #include "chrome/browser/chromeos/policy/enrollment_config.h"
17 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
18 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
19 #include "net/base/net_errors.h"
21 namespace chromeos {
23 class ErrorScreensHistogramHelper;
25 // WebUIMessageHandler implementation which handles events occurring on the
26 // page, such as the user pressing the signin button.
27 class EnrollmentScreenHandler
28 : public BaseScreenHandler,
29 public EnrollmentScreenActor,
30 public NetworkStateInformer::NetworkStateInformerObserver,
31 public WebUILoginView::FrameObserver {
32 public:
33 EnrollmentScreenHandler(
34 const scoped_refptr<NetworkStateInformer>& network_state_informer,
35 NetworkErrorModel* network_error_model);
36 ~EnrollmentScreenHandler() override;
38 // Implements WebUIMessageHandler:
39 void RegisterMessages() override;
41 // Implements EnrollmentScreenActor:
42 void SetParameters(Controller* controller,
43 const policy::EnrollmentConfig& config) override;
44 void PrepareToShow() override;
45 void Show() override;
46 void Hide() override;
47 void ShowSigninScreen() override;
48 void ShowAttributePromptScreen(const std::string& asset_id,
49 const std::string& location) override;
50 void ShowEnrollmentSpinnerScreen() override;
51 void ShowAuthError(const GoogleServiceAuthError& error) override;
52 void ShowEnrollmentStatus(policy::EnrollmentStatus status) override;
53 void ShowOtherError(
54 EnterpriseEnrollmentHelper::OtherError error_code) override;
56 // Implements BaseScreenHandler:
57 void Initialize() override;
58 void DeclareLocalizedValues(
59 ::login::LocalizedValuesBuilder* builder) override;
61 // Implements NetworkStateInformer::NetworkStateInformerObserver
62 void UpdateState(NetworkError::ErrorReason reason) override;
64 // Implements WebUILoginView::FrameObserver
65 void OnFrameError(const std::string& frame_unique_name) override;
67 private:
68 // Handlers for WebUI messages.
69 void HandleClose(const std::string& reason);
70 void HandleCompleteLogin(const std::string& user,
71 const std::string& auth_code);
72 void HandleRetry();
73 void HandleFrameLoadingCompleted(int status);
74 void HandleDeviceAttributesProvided(const std::string& asset_id,
75 const std::string& location);
76 void HandleOnLearnMore();
78 void UpdateStateInternal(NetworkError::ErrorReason reason, bool force_update);
79 void SetupAndShowOfflineMessage(NetworkStateInformer::State state,
80 NetworkError::ErrorReason reason);
81 void HideOfflineMessage(NetworkStateInformer::State state,
82 NetworkError::ErrorReason reason);
84 net::Error frame_error() const { return frame_error_; }
85 // Shows a given enrollment step.
86 void ShowStep(const char* step);
88 // Display the given i18n resource as error message.
89 void ShowError(int message_id, bool retry);
91 // Display the given string as error message.
92 void ShowErrorMessage(const std::string& message, bool retry);
94 // Display the given i18n string as a progress message.
95 void ShowWorking(int message_id);
97 // Shows the screen.
98 void DoShow();
100 // Returns current visible screen.
101 OobeUI::Screen GetCurrentScreen() const;
103 // Returns true if current visible screen is the enrollment sign-in page.
104 bool IsOnEnrollmentScreen() const;
106 // Returns true if current visible screen is the error screen over
107 // enrollment sign-in page.
108 bool IsEnrollmentScreenHiddenByError() const;
110 // Keeps the controller for this actor.
111 Controller* controller_;
113 bool show_on_init_;
115 // The enrollment configuration.
116 policy::EnrollmentConfig config_;
118 // Latest enrollment frame error.
119 net::Error frame_error_;
121 // True if screen was not shown yet.
122 bool first_show_;
124 // Whether we should handle network errors on enrollment screen.
125 // True when signin screen step is shown.
126 bool observe_network_failure_;
128 // Network state informer used to keep signin screen up.
129 scoped_refptr<NetworkStateInformer> network_state_informer_;
131 NetworkErrorModel* network_error_model_;
133 scoped_ptr<ErrorScreensHistogramHelper> histogram_helper_;
135 // Help application used for help dialogs.
136 scoped_refptr<HelpAppLauncher> help_app_;
138 base::WeakPtrFactory<EnrollmentScreenHandler> weak_ptr_factory_;
140 DISALLOW_COPY_AND_ASSIGN(EnrollmentScreenHandler);
143 } // namespace chromeos
145 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENROLLMENT_SCREEN_HANDLER_H_