| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_PREFS_H_ | |
| 6 #define CHROME_BROWSER_UI_APP_LIST_APP_LIST_PREFS_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <set> | |
| 10 #include <string> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "base/macros.h" | |
| 14 #include "base/observer_list.h" | |
| 15 #include "base/values.h" | |
| 16 #include "components/keyed_service/core/keyed_service.h" | |
| 17 #include "components/sync/model/string_ordinal.h" | |
| 18 | |
| 19 class PrefService; | |
| 20 | |
| 21 namespace content { | |
| 22 class BrowserContext; | |
| 23 } | |
| 24 | |
| 25 namespace user_prefs { | |
| 26 class PrefRegistrySyncable; | |
| 27 } | |
| 28 | |
| 29 namespace app_list { | |
| 30 | |
| 31 class AppListPrefs : public KeyedService { | |
| 32 public: | |
| 33 // An app list item's information. This is enough data to reconstruct the full | |
| 34 // hierarchy and ordering information of the app list. | |
| 35 struct AppListInfo { | |
| 36 enum ItemType { | |
| 37 ITEM_TYPE_INVALID = 0, | |
| 38 ITEM_TYPE_BEGIN, | |
| 39 APP_ITEM = ITEM_TYPE_BEGIN, | |
| 40 FOLDER_ITEM, | |
| 41 | |
| 42 // Do not change the order of this enum. | |
| 43 // When adding values, remember to update ITEM_TYPE_END. | |
| 44 ITEM_TYPE_END = FOLDER_ITEM, | |
| 45 }; | |
| 46 AppListInfo(); | |
| 47 AppListInfo(const AppListInfo& other); | |
| 48 ~AppListInfo(); | |
| 49 std::unique_ptr<base::DictionaryValue> CreateDictFromAppListInfo() const; | |
| 50 | |
| 51 static std::unique_ptr<AppListPrefs::AppListInfo> CreateAppListInfoFromDict( | |
| 52 const base::DictionaryValue* item_dict); | |
| 53 | |
| 54 // The id of the folder containing this item. | |
| 55 std::string parent_id; | |
| 56 | |
| 57 // The name of this item. | |
| 58 std::string name; | |
| 59 | |
| 60 // The position of this item in the app list. | |
| 61 syncer::StringOrdinal position; | |
| 62 | |
| 63 // The type of app list item being represented. | |
| 64 ItemType item_type; | |
| 65 }; | |
| 66 | |
| 67 typedef std::map<std::string, AppListInfo> AppListInfoMap; | |
| 68 | |
| 69 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | |
| 70 | |
| 71 static AppListPrefs* Get(content::BrowserContext* context); | |
| 72 | |
| 73 static AppListPrefs* Create(PrefService* pref_service); | |
| 74 | |
| 75 ~AppListPrefs() override; | |
| 76 | |
| 77 // Sets the app list info for |id|. | |
| 78 void SetAppListInfo(const std::string& id, const AppListInfo& info); | |
| 79 | |
| 80 // Gets the app list info for |id|. | |
| 81 std::unique_ptr<AppListInfo> GetAppListInfo(const std::string& id) const; | |
| 82 | |
| 83 // Gets a map of all AppListInfo objects in the prefs. | |
| 84 void GetAllAppListInfos(AppListInfoMap* out) const; | |
| 85 | |
| 86 // Deletes the app list info for |id|. | |
| 87 void DeleteAppListInfo(const std::string& id); | |
| 88 | |
| 89 private: | |
| 90 explicit AppListPrefs(PrefService* pref_service); | |
| 91 | |
| 92 PrefService* pref_service_; | |
| 93 | |
| 94 DISALLOW_COPY_AND_ASSIGN(AppListPrefs); | |
| 95 }; | |
| 96 | |
| 97 } // namespace app_list | |
| 98 | |
| 99 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_PREFS_H_ | |
| OLD | NEW |