Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / chromeos / login / supervised / supervised_user_creation_screen.h
blobd51a8edb7246685ba84a066d758aad8cf0f72063
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::ImageRequest,
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 void HideFlow() override;
96 bool FindUserByDisplayName(const base::string16& display_name,
97 std::string* out_id) const override;
98 void OnPageSelected(const std::string& page) override;
100 // SupervisedUserController::StatusConsumer overrides.
101 void OnCreationError(
102 SupervisedUserCreationController::ErrorCode code) override;
103 void OnCreationTimeout() override;
104 void OnCreationSuccess() override;
105 void OnLongCreationWarning() override;
107 // NetworkPortalDetector::Observer implementation:
108 void OnPortalDetectionCompleted(
109 const NetworkState* network,
110 const NetworkPortalDetector::CaptivePortalState& state) override;
112 // TODO(antrim) : this is an explicit code duplications with UserImageScreen.
113 // It should be removed by issue 251179.
115 // SupervisedUserCreationScreenHandler::Delegate (image) implementation:
116 void OnPhotoTaken(const std::string& raw_data) override;
117 void OnImageSelected(const std::string& image_url,
118 const std::string& image_type) override;
119 void OnImageAccepted() override;
120 // ImageDecoder::ImageRequest overrides:
121 void OnImageDecoded(const SkBitmap& decoded_image) override;
122 void OnDecodeImageFailed() 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 bool apply_photo_after_decoding_;
141 int selected_image_;
143 scoped_ptr<ErrorScreensHistogramHelper> histogram_helper_;
145 base::WeakPtrFactory<SupervisedUserCreationScreen> weak_factory_;
147 DISALLOW_COPY_AND_ASSIGN(SupervisedUserCreationScreen);
150 } // namespace chromeos
152 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_SUPERVISED_USER_CREATION_SCREEN_H_