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

Unified Diff: chrome/browser/profiles/profile_info_cache.h

Issue 8587023: Add GAIA info to profile info cache (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix leak 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_info_cache.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_info_cache.h
diff --git a/chrome/browser/profiles/profile_info_cache.h b/chrome/browser/profiles/profile_info_cache.h
index 63e08ff4509ddbb27f6ad57f89d04c35f59e9321..9687910c0809a0272e6ee34bd6ab79acea8f0c71 100644
--- a/chrome/browser/profiles/profile_info_cache.h
+++ b/chrome/browser/profiles/profile_info_cache.h
@@ -6,12 +6,14 @@
#define CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_
#pragma once
+#include <map>
#include <string>
#include <vector>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/file_path.h"
+#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/string16.h"
#include "chrome/browser/profiles/profile_info_cache_observer.h"
@@ -30,7 +32,8 @@ class PrefService;
// This class saves various information about profiles to local preferences.
// This cache can be used to display a list of profiles without having to
// actually load the profiles from disk.
-class ProfileInfoCache : public ProfileInfoInterface {
+class ProfileInfoCache : public ProfileInfoInterface,
+ public base::SupportsWeakPtr<ProfileInfoCache> {
public:
ProfileInfoCache(PrefService* prefs, const FilePath& user_data_dir);
virtual ~ProfileInfoCache();
@@ -54,6 +57,12 @@ class ProfileInfoCache : public ProfileInfoInterface {
size_t index) const OVERRIDE;
virtual bool GetBackgroundStatusOfProfileAtIndex(
size_t index) const OVERRIDE;
+ virtual string16 GetGAIANameOfProfileAtIndex(size_t index) const OVERRIDE;
+ virtual bool IsUsingGAIANameOfProfileAtIndex(size_t index) const OVERRIDE;
+ virtual const gfx::Image& GetGAIAPictureOfProfileAtIndex(
+ size_t index) const OVERRIDE;
+ virtual bool IsUsingGAIAPictureOfProfileAtIndex(
+ size_t index) const OVERRIDE;
size_t GetAvatarIconIndexOfProfileAtIndex(size_t index) const;
@@ -62,10 +71,24 @@ class ProfileInfoCache : public ProfileInfoInterface {
void SetAvatarIconOfProfileAtIndex(size_t index, size_t icon_index);
void SetBackgroundStatusOfProfileAtIndex(size_t index,
bool running_background_apps);
+ void SetGAIANameOfProfileAtIndex(size_t index, const string16& name);
+ void SetIsUsingGAIANameOfProfileAtIndex(size_t index, bool value);
+ void SetGAIAPictureOfProfileAtIndex(size_t index, const gfx::Image& image);
+ void SetIsUsingGAIAPictureOfProfileAtIndex(size_t index, bool value);
// Returns unique name that can be assigned to a newly created profile.
string16 ChooseNameForNewProfile(size_t icon_index);
+ // Checks if the given profile has switched to using GAIA information
+ // for the profile name and picture. This pref is used to switch over
+ // to GAIA info the first time it is available. Afterwards this pref is
+ // checked to prevent clobbering the user's custom settings.
+ bool GetHasMigratedToGAIAInfoOfProfileAtIndex(size_t index) const;
+
+ // Marks the given profile as having switched to using GAIA information
+ // for the profile name and picture.
+ void SetHasMigratedToGAIAInfoOfProfileAtIndex(size_t index, bool value);
+
// Returns an avatar icon index that can be assigned to a newly created
// profile. Note that the icon may not be unique since there are a limited
// set of default icons.
@@ -116,12 +139,23 @@ class ProfileInfoCache : public ProfileInfoInterface {
bool must_be_unique,
size_t* out_icon_index) const;
+ // Updates the position of the profile at the given index so that the list
+ // of profiles is still sorted.
+ void UpdateSortForProfileIndex(size_t index);
+
+ void OnGAIAPictureLoaded(FilePath path, gfx::Image** image) const;
+ void OnGAIAPictureSaved(FilePath path, bool* success) const;
+
PrefService* prefs_;
std::vector<std::string> sorted_keys_;
FilePath user_data_dir_;
ObserverList<ProfileInfoCacheObserver> observer_list_;
+ // A cache of gaia profile pictures. This cache is updated lazily so it needs
+ // to be mutable.
+ mutable std::map<std::string, gfx::Image*> gaia_pictures_;
+
DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache);
};
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_info_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698