| 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 345503c59e777a52a9822f0f6fdedc1922deecf5..017341bc89bed3ef4e81999ba5c04976f84b7626 100644
|
| --- a/chrome/browser/profiles/profile_info_cache.h
|
| +++ b/chrome/browser/profiles/profile_info_cache.h
|
| @@ -7,6 +7,7 @@
|
| #pragma once
|
|
|
| #include <string>
|
| +#include <map>
|
| #include <vector>
|
|
|
| #include "base/basictypes.h"
|
| @@ -14,18 +15,10 @@
|
| #include "base/file_path.h"
|
| #include "base/string16.h"
|
| #include "chrome/browser/profiles/profile_info_interface.h"
|
| -
|
| -namespace gfx {
|
| -class Image;
|
| -}
|
| -
|
| -namespace base {
|
| -class DictionaryValue;
|
| -}
|
| +#include "chrome/browser/profiles/profile_info_entry.h"
|
|
|
| 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.
|
| @@ -34,81 +27,30 @@ class ProfileInfoCache : public ProfileInfoInterface {
|
| ProfileInfoCache(PrefService* prefs, const FilePath& user_data_dir);
|
| virtual ~ProfileInfoCache();
|
|
|
| - void AddProfileToCache(const FilePath& profile_path,
|
| - const string16& name,
|
| - const string16& username,
|
| - size_t icon_index);
|
| - void DeleteProfileFromCache(const FilePath& profile_path);
|
| -
|
| // ProfileInfoInterface:
|
| virtual size_t GetNumberOfProfiles() const OVERRIDE;
|
| - // Don't cache this value and reuse, because resorting the menu could cause
|
| - // the item being referred to to change out from under you.
|
| - virtual size_t GetIndexOfProfileWithPath(
|
| - const FilePath& profile_path) const OVERRIDE;
|
| - virtual string16 GetNameOfProfileAtIndex(size_t index) const OVERRIDE;
|
| - virtual FilePath GetPathOfProfileAtIndex(size_t index) const OVERRIDE;
|
| - virtual string16 GetUserNameOfProfileAtIndex(size_t index) const OVERRIDE;
|
| - virtual const gfx::Image& GetAvatarIconOfProfileAtIndex(
|
| - size_t index) const OVERRIDE;
|
| - virtual bool GetBackgroundStatusOfProfileAtIndex(
|
| - size_t index) const OVERRIDE;
|
| -
|
| - size_t GetAvatarIconIndexOfProfileAtIndex(size_t index) const;
|
| -
|
| - void SetNameOfProfileAtIndex(size_t index, const string16& name);
|
| - void SetUserNameOfProfileAtIndex(size_t index, const string16& user_name);
|
| - void SetAvatarIconOfProfileAtIndex(size_t index, size_t icon_index);
|
| - void SetBackgroundStatusOfProfileAtIndex(size_t index,
|
| - bool running_background_apps);
|
| -
|
| - // Returns unique name that can be assigned to a newly created profile.
|
| - string16 ChooseNameForNewProfile(size_t icon_index);
|
| -
|
| - // 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.
|
| - size_t ChooseAvatarIconIndexForNewProfile() const;
|
|
|
| - const FilePath& GetUserDataDir() const;
|
| + virtual std::vector<ProfileInfoEntry> GetProfilesSortedByName()
|
| + const OVERRIDE;
|
|
|
| - // Gets the number of default avatar icons that exist.
|
| - static size_t GetDefaultAvatarIconCount();
|
| - // Gets the resource ID of the default avatar icon at |index|.
|
| - static int GetDefaultAvatarIconResourceIDAtIndex(size_t index);
|
| - // Returns a URL for the default avatar icon with specified index.
|
| - static std::string GetDefaultAvatarIconUrl(size_t index);
|
| - // Checks if the given URL points to one of the default avatar icons. If it
|
| - // is, returns true and its index through |icon_index|. If not, returns false.
|
| - static bool IsDefaultAvatarIconUrl(const std::string& icon_url,
|
| - size_t *icon_index);
|
| + virtual bool GetInfoForProfile(const FilePath& path,
|
| + ProfileInfoEntry* entry) const OVERRIDE;
|
| +
|
| + void DeleteProfileFromCache(const FilePath& profile_path);
|
| +
|
| + void SetInfoForProfile(const ProfileInfoEntry& info);
|
| +
|
| + const FilePath& GetUserDataDir() const;
|
|
|
| // Register cache related preferences in Local State.
|
| static void RegisterPrefs(PrefService* prefs);
|
|
|
| private:
|
| - const base::DictionaryValue* GetInfoForProfileAtIndex(size_t index) const;
|
| - // Saves the profile info to a cache and takes ownership of |info|.
|
| - // Currently the only information that is cached is the profiles name,
|
| - // user name, and avatar icon.
|
| - void SetInfoForProfileAtIndex(size_t index, base::DictionaryValue* info);
|
| std::string CacheKeyFromProfilePath(const FilePath& profile_path) const;
|
| - std::vector<std::string>::iterator FindPositionForProfile(
|
| - std::string search_key,
|
| - const string16& search_name);
|
| -
|
| - // Returns true if the given icon index is not in use by another profie.
|
| - bool IconIndexIsUnique(size_t icon_index) const;
|
| -
|
| - // Tries to find an icon index that satisfies all the given conditions.
|
| - // Returns true if an icon was found, false otherwise.
|
| - bool ChooseAvatarIconIndexForNewProfile(bool allow_generic_icon,
|
| - bool must_be_unique,
|
| - size_t* out_icon_index) const;
|
|
|
| PrefService* prefs_;
|
| - std::vector<std::string> sorted_keys_;
|
| FilePath user_data_dir_;
|
| + std::map<std::string, ProfileInfoEntry> cached_entries_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache);
|
| };
|
|
|