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.
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_
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"
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 {
33 LocallyManagedUserCreationScreen(
34 ScreenObserver* observer,
35 LocallyManagedUserCreationScreenHandler* actor);
36 virtual ~LocallyManagedUserCreationScreen();
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();
44 // Called when authentication fails for manager with provided password.
45 // Displays wrong password message on manager selection screen.
46 void OnManagerLoginFailure();
48 // Called when manager is successfully authenticated and account is in
50 void OnManagerFullyAuthenticated(Profile* manager_profile);
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();
57 // Shows initial screen where managed user name/password are defined and
58 // manager is selected.
59 void ShowInitialScreen();
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;
67 // LocallyManagedUserCreationScreenHandler::Delegate implementation:
68 virtual void OnActorDestroyed(LocallyManagedUserCreationScreenHandler* actor)
70 virtual void CreateManagedUser(
71 const string16& display_name,
72 const std::string& managed_user_password) OVERRIDE;
73 virtual void ImportManagedUser(const std::string& user_id) OVERRIDE;
74 virtual void ImportManagedUserWithPassword(
75 const std::string& user_id,
76 const std::string& password) OVERRIDE;
77 virtual void AuthenticateManager(
78 const std::string& manager_id,
79 const std::string& manager_password) OVERRIDE;
80 virtual void AbortFlow() OVERRIDE;
81 virtual void FinishFlow() OVERRIDE;
82 virtual bool FindUserByDisplayName(const string16& display_name,
83 std::string *out_id) const OVERRIDE;
84 virtual void OnPageSelected(const std::string& page) OVERRIDE;
86 // LocallyManagedUserController::StatusConsumer overrides.
87 virtual void OnCreationError(
88 LocallyManagedUserCreationController::ErrorCode code) OVERRIDE;
89 virtual void OnCreationTimeout() OVERRIDE;
90 virtual void OnCreationSuccess() OVERRIDE;
91 virtual void OnLongCreationWarning() OVERRIDE;
93 // NetworkPortalDetector::Observer implementation:
94 virtual void OnPortalDetectionCompleted(
95 const NetworkState* network,
96 const NetworkPortalDetector::CaptivePortalState& state) OVERRIDE;
98 // TODO(antrim) : this is an explicit code duplications with UserImageScreen.
99 // It should be removed by issue 251179.
101 // LocallyManagedUserCreationScreenHandler::Delegate (image) implementation:
102 virtual void CheckCameraPresence() OVERRIDE;
103 virtual void OnPhotoTaken(const std::string& raw_data) OVERRIDE;
104 virtual void OnImageSelected(const std::string& image_url,
105 const std::string& image_type) OVERRIDE;
106 virtual void OnImageAccepted() OVERRIDE;
107 // ImageDecoder::Delegate overrides:
108 virtual void OnImageDecoded(const ImageDecoder* decoder,
109 const SkBitmap& decoded_image) OVERRIDE;
110 virtual void OnDecodeImageFailed(const ImageDecoder* decoder) OVERRIDE;
114 void OnCameraPresenceCheckDone();
115 void OnGetManagedUsers(const base::DictionaryValue* users);
117 base::WeakPtrFactory<LocallyManagedUserCreationScreen> weak_factory_;
118 LocallyManagedUserCreationScreenHandler* actor_;
120 scoped_ptr<LocallyManagedUserCreationController> controller_;
121 scoped_ptr<base::DictionaryValue> existing_users_;
123 bool on_error_screen_;
124 std::string last_page_;
126 gfx::ImageSkia user_photo_;
127 scoped_refptr<ImageDecoder> image_decoder_;
128 bool apply_photo_after_decoding_;
131 DISALLOW_COPY_AND_ASSIGN(LocallyManagedUserCreationScreen);
134 } // namespace chromeos
136 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MANAGED_LOCALLY_MANAGED_USER_CREATION_SCREEN_H_