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_UI_WEBUI_CHROMEOS_LOGIN_SUPERVISED_USER_CREATION_SCREEN_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SUPERVISED_USER_CREATION_SCREEN_HANDLER_H_
10 #include "base/compiler_specific.h"
11 #include "base/strings/string16.h"
12 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
13 #include "components/user_manager/user_image/default_user_images.h"
14 #include "content/public/browser/web_ui.h"
22 class SupervisedUserCreationScreenHandler
: public BaseScreenHandler
{
26 virtual ~Delegate() {}
28 // This method is called, when actor is being destroyed. Note, if Delegate
29 // is destroyed earlier then it has to call SetDelegate(NULL).
30 virtual void OnActorDestroyed(
31 SupervisedUserCreationScreenHandler
* actor
) = 0;
33 // Starts supervised user creation flow, with manager identified by
34 // |manager_id| and |manager_password|.
35 virtual void AuthenticateManager(const std::string
& manager_id
,
36 const std::string
& manager_password
) = 0;
38 // Starts supervised user creation flow, with supervised user that would
39 // have |display_name| and authenticated by the |supervised_user_password|.
40 virtual void CreateSupervisedUser(
41 const base::string16
& display_name
,
42 const std::string
& supervised_user_password
) = 0;
44 // Look up if user with name |display_name| already exist and can be
45 // imported. Returns user ID in |out_id|. Returns true if user was found,
47 virtual bool FindUserByDisplayName(const base::string16
& display_name
,
48 std::string
*out_id
) const = 0;
50 // Starts supervised user import flow for user identified with |user_id|.
51 virtual void ImportSupervisedUser(const std::string
& user_id
) = 0;
52 // Starts supervised user import flow for user identified with |user_id| and
53 // additional |password|.
54 virtual void ImportSupervisedUserWithPassword(
55 const std::string
& user_id
, const std::string
& password
) = 0;
57 virtual void AbortFlow() = 0;
58 virtual void FinishFlow() = 0;
60 virtual void OnPhotoTaken(const std::string
& raw_data
) = 0;
61 virtual void OnImageSelected(const std::string
& image_url
,
62 const std::string
& image_type
) = 0;
63 virtual void OnImageAccepted() = 0;
64 virtual void OnPageSelected(const std::string
& page
) = 0;
67 SupervisedUserCreationScreenHandler();
68 ~SupervisedUserCreationScreenHandler() override
;
70 virtual void PrepareToShow();
73 virtual void SetDelegate(Delegate
* delegate
);
75 void ShowManagerPasswordError();
78 void ShowUsernamePage();
80 // Shows progress or error message close in the button area. |is_progress| is
81 // true for progress messages and false for error messages.
82 void ShowStatusMessage(bool is_progress
, const base::string16
& message
);
83 void ShowTutorialPage();
85 void ShowErrorPage(const base::string16
& title
,
86 const base::string16
& message
,
87 const base::string16
& button_text
);
89 // Navigates to specified page.
90 void ShowPage(const std::string
& page
);
92 void SetCameraPresent(bool enabled
);
94 void ShowExistingSupervisedUsers(const base::ListValue
* users
);
96 // BaseScreenHandler implementation:
97 void DeclareLocalizedValues(
98 ::login::LocalizedValuesBuilder
* builder
) override
;
99 void Initialize() override
;
101 // WebUIMessageHandler implementation:
102 void RegisterMessages() override
;
105 // WebUI message handlers.
106 void HandleCheckSupervisedUserName(const base::string16
& name
);
108 void HandleManagerSelected(const std::string
& manager_id
);
109 void HandleImportUserSelected(const std::string
& user_id
);
111 void HandleFinishLocalSupervisedUserCreation();
112 void HandleAbortLocalSupervisedUserCreation();
113 void HandleRetryLocalSupervisedUserCreation(const base::ListValue
* args
);
114 void HandleCurrentSupervisedUserPage(const std::string
& current_page
);
116 void HandleAuthenticateManager(const std::string
& raw_manager_username
,
117 const std::string
& manager_password
);
118 void HandleCreateSupervisedUser(const base::string16
& new_raw_user_name
,
119 const std::string
& new_user_password
);
120 void HandleImportSupervisedUser(const std::string
& user_id
);
121 void HandleImportSupervisedUserWithPassword(const std::string
& user_id
,
122 const std::string
& password
);
124 void HandleGetImages();
125 void HandlePhotoTaken(const std::string
& image_url
);
126 void HandleTakePhoto();
127 void HandleDiscardPhoto();
128 void HandleSelectImage(const std::string
& image_url
,
129 const std::string
& image_type
);
131 void UpdateText(const std::string
& element_id
, const base::string16
& text
);
135 DISALLOW_COPY_AND_ASSIGN(SupervisedUserCreationScreenHandler
);
138 } // namespace chromeos
140 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SUPERVISED_USER_CREATION_SCREEN_HANDLER_H_