| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013 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_EXTENSIONS_APP_LIST_EXTENSION_ORDERING_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_APP_LIST_EXTENSION_ORDERING_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <set> |
| 10 |
| 11 #include "chrome/browser/extensions/extension_ordering.h" |
| 12 #include "sync/api/string_ordinal.h" |
| 13 |
| 14 // The ordering for apps on the app list. This ordering is represented by a |
| 15 // single ordinal |
| 16 class AppListExtensionOrdering : public ExtensionOrdering { |
| 17 public: |
| 18 explicit AppListExtensionOrdering( |
| 19 ExtensionScopedPrefs* extension_scoped_prefs); |
| 20 ~AppListExtensionOrdering(); |
| 21 |
| 22 // ExtensionOrdering implementation. |
| 23 virtual void Initialize( |
| 24 const extensions::ExtensionIdList& extension_ids) OVERRIDE; |
| 25 virtual void FixSyncCollisions() OVERRIDE; |
| 26 virtual void InsertAtFront(const std::string& extension_id) OVERRIDE; |
| 27 virtual void InsertAtBack(const std::string& extension_id) OVERRIDE; |
| 28 virtual void InsertAtNextAvailable(const std::string& extension_id) OVERRIDE; |
| 29 virtual void OnExtensionMoved( |
| 30 const std::string& moved_extension_id, |
| 31 const std::string& predecessor_extension_id, |
| 32 const std::string& successor_extension_id) OVERRIDE; |
| 33 virtual void Erase(const std::string& extension_id) OVERRIDE; |
| 34 virtual bool ExtensionPrecedes(const std::string& extension1, |
| 35 const std::string& extension2) OVERRIDE; |
| 36 |
| 37 syncer::StringOrdinal GetAppListOrdinal(const std::string& extension_id); |
| 38 // Sets the ordinal for the given |extension_id| as |ordinal|. This causes a |
| 39 // sync. |
| 40 void SetAppListOrdinal(const std::string& extension_id, |
| 41 const syncer::StringOrdinal& ordinal); |
| 42 private: |
| 43 typedef std::set<std::string> ExtensionIdSet; |
| 44 typedef std::map<syncer::StringOrdinal, ExtensionIdSet, |
| 45 syncer::StringOrdinal::LessThanFn> AppListOrdinalMap; |
| 46 |
| 47 void UpdatePrefs(const std::string& extension_id, |
| 48 const syncer::StringOrdinal& ordinal); |
| 49 |
| 50 AppListOrdinalMap app_list_ordinal_map_; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(AppListExtensionOrdering); |
| 53 }; |
| 54 |
| 55 #endif // CHROME_BROWSER_EXTENSIONS_APP_LIST_EXTENSION_ORDERING_H_ |
| OLD | NEW |