OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_UI_APP_LIST_APP_LIST_PREFS_H_ | 5 #ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_PREFS_H_ |
6 #define CHROME_BROWSER_UI_APP_LIST_APP_LIST_PREFS_H_ | 6 #define CHROME_BROWSER_UI_APP_LIST_APP_LIST_PREFS_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <set> | 9 #include <set> |
9 #include <string> | 10 #include <string> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "components/keyed_service/core/keyed_service.h" | 16 #include "components/keyed_service/core/keyed_service.h" |
17 #include "sync/api/string_ordinal.h" | 17 #include "sync/api/string_ordinal.h" |
18 | 18 |
19 class PrefService; | 19 class PrefService; |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 class BrowserContext; | 22 class BrowserContext; |
23 } | 23 } |
(...skipping 15 matching lines...) Expand all Loading... |
39 APP_ITEM = ITEM_TYPE_BEGIN, | 39 APP_ITEM = ITEM_TYPE_BEGIN, |
40 FOLDER_ITEM, | 40 FOLDER_ITEM, |
41 | 41 |
42 // Do not change the order of this enum. | 42 // Do not change the order of this enum. |
43 // When adding values, remember to update ITEM_TYPE_END. | 43 // When adding values, remember to update ITEM_TYPE_END. |
44 ITEM_TYPE_END = FOLDER_ITEM, | 44 ITEM_TYPE_END = FOLDER_ITEM, |
45 }; | 45 }; |
46 AppListInfo(); | 46 AppListInfo(); |
47 AppListInfo(const AppListInfo& other); | 47 AppListInfo(const AppListInfo& other); |
48 ~AppListInfo(); | 48 ~AppListInfo(); |
49 scoped_ptr<base::DictionaryValue> CreateDictFromAppListInfo() const; | 49 std::unique_ptr<base::DictionaryValue> CreateDictFromAppListInfo() const; |
50 | 50 |
51 static scoped_ptr<AppListPrefs::AppListInfo> CreateAppListInfoFromDict( | 51 static std::unique_ptr<AppListPrefs::AppListInfo> CreateAppListInfoFromDict( |
52 const base::DictionaryValue* item_dict); | 52 const base::DictionaryValue* item_dict); |
53 | 53 |
54 // The id of the folder containing this item. | 54 // The id of the folder containing this item. |
55 std::string parent_id; | 55 std::string parent_id; |
56 | 56 |
57 // The name of this item. | 57 // The name of this item. |
58 std::string name; | 58 std::string name; |
59 | 59 |
60 // The position of this item in the app list. | 60 // The position of this item in the app list. |
61 syncer::StringOrdinal position; | 61 syncer::StringOrdinal position; |
62 | 62 |
63 // The type of app list item being represented. | 63 // The type of app list item being represented. |
64 ItemType item_type; | 64 ItemType item_type; |
65 }; | 65 }; |
66 | 66 |
67 typedef std::map<std::string, AppListInfo> AppListInfoMap; | 67 typedef std::map<std::string, AppListInfo> AppListInfoMap; |
68 | 68 |
69 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 69 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
70 | 70 |
71 static AppListPrefs* Get(content::BrowserContext* context); | 71 static AppListPrefs* Get(content::BrowserContext* context); |
72 | 72 |
73 static AppListPrefs* Create(PrefService* pref_service); | 73 static AppListPrefs* Create(PrefService* pref_service); |
74 | 74 |
75 ~AppListPrefs() override; | 75 ~AppListPrefs() override; |
76 | 76 |
77 // Sets the app list info for |id|. | 77 // Sets the app list info for |id|. |
78 void SetAppListInfo(const std::string& id, const AppListInfo& info); | 78 void SetAppListInfo(const std::string& id, const AppListInfo& info); |
79 | 79 |
80 // Gets the app list info for |id|. | 80 // Gets the app list info for |id|. |
81 scoped_ptr<AppListInfo> GetAppListInfo(const std::string& id) const; | 81 std::unique_ptr<AppListInfo> GetAppListInfo(const std::string& id) const; |
82 | 82 |
83 // Gets a map of all AppListInfo objects in the prefs. | 83 // Gets a map of all AppListInfo objects in the prefs. |
84 void GetAllAppListInfos(AppListInfoMap* out) const; | 84 void GetAllAppListInfos(AppListInfoMap* out) const; |
85 | 85 |
86 // Deletes the app list info for |id|. | 86 // Deletes the app list info for |id|. |
87 void DeleteAppListInfo(const std::string& id); | 87 void DeleteAppListInfo(const std::string& id); |
88 | 88 |
89 private: | 89 private: |
90 explicit AppListPrefs(PrefService* pref_service); | 90 explicit AppListPrefs(PrefService* pref_service); |
91 | 91 |
92 PrefService* pref_service_; | 92 PrefService* pref_service_; |
93 | 93 |
94 DISALLOW_COPY_AND_ASSIGN(AppListPrefs); | 94 DISALLOW_COPY_AND_ASSIGN(AppListPrefs); |
95 }; | 95 }; |
96 | 96 |
97 } // namespace app_list | 97 } // namespace app_list |
98 | 98 |
99 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_PREFS_H_ | 99 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_PREFS_H_ |
OLD | NEW |