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