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

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

Issue 7256002: Multi-Profiles: New Profile Setup UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: show product logo at bottom Created 9 years, 5 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(PrefService* prefs, 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 size_t GetIndexOfProfileWithPath(const FilePath& profile_path) const;
38 string16 GetNameOfProfileAtIndex(size_t index) const;
39 FilePath GetPathOfProfileAtIndex(size_t index) const;
40 const gfx::Image& GetAvatarIconOfProfileAtIndex(size_t index) const;
41 size_t GetAvatarIconIndexOfProfileAtIndex(size_t index) const;
42
43 void SetNameOfProfileAtIndex(size_t index, const string16& name);
44 void SetAvatarIconOfProfileAtIndex(size_t index, size_t icon_index);
45
46 // Gets the number of default avatar icons that exist.
47 static size_t GetDefaultAvatarIconCount();
48 // Gets the resource ID of the default avatar icon at |index|.
49 static int GetDefaultAvatarIconResourceIDAtIndex(size_t index);
50 // Returns a URL for the default avatar icon with specified index.
51 static std::string GetDefaultAvatarIconUrl(size_t index);
52
53 // Register cache related preferences in Local State.
54 static void RegisterPrefs(PrefService* prefs);
55
56 private:
57 const DictionaryValue* GetInfoForProfileAtIndex(size_t index) const;
58 // Saves the profile info to a cache and takes ownership of |info|.
59 // Currently the only information that is cached is the profiles name and
60 // avatar icon.
61 void SetInfoForProfileAtIndex(size_t index, DictionaryValue* info);
62 std::string CacheKeyFromProfilePath(const FilePath& profile_path) const;
63 std::vector<std::string>::iterator FindPositionForProfile(
64 std::string search_key,
65 const string16& search_name);
66
67 PrefService* prefs_;
68 std::vector<std::string> sorted_keys_;
69 FilePath user_data_dir_;
70
71 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache);
72 };
73
74 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698