| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/i18n/case_conversion.h" | 13 #include "base/i18n/case_conversion.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/profiler/scoped_tracker.h" | 16 #include "base/profiler/scoped_tracker.h" |
| 17 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
| 18 #include "base/strings/string_piece.h" | 18 #include "base/strings/string_piece.h" |
| 19 #include "base/values.h" | 19 #include "base/values.h" |
| 20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
| 21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 22 #include "chrome/browser/profiles/profile_avatar_downloader.h" | 22 #include "chrome/browser/profiles/profile_avatar_downloader.h" |
| 23 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 23 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 24 #include "chrome/browser/profiles/profiles_state.h" | 24 #include "chrome/browser/profiles/profiles_state.h" |
| 25 #include "chrome/common/features.h" |
| 25 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
| 26 #include "chrome/grit/generated_resources.h" | 27 #include "chrome/grit/generated_resources.h" |
| 27 #include "components/prefs/pref_registry_simple.h" | 28 #include "components/prefs/pref_registry_simple.h" |
| 28 #include "components/prefs/pref_service.h" | 29 #include "components/prefs/pref_service.h" |
| 29 #include "components/prefs/scoped_user_pref_update.h" | 30 #include "components/prefs/scoped_user_pref_update.h" |
| 30 #include "components/signin/core/common/profile_management_switches.h" | 31 #include "components/signin/core/common/profile_management_switches.h" |
| 31 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
| 33 #include "ui/base/resource/resource_bundle.h" | 34 #include "ui/base/resource/resource_bundle.h" |
| 34 #include "ui/gfx/image/image.h" | 35 #include "ui/gfx/image/image.h" |
| 35 #include "ui/gfx/image/image_util.h" | 36 #include "ui/gfx/image/image_util.h" |
| 36 | 37 |
| 37 #if defined(ENABLE_SUPERVISED_USERS) | 38 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
| 38 #include "chrome/browser/supervised_user/supervised_user_constants.h" | 39 #include "chrome/browser/supervised_user/supervised_user_constants.h" |
| 39 #endif | 40 #endif |
| 40 | 41 |
| 41 using content::BrowserThread; | 42 using content::BrowserThread; |
| 42 | 43 |
| 43 namespace { | 44 namespace { |
| 44 | 45 |
| 45 const char kNameKey[] = "name"; | 46 const char kNameKey[] = "name"; |
| 46 const char kShortcutNameKey[] = "shortcut_name"; | 47 const char kShortcutNameKey[] = "shortcut_name"; |
| 47 const char kGAIANameKey[] = "gaia_name"; | 48 const char kGAIANameKey[] = "gaia_name"; |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 GetGAIAPictureOfProfileAtIndex(index); | 394 GetGAIAPictureOfProfileAtIndex(index); |
| 394 } | 395 } |
| 395 return value; | 396 return value; |
| 396 } | 397 } |
| 397 | 398 |
| 398 bool ProfileInfoCache::ProfileIsSupervisedAtIndex(size_t index) const { | 399 bool ProfileInfoCache::ProfileIsSupervisedAtIndex(size_t index) const { |
| 399 return !GetSupervisedUserIdOfProfileAtIndex(index).empty(); | 400 return !GetSupervisedUserIdOfProfileAtIndex(index).empty(); |
| 400 } | 401 } |
| 401 | 402 |
| 402 bool ProfileInfoCache::ProfileIsChildAtIndex(size_t index) const { | 403 bool ProfileInfoCache::ProfileIsChildAtIndex(size_t index) const { |
| 403 #if defined(ENABLE_SUPERVISED_USERS) | 404 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
| 404 return GetSupervisedUserIdOfProfileAtIndex(index) == | 405 return GetSupervisedUserIdOfProfileAtIndex(index) == |
| 405 supervised_users::kChildAccountSUID; | 406 supervised_users::kChildAccountSUID; |
| 406 #else | 407 #else |
| 407 return false; | 408 return false; |
| 408 #endif | 409 #endif |
| 409 } | 410 } |
| 410 | 411 |
| 411 bool ProfileInfoCache::ProfileIsLegacySupervisedAtIndex(size_t index) const { | 412 bool ProfileInfoCache::ProfileIsLegacySupervisedAtIndex(size_t index) const { |
| 412 return ProfileIsSupervisedAtIndex(index) && !ProfileIsChildAtIndex(index); | 413 return ProfileIsSupervisedAtIndex(index) && !ProfileIsChildAtIndex(index); |
| 413 } | 414 } |
| (...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1221 if (!current_entry) { | 1222 if (!current_entry) { |
| 1222 // The profile info is in the cache but its entry isn't created yet, insert | 1223 // The profile info is in the cache but its entry isn't created yet, insert |
| 1223 // it in the map. | 1224 // it in the map. |
| 1224 current_entry.reset(new ProfileAttributesEntry()); | 1225 current_entry.reset(new ProfileAttributesEntry()); |
| 1225 current_entry->Initialize(this, path); | 1226 current_entry->Initialize(this, path); |
| 1226 } | 1227 } |
| 1227 | 1228 |
| 1228 *entry = current_entry.get(); | 1229 *entry = current_entry.get(); |
| 1229 return true; | 1230 return true; |
| 1230 } | 1231 } |
| OLD | NEW |