OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/chromeos/login/users/fake_chrome_user_manager.h" | 5 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/sys_info.h" | 8 #include "base/sys_info.h" |
9 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 9 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
10 #include "chrome/browser/chromeos/login/users/chrome_user_manager_util.h" | 10 #include "chrome/browser/chromeos/login/users/chrome_user_manager_util.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
22 #include "ui/gfx/image/image_skia.h" | 22 #include "ui/gfx/image/image_skia.h" |
23 | 23 |
24 namespace chromeos { | 24 namespace chromeos { |
25 | 25 |
26 class FakeSupervisedUserManager; | 26 class FakeSupervisedUserManager; |
27 | 27 |
28 FakeChromeUserManager::FakeChromeUserManager() | 28 FakeChromeUserManager::FakeChromeUserManager() |
29 : supervised_user_manager_(new FakeSupervisedUserManager), | 29 : supervised_user_manager_(new FakeSupervisedUserManager), |
30 bootstrap_manager_(NULL), | 30 bootstrap_manager_(NULL), |
31 multi_profile_user_controller_(NULL) {} | 31 multi_profile_user_controller_(NULL) { |
| 32 ProfileHelper::SetProfileToUserForTestingEnabled(true); |
| 33 } |
32 | 34 |
33 FakeChromeUserManager::~FakeChromeUserManager() { | 35 FakeChromeUserManager::~FakeChromeUserManager() { |
| 36 ProfileHelper::SetProfileToUserForTestingEnabled(false); |
34 } | 37 } |
35 | 38 |
36 const user_manager::User* FakeChromeUserManager::AddUser( | 39 const user_manager::User* FakeChromeUserManager::AddUser( |
37 const AccountId& account_id) { | 40 const AccountId& account_id) { |
38 return AddUserWithAffiliation(account_id, false); | 41 return AddUserWithAffiliation(account_id, false); |
39 } | 42 } |
40 | 43 |
41 const user_manager::User* FakeChromeUserManager::AddUserWithAffiliation( | 44 const user_manager::User* FakeChromeUserManager::AddUserWithAffiliation( |
42 const AccountId& account_id, | 45 const AccountId& account_id, |
43 bool is_affiliated) { | 46 bool is_affiliated) { |
44 user_manager::User* user = user_manager::User::CreateRegularUser(account_id); | 47 user_manager::User* user = user_manager::User::CreateRegularUser(account_id); |
45 user->SetAffiliation(is_affiliated); | 48 user->SetAffiliation(is_affiliated); |
46 user->set_username_hash(ProfileHelper::GetUserIdHashByUserIdForTesting( | 49 user->set_username_hash(ProfileHelper::GetUserIdHashByUserIdForTesting( |
47 account_id.GetUserEmail())); | 50 account_id.GetUserEmail())); |
48 user->SetStubImage(user_manager::UserImage( | 51 user->SetStubImage(user_manager::UserImage( |
49 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 52 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
50 IDR_PROFILE_PICTURE_LOADING)), | 53 IDR_PROFILE_PICTURE_LOADING)), |
51 user_manager::User::USER_IMAGE_PROFILE, false); | 54 user_manager::User::USER_IMAGE_PROFILE, false); |
52 users_.push_back(user); | 55 users_.push_back(user); |
| 56 chromeos::ProfileHelper::Get()->SetProfileToUserMappingForTesting(user); |
53 return user; | 57 return user; |
54 } | 58 } |
55 | 59 |
56 const user_manager::User* FakeChromeUserManager::AddPublicAccountUser( | 60 const user_manager::User* FakeChromeUserManager::AddPublicAccountUser( |
57 const AccountId& account_id) { | 61 const AccountId& account_id) { |
58 user_manager::User* user = | 62 user_manager::User* user = |
59 user_manager::User::CreatePublicAccountUser(account_id); | 63 user_manager::User::CreatePublicAccountUser(account_id); |
60 user->set_username_hash(ProfileHelper::GetUserIdHashByUserIdForTesting( | 64 user->set_username_hash(ProfileHelper::GetUserIdHashByUserIdForTesting( |
61 account_id.GetUserEmail())); | 65 account_id.GetUserEmail())); |
62 user->SetStubImage(user_manager::UserImage( | 66 user->SetStubImage(user_manager::UserImage( |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 NOTIMPLEMENTED(); | 267 NOTIMPLEMENTED(); |
264 return; | 268 return; |
265 } | 269 } |
266 | 270 |
267 bool FakeChromeUserManager::IsValidDefaultUserImageId(int image_index) const { | 271 bool FakeChromeUserManager::IsValidDefaultUserImageId(int image_index) const { |
268 NOTIMPLEMENTED(); | 272 NOTIMPLEMENTED(); |
269 return false; | 273 return false; |
270 } | 274 } |
271 | 275 |
272 } // namespace chromeos | 276 } // namespace chromeos |
OLD | NEW |