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.
5 #ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_PREFS_H_
6 #define CHROME_BROWSER_UI_APP_LIST_APP_LIST_PREFS_H_
12 #include "base/basictypes.h"
13 #include "base/observer_list.h"
14 #include "base/values.h"
15 #include "components/keyed_service/core/keyed_service.h"
16 #include "sync/api/string_ordinal.h"
24 namespace user_prefs
{
25 class PrefRegistrySyncable
;
30 class AppListPrefs
: public KeyedService
{
32 // An app list item's information. This is enough data to reconstruct the full
33 // hierarchy and ordering information of the app list.
36 ITEM_TYPE_INVALID
= 0,
38 APP_ITEM
= ITEM_TYPE_BEGIN
,
41 // Do not change the order of this enum.
42 // When adding values, remember to update ITEM_TYPE_END.
43 ITEM_TYPE_END
= FOLDER_ITEM
,
47 scoped_ptr
<base::DictionaryValue
> CreateDictFromAppListInfo() const;
49 static scoped_ptr
<AppListPrefs::AppListInfo
> CreateAppListInfoFromDict(
50 const base::DictionaryValue
* item_dict
);
52 // The id of the folder containing this item.
53 std::string parent_id
;
55 // The name of this item.
58 // The position of this item in the app list.
59 syncer::StringOrdinal position
;
61 // The type of app list item being represented.
65 typedef std::map
<std::string
, AppListInfo
> AppListInfoMap
;
67 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable
* registry
);
69 static AppListPrefs
* Get(content::BrowserContext
* context
);
71 static AppListPrefs
* Create(PrefService
* pref_service
);
73 ~AppListPrefs() override
;
75 // Sets the app list info for |id|.
76 void SetAppListInfo(const std::string
& id
, const AppListInfo
& info
);
78 // Gets the app list info for |id|.
79 scoped_ptr
<AppListInfo
> GetAppListInfo(const std::string
& id
) const;
81 // Gets a map of all AppListInfo objects in the prefs.
82 void GetAllAppListInfos(AppListInfoMap
* out
) const;
84 // Deletes the app list info for |id|.
85 void DeleteAppListInfo(const std::string
& id
);
88 explicit AppListPrefs(PrefService
* pref_service
);
90 PrefService
* pref_service_
;
92 DISALLOW_COPY_AND_ASSIGN(AppListPrefs
);
95 } // namespace app_list
97 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_PREFS_H_