| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2013 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_MANAGED_LOCALLY_MANAGED_USER_CREATION_SCRE
EN_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MANAGED_LOCALLY_MANAGED_USER_CREATION_SCRE
EN_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 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/managed/managed_user_creation_controller
.h" | |
| 14 #include "chrome/browser/chromeos/login/screens/wizard_screen.h" | |
| 15 #include "chrome/browser/image_decoder.h" | |
| 16 #include "chrome/browser/supervised_user/supervised_user_sync_service.h" | |
| 17 #include "chrome/browser/ui/webui/chromeos/login/locally_managed_user_creation_s
creen_handler.h" | |
| 18 #include "chromeos/network/portal_detector/network_portal_detector.h" | |
| 19 #include "ui/gfx/image/image_skia.h" | |
| 20 | |
| 21 class Profile; | |
| 22 | |
| 23 namespace chromeos { | |
| 24 | |
| 25 class NetworkState; | |
| 26 | |
| 27 // Class that controls screen showing ui for locally managed user creation. | |
| 28 class LocallyManagedUserCreationScreen | |
| 29 : public WizardScreen, | |
| 30 public LocallyManagedUserCreationScreenHandler::Delegate, | |
| 31 public ManagedUserCreationController::StatusConsumer, | |
| 32 public SupervisedUserSyncServiceObserver, | |
| 33 public ImageDecoder::Delegate, | |
| 34 public NetworkPortalDetector::Observer, | |
| 35 public CameraPresenceNotifier::Observer { | |
| 36 public: | |
| 37 LocallyManagedUserCreationScreen( | |
| 38 ScreenObserver* observer, | |
| 39 LocallyManagedUserCreationScreenHandler* actor); | |
| 40 virtual ~LocallyManagedUserCreationScreen(); | |
| 41 | |
| 42 // Makes screen to show message about inconsistency in manager login flow | |
| 43 // (e.g. password change detected, invalid OAuth token, etc). | |
| 44 // Called when manager user is successfully authenticated, so ui elements | |
| 45 // should result in forced logout. | |
| 46 void ShowManagerInconsistentStateErrorScreen(); | |
| 47 | |
| 48 // Called when authentication fails for manager with provided password. | |
| 49 // Displays wrong password message on manager selection screen. | |
| 50 void OnManagerLoginFailure(); | |
| 51 | |
| 52 // Called when manager is successfully authenticated and account is in | |
| 53 // consistent state. | |
| 54 void OnManagerFullyAuthenticated(Profile* manager_profile); | |
| 55 | |
| 56 // Called when manager is successfully authenticated against cryptohome, but | |
| 57 // OAUTH token validation hasn't completed yet. | |
| 58 // Results in spinner indicating that creation is in process. | |
| 59 void OnManagerCryptohomeAuthenticated(); | |
| 60 | |
| 61 // Shows initial screen where managed user name/password are defined and | |
| 62 // manager is selected. | |
| 63 void ShowInitialScreen(); | |
| 64 | |
| 65 // CameraPresenceNotifier::Observer implementation: | |
| 66 virtual void OnCameraPresenceCheckDone(bool is_camera_present) OVERRIDE; | |
| 67 | |
| 68 // SupervisedUserSyncServiceObserver implementation | |
| 69 virtual void OnSupervisedUserAcknowledged( | |
| 70 const std::string& supervised_user_id) OVERRIDE {} | |
| 71 virtual void OnSupervisedUsersSyncingStopped() OVERRIDE {} | |
| 72 virtual void OnSupervisedUsersChanged() OVERRIDE; | |
| 73 | |
| 74 // WizardScreen implementation: | |
| 75 virtual void PrepareToShow() OVERRIDE; | |
| 76 virtual void Show() OVERRIDE; | |
| 77 virtual void Hide() OVERRIDE; | |
| 78 virtual std::string GetName() const OVERRIDE; | |
| 79 | |
| 80 // LocallyManagedUserCreationScreenHandler::Delegate implementation: | |
| 81 virtual void OnActorDestroyed(LocallyManagedUserCreationScreenHandler* actor) | |
| 82 OVERRIDE; | |
| 83 virtual void CreateManagedUser( | |
| 84 const base::string16& display_name, | |
| 85 const std::string& managed_user_password) OVERRIDE; | |
| 86 virtual void ImportManagedUser(const std::string& user_id) OVERRIDE; | |
| 87 virtual void ImportManagedUserWithPassword( | |
| 88 const std::string& user_id, | |
| 89 const std::string& password) OVERRIDE; | |
| 90 virtual void AuthenticateManager( | |
| 91 const std::string& manager_id, | |
| 92 const std::string& manager_password) OVERRIDE; | |
| 93 virtual void AbortFlow() OVERRIDE; | |
| 94 virtual void FinishFlow() OVERRIDE; | |
| 95 virtual bool FindUserByDisplayName(const base::string16& display_name, | |
| 96 std::string *out_id) const OVERRIDE; | |
| 97 virtual void OnPageSelected(const std::string& page) OVERRIDE; | |
| 98 | |
| 99 // LocallyManagedUserController::StatusConsumer overrides. | |
| 100 virtual void OnCreationError(ManagedUserCreationController::ErrorCode code) | |
| 101 OVERRIDE; | |
| 102 virtual void OnCreationTimeout() OVERRIDE; | |
| 103 virtual void OnCreationSuccess() OVERRIDE; | |
| 104 virtual void OnLongCreationWarning() OVERRIDE; | |
| 105 | |
| 106 // NetworkPortalDetector::Observer implementation: | |
| 107 virtual void OnPortalDetectionCompleted( | |
| 108 const NetworkState* network, | |
| 109 const NetworkPortalDetector::CaptivePortalState& state) OVERRIDE; | |
| 110 | |
| 111 // TODO(antrim) : this is an explicit code duplications with UserImageScreen. | |
| 112 // It should be removed by issue 251179. | |
| 113 | |
| 114 // LocallyManagedUserCreationScreenHandler::Delegate (image) implementation: | |
| 115 virtual void OnPhotoTaken(const std::string& raw_data) OVERRIDE; | |
| 116 virtual void OnImageSelected(const std::string& image_url, | |
| 117 const std::string& image_type) OVERRIDE; | |
| 118 virtual void OnImageAccepted() OVERRIDE; | |
| 119 // ImageDecoder::Delegate overrides: | |
| 120 virtual void OnImageDecoded(const ImageDecoder* decoder, | |
| 121 const SkBitmap& decoded_image) OVERRIDE; | |
| 122 virtual void OnDecodeImageFailed(const ImageDecoder* decoder) OVERRIDE; | |
| 123 | |
| 124 private: | |
| 125 void ApplyPicture(); | |
| 126 void OnGetManagedUsers(const base::DictionaryValue* users); | |
| 127 | |
| 128 base::WeakPtrFactory<LocallyManagedUserCreationScreen> weak_factory_; | |
| 129 LocallyManagedUserCreationScreenHandler* actor_; | |
| 130 | |
| 131 scoped_ptr<ManagedUserCreationController> controller_; | |
| 132 scoped_ptr<base::DictionaryValue> existing_users_; | |
| 133 | |
| 134 bool on_error_screen_; | |
| 135 std::string last_page_; | |
| 136 | |
| 137 SupervisedUserSyncService* sync_service_; | |
| 138 | |
| 139 gfx::ImageSkia user_photo_; | |
| 140 scoped_refptr<ImageDecoder> image_decoder_; | |
| 141 bool apply_photo_after_decoding_; | |
| 142 int selected_image_; | |
| 143 | |
| 144 DISALLOW_COPY_AND_ASSIGN(LocallyManagedUserCreationScreen); | |
| 145 }; | |
| 146 | |
| 147 } // namespace chromeos | |
| 148 | |
| 149 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MANAGED_LOCALLY_MANAGED_USER_CREATION_S
CREEN_H_ | |
| 150 | |
| OLD | NEW |