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 #ifndef CHROME_BROWSER_PROFILES_PROFILE_ATTRIBUTES_STORAGE_H_ | 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_ATTRIBUTES_STORAGE_H_ |
6 #define CHROME_BROWSER_PROFILES_PROFILE_ATTRIBUTES_STORAGE_H_ | 6 #define CHROME_BROWSER_PROFILES_PROFILE_ATTRIBUTES_STORAGE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
| 10 #include <string> |
| 11 #include <vector> |
| 12 |
10 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/strings/string16.h" |
| 15 #include "chrome/browser/profiles/profile_info_cache_observer.h" |
11 | 16 |
| 17 namespace base { |
| 18 class FilePath; |
| 19 } // namespace base |
12 class ProfileAttributesEntry; | 20 class ProfileAttributesEntry; |
13 | 21 |
14 class ProfileAttributesStorage { | 22 class ProfileAttributesStorage { |
15 public: | 23 public: |
| 24 using Observer = ProfileInfoCacheObserver; |
| 25 |
16 ProfileAttributesStorage() {} | 26 ProfileAttributesStorage() {} |
17 ~ProfileAttributesStorage() {} | 27 ~ProfileAttributesStorage() {} |
18 | 28 |
19 // If the |supervised_user_id| is non-empty, the profile will be marked to be | 29 // If the |supervised_user_id| is non-empty, the profile will be marked to be |
20 // omitted from the avatar-menu list on desktop versions. This is used while a | 30 // omitted from the avatar-menu list on desktop versions. This is used while a |
21 // supervised user is in the process of being registered with the server. Use | 31 // supervised user is in the process of being registered with the server. Use |
22 // ProfileAttributesEntry::SetIsOmitted() to clear the flag when the profile | 32 // ProfileAttributesEntry::SetIsOmitted() to clear the flag when the profile |
23 // is ready to be shown in the menu. | 33 // is ready to be shown in the menu. |
24 virtual void AddProfile(const base::FilePath& profile_path, | 34 virtual void AddProfile(const base::FilePath& profile_path, |
25 const base::string16& name, | 35 const base::string16& name, |
26 const std::string& gaia_id, | 36 const std::string& gaia_id, |
27 const base::string16& user_name, | 37 const base::string16& user_name, |
28 size_t icon_index, | 38 size_t icon_index, |
29 const std::string& supervised_user_id) = 0; | 39 const std::string& supervised_user_id) = 0; |
30 // Removes the profile at |profile_path| from this storage. Does not delete or | 40 // Removes the profile at |profile_path| from this storage. Does not delete or |
31 // affect the actual profile's data. | 41 // affect the actual profile's data. |
32 virtual void RemoveProfile(const base::FilePath& profile_path) = 0; | 42 virtual void RemoveProfile(const base::FilePath& profile_path) = 0; |
33 | 43 |
34 // Returns a vector containing one attributes entry per known profile. They | 44 // Returns a vector containing one attributes entry per known profile. They |
35 // are not sorted in any particular order. | 45 // are not sorted in any particular order. |
36 virtual std::vector<ProfileAttributesEntry*> GetAllProfilesAttributes() = 0; | 46 virtual std::vector<ProfileAttributesEntry*> GetAllProfilesAttributes() = 0; |
| 47 virtual std::vector<ProfileAttributesEntry*> |
| 48 GetAllProfilesAttributesSortedByName() = 0; |
37 | 49 |
38 // Populates |entry| with the data for the profile at |path| and returns true | 50 // Populates |entry| with the data for the profile at |path| and returns true |
39 // if the operation is successful and |entry| can be used. Returns false | 51 // if the operation is successful and |entry| can be used. Returns false |
40 // otherwise. | 52 // otherwise. |
41 // |entry| should not be cached as it may not reflect subsequent changes to | 53 // |entry| should not be cached as it may not reflect subsequent changes to |
42 // the profile's metadata. | 54 // the profile's metadata. |
43 virtual bool GetProfileAttributesWithPath( | 55 virtual bool GetProfileAttributesWithPath( |
44 const base::FilePath& path, ProfileAttributesEntry** entry) = 0; | 56 const base::FilePath& path, ProfileAttributesEntry** entry) = 0; |
45 | 57 |
46 // Returns the count of known profiles. | 58 // Returns the count of known profiles. |
47 virtual size_t GetNumberOfProfiles() const = 0; | 59 virtual size_t GetNumberOfProfiles() const = 0; |
48 | 60 |
| 61 virtual void AddObserver(ProfileAttributesStorage::Observer* observer) = 0; |
| 62 virtual void RemoveObserver(ProfileAttributesStorage::Observer* observer) = 0; |
| 63 |
| 64 private: |
49 DISALLOW_COPY_AND_ASSIGN(ProfileAttributesStorage); | 65 DISALLOW_COPY_AND_ASSIGN(ProfileAttributesStorage); |
50 }; | 66 }; |
51 | 67 |
52 #endif // CHROME_BROWSER_PROFILES_PROFILE_ATTRIBUTES_STORAGE_H_ | 68 #endif // CHROME_BROWSER_PROFILES_PROFILE_ATTRIBUTES_STORAGE_H_ |
OLD | NEW |