ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / chrome / browser / chromeos / login / supervised / supervised_user_creation_screen.h
bloba41cd6dff3c693f5630f764abcb4f94294dea71e
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_SUPERVISED_SUPERVISED_USER_CREATION_SCREEN_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_SUPERVISED_USER_CREATION_SCREEN_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "chrome/browser/chromeos/camera_presence_notifier.h"
13 #include "chrome/browser/chromeos/login/screens/base_screen.h"
14 #include "chrome/browser/chromeos/login/supervised/supervised_user_creation_controller.h"
15 #include "chrome/browser/image_decoder.h"
16 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service.h"
17 #include "chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen_handler.h"
18 #include "chromeos/network/portal_detector/network_portal_detector.h"
19 #include "ui/gfx/image/image_skia.h"
21 class Profile;
23 namespace chromeos {
25 class ErrorScreensHistogramHelper;
26 class NetworkState;
27 class ScreenManager;
29 // Class that controls screen showing ui for supervised user creation.
30 class SupervisedUserCreationScreen
31 : public BaseScreen,
32 public SupervisedUserCreationScreenHandler::Delegate,
33 public SupervisedUserCreationController::StatusConsumer,
34 public SupervisedUserSyncServiceObserver,
35 public ImageDecoder::Delegate,
36 public NetworkPortalDetector::Observer,
37 public CameraPresenceNotifier::Observer {
38 public:
39 SupervisedUserCreationScreen(BaseScreenDelegate* base_screen_delegate,
40 SupervisedUserCreationScreenHandler* actor);
41 ~SupervisedUserCreationScreen() override;
43 static SupervisedUserCreationScreen* Get(ScreenManager* manager);
45 // Makes screen to show message about inconsistency in manager login flow
46 // (e.g. password change detected, invalid OAuth token, etc).
47 // Called when manager user is successfully authenticated, so ui elements
48 // should result in forced logout.
49 void ShowManagerInconsistentStateErrorScreen();
51 // Called when authentication fails for manager with provided password.
52 // Displays wrong password message on manager selection screen.
53 void OnManagerLoginFailure();
55 // Called when manager is successfully authenticated and account is in
56 // consistent state.
57 void OnManagerFullyAuthenticated(Profile* manager_profile);
59 // Called when manager is successfully authenticated against cryptohome, but
60 // OAUTH token validation hasn't completed yet.
61 // Results in spinner indicating that creation is in process.
62 void OnManagerCryptohomeAuthenticated();
64 // Shows initial screen where managed user name/password are defined and
65 // manager is selected.
66 void ShowInitialScreen();
68 // CameraPresenceNotifier::Observer implementation:
69 void OnCameraPresenceCheckDone(bool is_camera_present) override;
71 // SupervisedUserSyncServiceObserver implementation
72 void OnSupervisedUserAcknowledged(
73 const std::string& supervised_user_id) override {}
74 void OnSupervisedUsersSyncingStopped() override {}
75 void OnSupervisedUsersChanged() override;
77 // BaseScreen implementation:
78 void PrepareToShow() override;
79 void Show() override;
80 void Hide() override;
81 std::string GetName() const override;
83 // SupervisedUserCreationScreenHandler::Delegate implementation:
84 void OnActorDestroyed(SupervisedUserCreationScreenHandler* actor) override;
85 void CreateSupervisedUser(
86 const base::string16& display_name,
87 const std::string& supervised_user_password) override;
88 void ImportSupervisedUser(const std::string& user_id) override;
89 void ImportSupervisedUserWithPassword(const std::string& user_id,
90 const std::string& password) override;
91 void AuthenticateManager(const std::string& manager_id,
92 const std::string& manager_password) override;
93 void AbortFlow() override;
94 void FinishFlow() override;
95 bool FindUserByDisplayName(const base::string16& display_name,
96 std::string* out_id) const override;
97 void OnPageSelected(const std::string& page) override;
99 // SupervisedUserController::StatusConsumer overrides.
100 void OnCreationError(
101 SupervisedUserCreationController::ErrorCode code) override;
102 void OnCreationTimeout() override;
103 void OnCreationSuccess() override;
104 void OnLongCreationWarning() override;
106 // NetworkPortalDetector::Observer implementation:
107 void OnPortalDetectionCompleted(
108 const NetworkState* network,
109 const NetworkPortalDetector::CaptivePortalState& state) override;
111 // TODO(antrim) : this is an explicit code duplications with UserImageScreen.
112 // It should be removed by issue 251179.
114 // SupervisedUserCreationScreenHandler::Delegate (image) implementation:
115 void OnPhotoTaken(const std::string& raw_data) override;
116 void OnImageSelected(const std::string& image_url,
117 const std::string& image_type) override;
118 void OnImageAccepted() override;
119 // ImageDecoder::Delegate overrides:
120 void OnImageDecoded(const ImageDecoder* decoder,
121 const SkBitmap& decoded_image) override;
122 void OnDecodeImageFailed(const ImageDecoder* decoder) override;
124 private:
125 void ApplyPicture();
126 void OnGetSupervisedUsers(const base::DictionaryValue* users);
128 SupervisedUserCreationScreenHandler* actor_;
130 scoped_ptr<SupervisedUserCreationController> controller_;
131 scoped_ptr<base::DictionaryValue> existing_users_;
133 bool on_error_screen_;
134 bool manager_signin_in_progress_;
135 std::string last_page_;
137 SupervisedUserSyncService* sync_service_;
139 gfx::ImageSkia user_photo_;
140 scoped_refptr<ImageDecoder> image_decoder_;
141 bool apply_photo_after_decoding_;
142 int selected_image_;
144 scoped_ptr<ErrorScreensHistogramHelper> histogram_helper_;
146 base::WeakPtrFactory<SupervisedUserCreationScreen> weak_factory_;
148 DISALLOW_COPY_AND_ASSIGN(SupervisedUserCreationScreen);
151 } // namespace chromeos
153 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_SUPERVISED_USER_CREATION_SCREEN_H_