OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/profiles/profile_info_cache.h" | 5 #include "chrome/browser/profiles/profile_info_cache.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
27 #include "chrome/grit/generated_resources.h" | 27 #include "chrome/grit/generated_resources.h" |
28 #include "components/signin/core/common/profile_management_switches.h" | 28 #include "components/signin/core/common/profile_management_switches.h" |
29 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
30 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
31 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
32 #include "ui/base/resource/resource_bundle.h" | 32 #include "ui/base/resource/resource_bundle.h" |
33 #include "ui/gfx/image/image.h" | 33 #include "ui/gfx/image/image.h" |
34 #include "ui/gfx/image/image_util.h" | 34 #include "ui/gfx/image/image_util.h" |
35 | 35 |
| 36 #if defined(ENABLE_SUPERVISED_USERS) |
| 37 #include "chrome/browser/supervised_user/supervised_user_constants.h" |
| 38 #endif |
| 39 |
36 using content::BrowserThread; | 40 using content::BrowserThread; |
37 | 41 |
38 namespace { | 42 namespace { |
39 | 43 |
40 const char kNameKey[] = "name"; | 44 const char kNameKey[] = "name"; |
41 const char kShortcutNameKey[] = "shortcut_name"; | 45 const char kShortcutNameKey[] = "shortcut_name"; |
42 const char kGAIANameKey[] = "gaia_name"; | 46 const char kGAIANameKey[] = "gaia_name"; |
43 const char kGAIAGivenNameKey[] = "gaia_given_name"; | 47 const char kGAIAGivenNameKey[] = "gaia_given_name"; |
44 const char kUserNameKey[] = "user_name"; | 48 const char kUserNameKey[] = "user_name"; |
45 const char kIsUsingDefaultNameKey[] = "is_using_default_name"; | 49 const char kIsUsingDefaultNameKey[] = "is_using_default_name"; |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 value = ProfileIsUsingDefaultAvatarAtIndex(index) && | 396 value = ProfileIsUsingDefaultAvatarAtIndex(index) && |
393 GetGAIAPictureOfProfileAtIndex(index); | 397 GetGAIAPictureOfProfileAtIndex(index); |
394 } | 398 } |
395 return value; | 399 return value; |
396 } | 400 } |
397 | 401 |
398 bool ProfileInfoCache::ProfileIsSupervisedAtIndex(size_t index) const { | 402 bool ProfileInfoCache::ProfileIsSupervisedAtIndex(size_t index) const { |
399 return !GetSupervisedUserIdOfProfileAtIndex(index).empty(); | 403 return !GetSupervisedUserIdOfProfileAtIndex(index).empty(); |
400 } | 404 } |
401 | 405 |
| 406 bool ProfileInfoCache::ProfileIsChildAtIndex(size_t index) const { |
| 407 #if defined(ENABLE_SUPERVISED_USERS) |
| 408 return GetSupervisedUserIdOfProfileAtIndex(index) == |
| 409 supervised_users::kChildAccountSUID; |
| 410 #else |
| 411 return false; |
| 412 #endif |
| 413 } |
| 414 |
| 415 bool ProfileInfoCache::ProfileIsLegacySupervisedAtIndex(size_t index) const { |
| 416 return ProfileIsSupervisedAtIndex(index) && !ProfileIsChildAtIndex(index); |
| 417 } |
| 418 |
402 bool ProfileInfoCache::IsOmittedProfileAtIndex(size_t index) const { | 419 bool ProfileInfoCache::IsOmittedProfileAtIndex(size_t index) const { |
403 bool value = false; | 420 bool value = false; |
404 GetInfoForProfileAtIndex(index)->GetBoolean(kIsOmittedFromProfileListKey, | 421 GetInfoForProfileAtIndex(index)->GetBoolean(kIsOmittedFromProfileListKey, |
405 &value); | 422 &value); |
406 return value; | 423 return value; |
407 } | 424 } |
408 | 425 |
409 bool ProfileInfoCache::ProfileIsSigninRequiredAtIndex(size_t index) const { | 426 bool ProfileInfoCache::ProfileIsSigninRequiredAtIndex(size_t index) const { |
410 bool value = false; | 427 bool value = false; |
411 GetInfoForProfileAtIndex(index)->GetBoolean(kSigninRequiredKey, &value); | 428 GetInfoForProfileAtIndex(index)->GetBoolean(kSigninRequiredKey, &value); |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 std::vector<base::FilePath>::const_iterator it; | 1123 std::vector<base::FilePath>::const_iterator it; |
1107 for (it = profiles_to_rename.begin(); it != profiles_to_rename.end(); ++it) { | 1124 for (it = profiles_to_rename.begin(); it != profiles_to_rename.end(); ++it) { |
1108 size_t profile_index = GetIndexOfProfileWithPath(*it); | 1125 size_t profile_index = GetIndexOfProfileWithPath(*it); |
1109 SetProfileIsUsingDefaultNameAtIndex(profile_index, true); | 1126 SetProfileIsUsingDefaultNameAtIndex(profile_index, true); |
1110 // This will assign a new "Person %d" type name and re-sort the cache. | 1127 // This will assign a new "Person %d" type name and re-sort the cache. |
1111 SetNameOfProfileAtIndex(profile_index, ChooseNameForNewProfile( | 1128 SetNameOfProfileAtIndex(profile_index, ChooseNameForNewProfile( |
1112 GetAvatarIconIndexOfProfileAtIndex(profile_index))); | 1129 GetAvatarIconIndexOfProfileAtIndex(profile_index))); |
1113 } | 1130 } |
1114 #endif | 1131 #endif |
1115 } | 1132 } |
OLD | NEW |