Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: chrome/browser/profiles/profile_info_cache.h

Issue 8673003: Revert 111254 - Add GAIA info to profile info cache (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <map>
10 #include <string> 9 #include <string>
11 #include <vector> 10 #include <vector>
12 11
13 #include "base/basictypes.h" 12 #include "base/basictypes.h"
14 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
15 #include "base/file_path.h" 14 #include "base/file_path.h"
16 #include "base/memory/weak_ptr.h"
17 #include "base/observer_list.h" 15 #include "base/observer_list.h"
18 #include "base/string16.h" 16 #include "base/string16.h"
19 #include "chrome/browser/profiles/profile_info_cache_observer.h" 17 #include "chrome/browser/profiles/profile_info_cache_observer.h"
20 #include "chrome/browser/profiles/profile_info_interface.h" 18 #include "chrome/browser/profiles/profile_info_interface.h"
21 19
22 namespace gfx { 20 namespace gfx {
23 class Image; 21 class Image;
24 } 22 }
25 23
26 namespace base { 24 namespace base {
27 class DictionaryValue; 25 class DictionaryValue;
28 } 26 }
29 27
30 class PrefService; 28 class PrefService;
31 29
32 // This class saves various information about profiles to local preferences. 30 // This class saves various information about profiles to local preferences.
33 // This cache can be used to display a list of profiles without having to 31 // This cache can be used to display a list of profiles without having to
34 // actually load the profiles from disk. 32 // actually load the profiles from disk.
35 class ProfileInfoCache : public ProfileInfoInterface, 33 class ProfileInfoCache : public ProfileInfoInterface {
36 public base::SupportsWeakPtr<ProfileInfoCache> {
37 public: 34 public:
38 ProfileInfoCache(PrefService* prefs, const FilePath& user_data_dir); 35 ProfileInfoCache(PrefService* prefs, const FilePath& user_data_dir);
39 virtual ~ProfileInfoCache(); 36 virtual ~ProfileInfoCache();
40 37
41 void AddProfileToCache(const FilePath& profile_path, 38 void AddProfileToCache(const FilePath& profile_path,
42 const string16& name, 39 const string16& name,
43 const string16& username, 40 const string16& username,
44 size_t icon_index); 41 size_t icon_index);
45 void DeleteProfileFromCache(const FilePath& profile_path); 42 void DeleteProfileFromCache(const FilePath& profile_path);
46 43
47 // ProfileInfoInterface: 44 // ProfileInfoInterface:
48 virtual size_t GetNumberOfProfiles() const OVERRIDE; 45 virtual size_t GetNumberOfProfiles() const OVERRIDE;
49 // Don't cache this value and reuse, because resorting the menu could cause 46 // Don't cache this value and reuse, because resorting the menu could cause
50 // the item being referred to to change out from under you. 47 // the item being referred to to change out from under you.
51 virtual size_t GetIndexOfProfileWithPath( 48 virtual size_t GetIndexOfProfileWithPath(
52 const FilePath& profile_path) const OVERRIDE; 49 const FilePath& profile_path) const OVERRIDE;
53 virtual string16 GetNameOfProfileAtIndex(size_t index) const OVERRIDE; 50 virtual string16 GetNameOfProfileAtIndex(size_t index) const OVERRIDE;
54 virtual FilePath GetPathOfProfileAtIndex(size_t index) const OVERRIDE; 51 virtual FilePath GetPathOfProfileAtIndex(size_t index) const OVERRIDE;
55 virtual string16 GetUserNameOfProfileAtIndex(size_t index) const OVERRIDE; 52 virtual string16 GetUserNameOfProfileAtIndex(size_t index) const OVERRIDE;
56 virtual const gfx::Image& GetAvatarIconOfProfileAtIndex( 53 virtual const gfx::Image& GetAvatarIconOfProfileAtIndex(
57 size_t index) const OVERRIDE; 54 size_t index) const OVERRIDE;
58 virtual bool GetBackgroundStatusOfProfileAtIndex( 55 virtual bool GetBackgroundStatusOfProfileAtIndex(
59 size_t index) const OVERRIDE; 56 size_t index) const OVERRIDE;
60 virtual string16 GetGAIANameOfProfileAtIndex(size_t index) const OVERRIDE;
61 virtual bool IsUsingGAIANameOfProfileAtIndex(size_t index) const OVERRIDE;
62 virtual const gfx::Image& GetGAIAPictureOfProfileAtIndex(
63 size_t index) const OVERRIDE;
64 virtual bool IsUsingGAIAPictureOfProfileAtIndex(
65 size_t index) const OVERRIDE;
66 57
67 size_t GetAvatarIconIndexOfProfileAtIndex(size_t index) const; 58 size_t GetAvatarIconIndexOfProfileAtIndex(size_t index) const;
68 59
69 void SetNameOfProfileAtIndex(size_t index, const string16& name); 60 void SetNameOfProfileAtIndex(size_t index, const string16& name);
70 void SetUserNameOfProfileAtIndex(size_t index, const string16& user_name); 61 void SetUserNameOfProfileAtIndex(size_t index, const string16& user_name);
71 void SetAvatarIconOfProfileAtIndex(size_t index, size_t icon_index); 62 void SetAvatarIconOfProfileAtIndex(size_t index, size_t icon_index);
72 void SetBackgroundStatusOfProfileAtIndex(size_t index, 63 void SetBackgroundStatusOfProfileAtIndex(size_t index,
73 bool running_background_apps); 64 bool running_background_apps);
74 void SetGAIANameOfProfileAtIndex(size_t index, const string16& name);
75 void SetIsUsingGAIANameOfProfileAtIndex(size_t index, bool value);
76 void SetGAIAPictureOfProfileAtIndex(size_t index, const gfx::Image& image);
77 void SetIsUsingGAIAPictureOfProfileAtIndex(size_t index, bool value);
78 65
79 // Returns unique name that can be assigned to a newly created profile. 66 // Returns unique name that can be assigned to a newly created profile.
80 string16 ChooseNameForNewProfile(size_t icon_index); 67 string16 ChooseNameForNewProfile(size_t icon_index);
81 68
82 // Checks if the given profile has switched to using GAIA information
83 // for the profile name and picture. This pref is used to switch over
84 // to GAIA info the first time it is available. Afterwards this pref is
85 // checked to prevent clobbering the user's custom settings.
86 bool GetHasMigratedToGAIAInfoOfProfileAtIndex(size_t index) const;
87
88 // Marks the given profile as having switched to using GAIA information
89 // for the profile name and picture.
90 void SetHasMigratedToGAIAInfoOfProfileAtIndex(size_t index, bool value);
91
92 // Returns an avatar icon index that can be assigned to a newly created 69 // Returns an avatar icon index that can be assigned to a newly created
93 // profile. Note that the icon may not be unique since there are a limited 70 // profile. Note that the icon may not be unique since there are a limited
94 // set of default icons. 71 // set of default icons.
95 size_t ChooseAvatarIconIndexForNewProfile() const; 72 size_t ChooseAvatarIconIndexForNewProfile() const;
96 73
97 const FilePath& GetUserDataDir() const; 74 const FilePath& GetUserDataDir() const;
98 75
99 // Gets the number of default avatar icons that exist. 76 // Gets the number of default avatar icons that exist.
100 static size_t GetDefaultAvatarIconCount(); 77 static size_t GetDefaultAvatarIconCount();
101 // Gets the resource ID of the default avatar icon at |index|. 78 // Gets the resource ID of the default avatar icon at |index|.
(...skipping 30 matching lines...) Expand all
132 109
133 // Returns true if the given icon index is not in use by another profie. 110 // Returns true if the given icon index is not in use by another profie.
134 bool IconIndexIsUnique(size_t icon_index) const; 111 bool IconIndexIsUnique(size_t icon_index) const;
135 112
136 // Tries to find an icon index that satisfies all the given conditions. 113 // Tries to find an icon index that satisfies all the given conditions.
137 // Returns true if an icon was found, false otherwise. 114 // Returns true if an icon was found, false otherwise.
138 bool ChooseAvatarIconIndexForNewProfile(bool allow_generic_icon, 115 bool ChooseAvatarIconIndexForNewProfile(bool allow_generic_icon,
139 bool must_be_unique, 116 bool must_be_unique,
140 size_t* out_icon_index) const; 117 size_t* out_icon_index) const;
141 118
142 // Updates the position of the profile at the given index so that the list
143 // of profiles is still sorted.
144 void UpdateSortForProfileIndex(size_t index);
145
146 void OnGAIAPictureLoaded(FilePath path, gfx::Image** image) const;
147 void OnGAIAPictureSaved(FilePath path, bool* success) const;
148
149 PrefService* prefs_; 119 PrefService* prefs_;
150 std::vector<std::string> sorted_keys_; 120 std::vector<std::string> sorted_keys_;
151 FilePath user_data_dir_; 121 FilePath user_data_dir_;
152 122
153 ObserverList<ProfileInfoCacheObserver> observer_list_; 123 ObserverList<ProfileInfoCacheObserver> observer_list_;
154 124
155 // A cache of gaia profile pictures. This cache is updated lazily so it needs
156 // to be mutable.
157 mutable std::map<std::string, gfx::Image*> gaia_pictures_;
158
159 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); 125 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache);
160 }; 126 };
161 127
162 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ 128 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/user_manager.h ('k') | chrome/browser/profiles/profile_info_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698