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 #ifndef CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ | 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ |
6 #define CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ | 6 #define CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
17 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
18 #include "chrome/browser/profiles/profile_info_cache_observer.h" | 18 #include "chrome/browser/profiles/profile_info_cache_observer.h" |
19 #include "chrome/browser/profiles/profile_info_interface.h" | 19 #include "chrome/browser/profiles/profile_info_interface.h" |
20 | 20 |
21 namespace gfx { | 21 namespace gfx { |
22 class Image; | 22 class Image; |
23 } | 23 } |
24 | 24 |
25 namespace base { | 25 namespace base { |
26 class DictionaryValue; | 26 class DictionaryValue; |
27 } | 27 } |
28 | 28 |
| 29 namespace user_manager { |
| 30 class UserID; |
| 31 } |
| 32 |
29 class PrefService; | 33 class PrefService; |
30 class PrefRegistrySimple; | 34 class PrefRegistrySimple; |
31 class ProfileAvatarDownloader; | 35 class ProfileAvatarDownloader; |
32 | 36 |
33 // This class saves various information about profiles to local preferences. | 37 // This class saves various information about profiles to local preferences. |
34 // This cache can be used to display a list of profiles without having to | 38 // This cache can be used to display a list of profiles without having to |
35 // actually load the profiles from disk. | 39 // actually load the profiles from disk. |
36 class ProfileInfoCache : public ProfileInfoInterface, | 40 class ProfileInfoCache : public ProfileInfoInterface, |
37 public base::SupportsWeakPtr<ProfileInfoCache> { | 41 public base::SupportsWeakPtr<ProfileInfoCache> { |
38 public: | 42 public: |
39 ProfileInfoCache(PrefService* prefs, const base::FilePath& user_data_dir); | 43 ProfileInfoCache(PrefService* prefs, const base::FilePath& user_data_dir); |
40 ~ProfileInfoCache() override; | 44 ~ProfileInfoCache() override; |
41 | 45 |
42 // If the |supervised_user_id| is non-empty, the profile will be marked to be | 46 // If the |supervised_user_id| is non-empty, the profile will be marked to be |
43 // omitted from the avatar-menu list on desktop versions. This is used while a | 47 // omitted from the avatar-menu list on desktop versions. This is used while a |
44 // supervised user is in the process of being registered with the server. Use | 48 // supervised user is in the process of being registered with the server. Use |
45 // SetIsOmittedProfileAtIndex() to clear the flag when the profile is ready to | 49 // SetIsOmittedProfileAtIndex() to clear the flag when the profile is ready to |
46 // be shown in the menu. | 50 // be shown in the menu. |
47 void AddProfileToCache(const base::FilePath& profile_path, | 51 void AddProfileToCache(const base::FilePath& profile_path, |
48 const base::string16& name, | 52 const base::string16& name, |
49 const std::string& gaia_id, | 53 const std::string& gaia_id, |
50 const base::string16& user_name, | 54 const base::string16& user_name, |
51 size_t icon_index, | 55 size_t icon_index, |
52 const std::string& supervised_user_id); | 56 const user_manager::UserID& supervised_user_id); |
53 void DeleteProfileFromCache(const base::FilePath& profile_path); | 57 void DeleteProfileFromCache(const base::FilePath& profile_path); |
54 | 58 |
55 // ProfileInfoInterface: | 59 // ProfileInfoInterface: |
56 size_t GetNumberOfProfiles() const override; | 60 size_t GetNumberOfProfiles() const override; |
57 // Don't cache this value and reuse, because resorting the menu could cause | 61 // Don't cache this value and reuse, because resorting the menu could cause |
58 // the item being referred to to change out from under you. | 62 // the item being referred to to change out from under you. |
59 size_t GetIndexOfProfileWithPath( | 63 size_t GetIndexOfProfileWithPath( |
60 const base::FilePath& profile_path) const override; | 64 const base::FilePath& profile_path) const override; |
61 base::string16 GetNameOfProfileAtIndex(size_t index) const override; | 65 base::string16 GetNameOfProfileAtIndex(size_t index) const override; |
62 base::string16 GetShortcutNameOfProfileAtIndex(size_t index) const override; | 66 base::string16 GetShortcutNameOfProfileAtIndex(size_t index) const override; |
(...skipping 13 matching lines...) Expand all Loading... |
76 // Returns the GAIA picture for the given profile. This may return NULL | 80 // Returns the GAIA picture for the given profile. This may return NULL |
77 // if the profile does not have a GAIA picture or if the picture must be | 81 // if the profile does not have a GAIA picture or if the picture must be |
78 // loaded from disk. | 82 // loaded from disk. |
79 const gfx::Image* GetGAIAPictureOfProfileAtIndex(size_t index) const override; | 83 const gfx::Image* GetGAIAPictureOfProfileAtIndex(size_t index) const override; |
80 bool IsUsingGAIAPictureOfProfileAtIndex(size_t index) const override; | 84 bool IsUsingGAIAPictureOfProfileAtIndex(size_t index) const override; |
81 bool ProfileIsSupervisedAtIndex(size_t index) const override; | 85 bool ProfileIsSupervisedAtIndex(size_t index) const override; |
82 bool ProfileIsChildAtIndex(size_t index) const override; | 86 bool ProfileIsChildAtIndex(size_t index) const override; |
83 bool ProfileIsLegacySupervisedAtIndex(size_t index) const override; | 87 bool ProfileIsLegacySupervisedAtIndex(size_t index) const override; |
84 bool IsOmittedProfileAtIndex(size_t index) const override; | 88 bool IsOmittedProfileAtIndex(size_t index) const override; |
85 bool ProfileIsSigninRequiredAtIndex(size_t index) const override; | 89 bool ProfileIsSigninRequiredAtIndex(size_t index) const override; |
86 std::string GetSupervisedUserIdOfProfileAtIndex(size_t index) const override; | 90 user_manager::UserID GetSupervisedUserIdOfProfileAtIndex(size_t index) const o
verride; |
87 bool ProfileIsEphemeralAtIndex(size_t index) const override; | 91 bool ProfileIsEphemeralAtIndex(size_t index) const override; |
88 bool ProfileIsUsingDefaultNameAtIndex(size_t index) const override; | 92 bool ProfileIsUsingDefaultNameAtIndex(size_t index) const override; |
89 bool ProfileIsAuthenticatedAtIndex(size_t index) const override; | 93 bool ProfileIsAuthenticatedAtIndex(size_t index) const override; |
90 bool ProfileIsUsingDefaultAvatarAtIndex(size_t index) const override; | 94 bool ProfileIsUsingDefaultAvatarAtIndex(size_t index) const override; |
91 bool ProfileIsAuthErrorAtIndex(size_t index) const; | 95 bool ProfileIsAuthErrorAtIndex(size_t index) const; |
92 | 96 |
93 size_t GetAvatarIconIndexOfProfileAtIndex(size_t index) const; | 97 size_t GetAvatarIconIndexOfProfileAtIndex(size_t index) const; |
94 | 98 |
95 void SetProfileActiveTimeAtIndex(size_t index); | 99 void SetProfileActiveTimeAtIndex(size_t index); |
96 // Warning: This will re-sort profiles and thus may change indices! | 100 // Warning: This will re-sort profiles and thus may change indices! |
97 void SetNameOfProfileAtIndex(size_t index, const base::string16& name); | 101 void SetNameOfProfileAtIndex(size_t index, const base::string16& name); |
98 void SetShortcutNameOfProfileAtIndex(size_t index, | 102 void SetShortcutNameOfProfileAtIndex(size_t index, |
99 const base::string16& name); | 103 const base::string16& name); |
100 void SetAuthInfoOfProfileAtIndex(size_t index, | 104 void SetAuthInfoOfProfileAtIndex(size_t index, |
101 const std::string& gaia_id, | 105 const std::string& gaia_id, |
102 const base::string16& user_name); | 106 const base::string16& user_name); |
103 void SetAvatarIconOfProfileAtIndex(size_t index, size_t icon_index); | 107 void SetAvatarIconOfProfileAtIndex(size_t index, size_t icon_index); |
104 void SetIsOmittedProfileAtIndex(size_t index, bool is_omitted); | 108 void SetIsOmittedProfileAtIndex(size_t index, bool is_omitted); |
105 void SetSupervisedUserIdOfProfileAtIndex(size_t index, const std::string& id); | 109 void SetSupervisedUserIdOfProfileAtIndex(size_t index, const user_manager::Use
rID& id); |
106 void SetLocalAuthCredentialsOfProfileAtIndex(size_t index, | 110 void SetLocalAuthCredentialsOfProfileAtIndex(size_t index, |
107 const std::string& auth); | 111 const std::string& auth); |
108 void SetBackgroundStatusOfProfileAtIndex(size_t index, | 112 void SetBackgroundStatusOfProfileAtIndex(size_t index, |
109 bool running_background_apps); | 113 bool running_background_apps); |
110 // Warning: This will re-sort profiles and thus may change indices! | 114 // Warning: This will re-sort profiles and thus may change indices! |
111 void SetGAIANameOfProfileAtIndex(size_t index, const base::string16& name); | 115 void SetGAIANameOfProfileAtIndex(size_t index, const base::string16& name); |
112 // Warning: This will re-sort profiles and thus may change indices! | 116 // Warning: This will re-sort profiles and thus may change indices! |
113 void SetGAIAGivenNameOfProfileAtIndex(size_t index, | 117 void SetGAIAGivenNameOfProfileAtIndex(size_t index, |
114 const base::string16& name); | 118 const base::string16& name); |
115 void SetGAIAPictureOfProfileAtIndex(size_t index, const gfx::Image* image); | 119 void SetGAIAPictureOfProfileAtIndex(size_t index, const gfx::Image* image); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 avatar_images_downloads_in_progress_; | 240 avatar_images_downloads_in_progress_; |
237 | 241 |
238 // Determines of the ProfileAvatarDownloader should be created and executed | 242 // Determines of the ProfileAvatarDownloader should be created and executed |
239 // or not. Only set to true for tests. | 243 // or not. Only set to true for tests. |
240 bool disable_avatar_download_for_testing_; | 244 bool disable_avatar_download_for_testing_; |
241 | 245 |
242 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); | 246 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); |
243 }; | 247 }; |
244 | 248 |
245 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ | 249 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ |
OLD | NEW |