OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_EXTENSIONS_EXTENSION_SORTING_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SORTING_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SORTING_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SORTING_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 11 matching lines...) Expand all Loading... |
22 public: | 22 public: |
23 ExtensionSorting(ExtensionScopedPrefs* extension_scoped_prefs, | 23 ExtensionSorting(ExtensionScopedPrefs* extension_scoped_prefs, |
24 PrefService* pref_service); | 24 PrefService* pref_service); |
25 ~ExtensionSorting(); | 25 ~ExtensionSorting(); |
26 | 26 |
27 // Set up the ExtensionService to inform of changes that require syncing. | 27 // Set up the ExtensionService to inform of changes that require syncing. |
28 void SetExtensionService(ExtensionServiceInterface* extension_service); | 28 void SetExtensionService(ExtensionServiceInterface* extension_service); |
29 | 29 |
30 // Properly initialize ExtensionSorting internal values that require | 30 // Properly initialize ExtensionSorting internal values that require |
31 // |extension_ids|. | 31 // |extension_ids|. |
32 void Initialize(const ExtensionPrefs::ExtensionIdSet& extension_ids); | 32 void Initialize( |
| 33 const extensions::ExtensionPrefs::ExtensionIdSet& extension_ids); |
33 | 34 |
34 // Resolves any conflicts the might be created as a result of syncing that | 35 // Resolves any conflicts the might be created as a result of syncing that |
35 // results in two icons having the same page and app launch ordinal. After | 36 // results in two icons having the same page and app launch ordinal. After |
36 // this is called it is guaranteed that there are no collisions of NTP icons. | 37 // this is called it is guaranteed that there are no collisions of NTP icons. |
37 void FixNTPOrdinalCollisions(); | 38 void FixNTPOrdinalCollisions(); |
38 | 39 |
39 // This ensures that the extension has valid ordinals, and if it doesn't then | 40 // This ensures that the extension has valid ordinals, and if it doesn't then |
40 // properly initialize them. | 41 // properly initialize them. |
41 void EnsureValidOrdinals(const std::string& extension_id); | 42 void EnsureValidOrdinals(const std::string& extension_id); |
42 | 43 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 // the largest ordinal on |page_ordinal|. If there are no apps on the page | 113 // the largest ordinal on |page_ordinal|. If there are no apps on the page |
113 // then an invalid StringOrdinal is returned. It is an error to call this | 114 // then an invalid StringOrdinal is returned. It is an error to call this |
114 // function with an invalid |page_ordinal|. | 115 // function with an invalid |page_ordinal|. |
115 StringOrdinal GetMinOrMaxAppLaunchOrdinalsOnPage( | 116 StringOrdinal GetMinOrMaxAppLaunchOrdinalsOnPage( |
116 const StringOrdinal& page_ordinal, | 117 const StringOrdinal& page_ordinal, |
117 AppLaunchOrdinalReturn return_type) const; | 118 AppLaunchOrdinalReturn return_type) const; |
118 | 119 |
119 // Initialize the |page_ordinal_map_| with the page ordinals used by the | 120 // Initialize the |page_ordinal_map_| with the page ordinals used by the |
120 // given extensions. | 121 // given extensions. |
121 void InitializePageOrdinalMap( | 122 void InitializePageOrdinalMap( |
122 const ExtensionPrefs::ExtensionIdSet& extension_ids); | 123 const extensions::ExtensionPrefs::ExtensionIdSet& extension_ids); |
123 | 124 |
124 // Migrates the app launcher and page index values. | 125 // Migrates the app launcher and page index values. |
125 void MigrateAppIndex(const ExtensionPrefs::ExtensionIdSet& extension_ids); | 126 void MigrateAppIndex( |
| 127 const extensions::ExtensionPrefs::ExtensionIdSet& extension_ids); |
126 | 128 |
127 // Called to add a new mapping value for |extension_id| with a page ordinal | 129 // Called to add a new mapping value for |extension_id| with a page ordinal |
128 // of |page_ordinal| and a app launch ordinal of |app_launch_ordinal|. This | 130 // of |page_ordinal| and a app launch ordinal of |app_launch_ordinal|. This |
129 // works with valid and invalid StringOrdinals. | 131 // works with valid and invalid StringOrdinals. |
130 void AddOrdinalMapping(const std::string& extension_id, | 132 void AddOrdinalMapping(const std::string& extension_id, |
131 const StringOrdinal& page_ordinal, | 133 const StringOrdinal& page_ordinal, |
132 const StringOrdinal& app_launch_ordinal); | 134 const StringOrdinal& app_launch_ordinal); |
133 | 135 |
134 // Ensures |ntp_ordinal_map_| is of |minimum_size| number of entries. | 136 // Ensures |ntp_ordinal_map_| is of |minimum_size| number of entries. |
135 void CreateOrdinalsIfNecessary(size_t minimum_size); | 137 void CreateOrdinalsIfNecessary(size_t minimum_size); |
(...skipping 28 matching lines...) Expand all Loading... |
164 // The StringOrdinal is the page ordinal and the AppLaunchOrdinalMap is the | 166 // The StringOrdinal is the page ordinal and the AppLaunchOrdinalMap is the |
165 // contents of that page. | 167 // contents of that page. |
166 typedef std::map< | 168 typedef std::map< |
167 StringOrdinal, AppLaunchOrdinalMap, StringOrdinalLessThan> PageOrdinalMap; | 169 StringOrdinal, AppLaunchOrdinalMap, StringOrdinalLessThan> PageOrdinalMap; |
168 PageOrdinalMap ntp_ordinal_map_; | 170 PageOrdinalMap ntp_ordinal_map_; |
169 | 171 |
170 DISALLOW_COPY_AND_ASSIGN(ExtensionSorting); | 172 DISALLOW_COPY_AND_ASSIGN(ExtensionSorting); |
171 }; | 173 }; |
172 | 174 |
173 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SORTING_H_ | 175 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SORTING_H_ |
OLD | NEW |