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

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

Issue 7155015: Store profile avatar to preferences (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments Created 9 years, 6 months 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_
6 #define CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_
7 #pragma once
8
9 #include <string>
10 #include <vector>
11
12 #include "base/basictypes.h"
13 #include "base/file_path.h"
14 #include "base/string16.h"
15
16 namespace gfx {
17 class Image;
18 }
19
20 class DictionaryValue;
21 class PrefService;
22
23
24 // This class saves various information about profiles to local preferences.
25 // This cache can be used to display a list of profiles without having to
26 // actually load the profiles from disk.
27 class ProfileInfoCache {
28 public:
29 explicit ProfileInfoCache(const FilePath& user_data_dir);
30
31 void AddProfileToCache(const FilePath& profile_path,
32 const string16& name,
33 size_t icon_index);
34 void DeleteProfileFromCache(const FilePath& profile_path);
35
36 size_t GetNumberOfProfiles() const;
37 string16 GetNameOfProfileAtIndex(size_t index) const;
38 FilePath GetPathOfProfileAtIndex(size_t index) const;
39 const gfx::Image& GetAvatarIconOfProfileAtIndex(size_t index) const;
40
41 void SetNameOfProfileAtIndex(size_t index, const string16& name);
42 void SetAvatarIconOfProfileAtIndex(size_t index, size_t icon_index);
43
44 // Gets the number of default avatar icons that exist.
45 static size_t GetDefaultAvatarIconCount();
46 // Gets the resource ID of the default avatar icon at |index|.
47 static int GetDefaultAvatarIconResourceIDAtIndex(size_t index);
48
49 // Register cache related preferences in Local State.
50 static void RegisterPrefs(PrefService* prefs);
51
52 private:
53 const DictionaryValue* GetInfoForProfileAtIndex(size_t index) const;
54 // Saves the profile info to a cache and takes ownership of |info|.
55 // Currently the only information that is cached is the profiles name and
56 // avatar icon.
57 void SetInfoForProfileAtIndex(size_t index, DictionaryValue* info);
58 std::string CacheKeyFromProfilePath(const FilePath& profile_path) const;
59 std::vector<std::string>::iterator FindPositionForProfile(
60 std::string search_key,
61 const string16& search_name);
62
63 std::vector<std::string> sorted_keys_;
64 FilePath user_data_dir_;
65
66 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache);
67 };
68
69 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698