OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen
_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen
_handler.h" |
6 | 6 |
7 #include "ash/audio/sounds.h" | 7 #include "ash/audio/sounds.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/chromeos/login/screens/user_selection_screen.h" | 10 #include "chrome/browser/chromeos/login/screens/user_selection_screen.h" |
11 #include "chrome/browser/chromeos/login/supervised/supervised_user_creation_flow
.h" | 11 #include "chrome/browser/chromeos/login/supervised/supervised_user_creation_flow
.h" |
| 12 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
12 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" | 13 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" |
13 #include "chrome/browser/chromeos/login/users/user_manager.h" | |
14 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 14 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
15 #include "chrome/browser/chromeos/settings/cros_settings.h" | 15 #include "chrome/browser/chromeos/settings/cros_settings.h" |
16 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 16 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
17 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
18 #include "chromeos/audio/chromeos_sounds.h" | 18 #include "chromeos/audio/chromeos_sounds.h" |
| 19 #include "components/user_manager/user_manager.h" |
19 #include "components/user_manager/user_type.h" | 20 #include "components/user_manager/user_type.h" |
20 #include "google_apis/gaia/gaia_auth_util.h" | 21 #include "google_apis/gaia/gaia_auth_util.h" |
21 #include "grit/browser_resources.h" | 22 #include "grit/browser_resources.h" |
22 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
23 #include "net/base/data_url.h" | 24 #include "net/base/data_url.h" |
24 #include "net/base/escape.h" | 25 #include "net/base/escape.h" |
25 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
26 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
27 | 28 |
28 const char kJsScreenPath[] = "login.SupervisedUserCreationScreen"; | 29 const char kJsScreenPath[] = "login.SupervisedUserCreationScreen"; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 AddCallback("currentSupervisedUserPage", | 203 AddCallback("currentSupervisedUserPage", |
203 &SupervisedUserCreationScreenHandler:: | 204 &SupervisedUserCreationScreenHandler:: |
204 HandleCurrentSupervisedUserPage); | 205 HandleCurrentSupervisedUserPage); |
205 } | 206 } |
206 | 207 |
207 void SupervisedUserCreationScreenHandler::PrepareToShow() {} | 208 void SupervisedUserCreationScreenHandler::PrepareToShow() {} |
208 | 209 |
209 void SupervisedUserCreationScreenHandler::Show() { | 210 void SupervisedUserCreationScreenHandler::Show() { |
210 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 211 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
211 scoped_ptr<base::ListValue> users_list(new base::ListValue()); | 212 scoped_ptr<base::ListValue> users_list(new base::ListValue()); |
212 const user_manager::UserList& users = UserManager::Get()->GetUsers(); | 213 const user_manager::UserList& users = |
| 214 user_manager::UserManager::Get()->GetUsers(); |
213 std::string owner; | 215 std::string owner; |
214 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); | 216 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); |
215 | 217 |
216 for (user_manager::UserList::const_iterator it = users.begin(); | 218 for (user_manager::UserList::const_iterator it = users.begin(); |
217 it != users.end(); | 219 it != users.end(); |
218 ++it) { | 220 ++it) { |
219 if ((*it)->GetType() != user_manager::USER_TYPE_REGULAR) | 221 if ((*it)->GetType() != user_manager::USER_TYPE_REGULAR) |
220 continue; | 222 continue; |
221 bool is_owner = ((*it)->email() == owner); | 223 bool is_owner = ((*it)->email() == owner); |
222 base::DictionaryValue* user_dict = new base::DictionaryValue(); | 224 base::DictionaryValue* user_dict = new base::DictionaryValue(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 | 296 |
295 void SupervisedUserCreationScreenHandler::HandleImportUserSelected( | 297 void SupervisedUserCreationScreenHandler::HandleImportUserSelected( |
296 const std::string& user_id) { | 298 const std::string& user_id) { |
297 if (!delegate_) | 299 if (!delegate_) |
298 return; | 300 return; |
299 } | 301 } |
300 | 302 |
301 void SupervisedUserCreationScreenHandler::HandleCheckSupervisedUserName( | 303 void SupervisedUserCreationScreenHandler::HandleCheckSupervisedUserName( |
302 const base::string16& name) { | 304 const base::string16& name) { |
303 std::string user_id; | 305 std::string user_id; |
304 if (NULL != UserManager::Get()->GetSupervisedUserManager()-> | 306 if (NULL != |
305 FindByDisplayName(base::CollapseWhitespace(name, true))) { | 307 ChromeUserManager::Get()->GetSupervisedUserManager()->FindByDisplayName( |
| 308 base::CollapseWhitespace(name, true))) { |
306 CallJS("supervisedUserNameError", name, | 309 CallJS("supervisedUserNameError", name, |
307 l10n_util::GetStringUTF16( | 310 l10n_util::GetStringUTF16( |
308 IDS_CREATE_SUPERVISED_USER_CREATE_USERNAME_ALREADY_EXISTS)); | 311 IDS_CREATE_SUPERVISED_USER_CREATE_USERNAME_ALREADY_EXISTS)); |
309 } else if (net::EscapeForHTML(name) != name) { | 312 } else if (net::EscapeForHTML(name) != name) { |
310 CallJS("supervisedUserNameError", name, | 313 CallJS("supervisedUserNameError", name, |
311 l10n_util::GetStringUTF16( | 314 l10n_util::GetStringUTF16( |
312 IDS_CREATE_SUPERVISED_USER_CREATE_ILLEGAL_USERNAME)); | 315 IDS_CREATE_SUPERVISED_USER_CREATE_ILLEGAL_USERNAME)); |
313 } else if (delegate_ && delegate_->FindUserByDisplayName( | 316 } else if (delegate_ && delegate_->FindUserByDisplayName( |
314 base::CollapseWhitespace(name, true), &user_id)) { | 317 base::CollapseWhitespace(name, true), &user_id)) { |
315 CallJS("supervisedUserSuggestImport", name, user_id); | 318 CallJS("supervisedUserSuggestImport", name, user_id); |
316 } else { | 319 } else { |
317 CallJS("supervisedUserNameOk", name); | 320 CallJS("supervisedUserNameOk", name); |
318 } | 321 } |
319 } | 322 } |
320 | 323 |
321 void SupervisedUserCreationScreenHandler::HandleCreateSupervisedUser( | 324 void SupervisedUserCreationScreenHandler::HandleCreateSupervisedUser( |
322 const base::string16& new_raw_user_name, | 325 const base::string16& new_raw_user_name, |
323 const std::string& new_user_password) { | 326 const std::string& new_user_password) { |
324 if (!delegate_) | 327 if (!delegate_) |
325 return; | 328 return; |
326 const base::string16 new_user_name = | 329 const base::string16 new_user_name = |
327 base::CollapseWhitespace(new_raw_user_name, true); | 330 base::CollapseWhitespace(new_raw_user_name, true); |
328 if (NULL != UserManager::Get()->GetSupervisedUserManager()-> | 331 if (NULL != |
329 FindByDisplayName(new_user_name)) { | 332 ChromeUserManager::Get()->GetSupervisedUserManager()->FindByDisplayName( |
| 333 new_user_name)) { |
330 CallJS("supervisedUserNameError", new_user_name, | 334 CallJS("supervisedUserNameError", new_user_name, |
331 l10n_util::GetStringFUTF16( | 335 l10n_util::GetStringFUTF16( |
332 IDS_CREATE_SUPERVISED_USER_CREATE_USERNAME_ALREADY_EXISTS, | 336 IDS_CREATE_SUPERVISED_USER_CREATE_USERNAME_ALREADY_EXISTS, |
333 new_user_name)); | 337 new_user_name)); |
334 return; | 338 return; |
335 } | 339 } |
336 if (net::EscapeForHTML(new_user_name) != new_user_name) { | 340 if (net::EscapeForHTML(new_user_name) != new_user_name) { |
337 CallJS("supervisedUserNameError", new_user_name, | 341 CallJS("supervisedUserNameError", new_user_name, |
338 l10n_util::GetStringUTF16( | 342 l10n_util::GetStringUTF16( |
339 IDS_CREATE_SUPERVISED_USER_CREATE_ILLEGAL_USERNAME)); | 343 IDS_CREATE_SUPERVISED_USER_CREATE_ILLEGAL_USERNAME)); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 delegate_->ImportSupervisedUserWithPassword(user_id, password); | 381 delegate_->ImportSupervisedUserWithPassword(user_id, password); |
378 } | 382 } |
379 | 383 |
380 void SupervisedUserCreationScreenHandler::HandleAuthenticateManager( | 384 void SupervisedUserCreationScreenHandler::HandleAuthenticateManager( |
381 const std::string& raw_manager_username, | 385 const std::string& raw_manager_username, |
382 const std::string& manager_password) { | 386 const std::string& manager_password) { |
383 const std::string manager_username = | 387 const std::string manager_username = |
384 gaia::SanitizeEmail(raw_manager_username); | 388 gaia::SanitizeEmail(raw_manager_username); |
385 | 389 |
386 UserFlow* flow = new SupervisedUserCreationFlow(manager_username); | 390 UserFlow* flow = new SupervisedUserCreationFlow(manager_username); |
387 UserManager::Get()->SetUserFlow(manager_username, flow); | 391 ChromeUserManager::Get()->SetUserFlow(manager_username, flow); |
388 | 392 |
389 delegate_->AuthenticateManager(manager_username, manager_password); | 393 delegate_->AuthenticateManager(manager_username, manager_password); |
390 } | 394 } |
391 | 395 |
392 // TODO(antrim) : this is an explicit code duplications with UserImageScreen. | 396 // TODO(antrim) : this is an explicit code duplications with UserImageScreen. |
393 // It should be removed by issue 251179. | 397 // It should be removed by issue 251179. |
394 void SupervisedUserCreationScreenHandler::HandleGetImages() { | 398 void SupervisedUserCreationScreenHandler::HandleGetImages() { |
395 base::ListValue image_urls; | 399 base::ListValue image_urls; |
396 for (int i = user_manager::kFirstDefaultImageIndex; | 400 for (int i = user_manager::kFirstDefaultImageIndex; |
397 i < user_manager::kDefaultImagesCount; | 401 i < user_manager::kDefaultImagesCount; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 void SupervisedUserCreationScreenHandler::SetCameraPresent(bool present) { | 454 void SupervisedUserCreationScreenHandler::SetCameraPresent(bool present) { |
451 CallJS("setCameraPresent", present); | 455 CallJS("setCameraPresent", present); |
452 } | 456 } |
453 | 457 |
454 void SupervisedUserCreationScreenHandler::ShowExistingSupervisedUsers( | 458 void SupervisedUserCreationScreenHandler::ShowExistingSupervisedUsers( |
455 const base::ListValue* users) { | 459 const base::ListValue* users) { |
456 CallJS("setExistingSupervisedUsers", *users); | 460 CallJS("setExistingSupervisedUsers", *users); |
457 } | 461 } |
458 | 462 |
459 } // namespace chromeos | 463 } // namespace chromeos |
OLD | NEW |