OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
| 11 #include <map> |
11 | 12 |
12 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
14 #include "base/file_path.h" | 15 #include "base/file_path.h" |
15 #include "base/string16.h" | 16 #include "base/string16.h" |
16 #include "chrome/browser/profiles/profile_info_interface.h" | 17 #include "chrome/browser/profiles/profile_info_interface.h" |
| 18 #include "third_party/skia/include/core/SkBitmap.h" |
17 | 19 |
18 namespace gfx { | 20 namespace gfx { |
19 class Image; | 21 class Image; |
20 } | 22 } |
21 | 23 |
22 namespace base { | 24 namespace base { |
23 class DictionaryValue; | 25 class DictionaryValue; |
24 } | 26 } |
25 | 27 |
26 class PrefService; | 28 class PrefService; |
(...skipping 13 matching lines...) Expand all Loading... |
40 size_t icon_index); | 42 size_t icon_index); |
41 void DeleteProfileFromCache(const FilePath& profile_path); | 43 void DeleteProfileFromCache(const FilePath& profile_path); |
42 | 44 |
43 // ProfileInfoInterface: | 45 // ProfileInfoInterface: |
44 virtual size_t GetNumberOfProfiles() const OVERRIDE; | 46 virtual size_t GetNumberOfProfiles() const OVERRIDE; |
45 // Don't cache this value and reuse, because resorting the menu could cause | 47 // Don't cache this value and reuse, because resorting the menu could cause |
46 // the item being referred to to change out from under you. | 48 // the item being referred to to change out from under you. |
47 virtual size_t GetIndexOfProfileWithPath( | 49 virtual size_t GetIndexOfProfileWithPath( |
48 const FilePath& profile_path) const OVERRIDE; | 50 const FilePath& profile_path) const OVERRIDE; |
49 virtual string16 GetNameOfProfileAtIndex(size_t index) const OVERRIDE; | 51 virtual string16 GetNameOfProfileAtIndex(size_t index) const OVERRIDE; |
| 52 virtual string16 GetGAIANameOfProfileAtIndex(size_t index) const OVERRIDE; |
| 53 virtual SkBitmap GetGAIAPictureOfProfileAtIndex(size_t index) const OVERRIDE; |
50 virtual FilePath GetPathOfProfileAtIndex(size_t index) const OVERRIDE; | 54 virtual FilePath GetPathOfProfileAtIndex(size_t index) const OVERRIDE; |
51 virtual string16 GetUserNameOfProfileAtIndex(size_t index) const OVERRIDE; | 55 virtual string16 GetUserNameOfProfileAtIndex(size_t index) const OVERRIDE; |
52 virtual const gfx::Image& GetAvatarIconOfProfileAtIndex( | 56 virtual gfx::Image GetAvatarIconOfProfileAtIndex( |
53 size_t index) const OVERRIDE; | 57 size_t index) const OVERRIDE; |
54 virtual bool GetBackgroundStatusOfProfileAtIndex( | 58 virtual bool GetBackgroundStatusOfProfileAtIndex( |
55 size_t index) const OVERRIDE; | 59 size_t index) const OVERRIDE; |
56 | 60 |
| 61 virtual bool IsUsingCustomAvatarIconForProfileAtIndex( |
| 62 size_t index) const; |
| 63 virtual void SetIsUsingCustomAvatarIconForProfileAtIndex( |
| 64 size_t index, bool value); |
| 65 |
| 66 virtual bool IsUsinGAIANameForProfileAtIndex( |
| 67 size_t index) const; |
| 68 virtual void SetIsUsingGAIANameForProfileAtIndex( |
| 69 size_t index, bool value); |
| 70 |
57 size_t GetAvatarIconIndexOfProfileAtIndex(size_t index) const; | 71 size_t GetAvatarIconIndexOfProfileAtIndex(size_t index) const; |
58 | 72 |
59 void SetNameOfProfileAtIndex(size_t index, const string16& name); | 73 void SetNameOfProfileAtIndex(size_t index, const string16& name); |
| 74 void SetGAIANameOfProfileAtIndex(size_t index, const string16& name); |
| 75 void SetGAIAPictureOfProfileAtIndex(size_t index, |
| 76 const SkBitmap& bitmap); |
60 void SetUserNameOfProfileAtIndex(size_t index, const string16& user_name); | 77 void SetUserNameOfProfileAtIndex(size_t index, const string16& user_name); |
61 void SetAvatarIconOfProfileAtIndex(size_t index, size_t icon_index); | 78 void SetAvatarIconOfProfileAtIndex(size_t index, size_t icon_index); |
62 void SetBackgroundStatusOfProfileAtIndex(size_t index, | 79 void SetBackgroundStatusOfProfileAtIndex(size_t index, |
63 bool running_background_apps); | 80 bool running_background_apps); |
64 | 81 |
65 // Returns unique name that can be assigned to a newly created profile. | 82 // Returns unique name that can be assigned to a newly created profile. |
66 string16 ChooseNameForNewProfile(size_t icon_index); | 83 string16 ChooseNameForNewProfile(size_t icon_index); |
67 | 84 |
68 // Returns an avatar icon index that can be assigned to a newly created | 85 // Returns an avatar icon index that can be assigned to a newly created |
69 // profile. Note that the icon may not be unique since there are a limited | 86 // profile. Note that the icon may not be unique since there are a limited |
(...skipping 29 matching lines...) Expand all Loading... |
99 | 116 |
100 // Returns true if the given icon index is not in use by another profie. | 117 // Returns true if the given icon index is not in use by another profie. |
101 bool IconIndexIsUnique(size_t icon_index) const; | 118 bool IconIndexIsUnique(size_t icon_index) const; |
102 | 119 |
103 // Tries to find an icon index that satisfies all the given conditions. | 120 // Tries to find an icon index that satisfies all the given conditions. |
104 // Returns true if an icon was found, false otherwise. | 121 // Returns true if an icon was found, false otherwise. |
105 bool ChooseAvatarIconIndexForNewProfile(bool allow_generic_icon, | 122 bool ChooseAvatarIconIndexForNewProfile(bool allow_generic_icon, |
106 bool must_be_unique, | 123 bool must_be_unique, |
107 size_t* out_icon_index) const; | 124 size_t* out_icon_index) const; |
108 | 125 |
| 126 FilePath GetImagePath(std::string key, |
| 127 string16 file_name); |
| 128 void ReadBitmap(std::string key, |
| 129 string16 file_name, |
| 130 SkBitmap* bmp); |
| 131 void SaveBitmap(std::string key, |
| 132 string16 file_name, |
| 133 const SkBitmap& image); |
| 134 |
109 PrefService* prefs_; | 135 PrefService* prefs_; |
110 std::vector<std::string> sorted_keys_; | 136 std::vector<std::string> sorted_keys_; |
111 FilePath user_data_dir_; | 137 FilePath user_data_dir_; |
| 138 mutable std::map<std::string, SkBitmap*> bitmaps_; |
112 | 139 |
113 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); | 140 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); |
114 }; | 141 }; |
115 | 142 |
116 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ | 143 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ |
OLD | NEW |