Chromium Code Reviews| 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 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | |
| 9 #include <string> | 10 #include <string> |
| 10 | 11 |
| 11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 12 #include "chrome/browser/extensions/extension_prefs.h" | 13 #include "chrome/browser/extensions/extension_prefs.h" |
| 13 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
| 14 #include "sync/api/string_ordinal.h" | 15 #include "sync/api/string_ordinal.h" |
| 15 | 16 |
| 16 class ExtensionScopedPrefs; | 17 class ExtensionScopedPrefs; |
| 17 class ExtensionServiceInterface; | 18 class ExtensionServiceInterface; |
| 18 class PrefService; | 19 class PrefService; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 | 95 |
| 95 // Convert the page StringOrdinal value to its integer equivalent. This takes | 96 // Convert the page StringOrdinal value to its integer equivalent. This takes |
| 96 // O(# of apps) worst-case. | 97 // O(# of apps) worst-case. |
| 97 int PageStringOrdinalAsInteger( | 98 int PageStringOrdinalAsInteger( |
| 98 const syncer::StringOrdinal& page_ordinal) const; | 99 const syncer::StringOrdinal& page_ordinal) const; |
| 99 | 100 |
| 100 // Converts the page index integer to its StringOrdinal equivalent. This takes | 101 // Converts the page index integer to its StringOrdinal equivalent. This takes |
| 101 // O(# of apps) worst-case. | 102 // O(# of apps) worst-case. |
| 102 syncer::StringOrdinal PageIntegerAsStringOrdinal(size_t page_index); | 103 syncer::StringOrdinal PageIntegerAsStringOrdinal(size_t page_index); |
| 103 | 104 |
| 105 // Hidden extensions don't appear in the new tab page. | |
| 106 void MarkExtensionAsHidden(const std::string& extension_id); | |
|
tapted
2013/02/26 03:38:49
I think the member names need to mention NTP, or t
koz (OOO until 15th September)
2013/02/26 03:58:37
Yep, good point. Done.
| |
| 107 | |
| 104 private: | 108 private: |
| 105 // Unit tests. | 109 // Unit tests. |
| 106 friend class ExtensionSortingDefaultOrdinalsBase; | 110 friend class ExtensionSortingDefaultOrdinalsBase; |
| 107 friend class ExtensionSortingGetMinOrMaxAppLaunchOrdinalsOnPage; | 111 friend class ExtensionSortingGetMinOrMaxAppLaunchOrdinalsOnPage; |
| 108 friend class ExtensionSortingInitializeWithNoApps; | 112 friend class ExtensionSortingInitializeWithNoApps; |
| 109 friend class ExtensionSortingPageOrdinalMapping; | 113 friend class ExtensionSortingPageOrdinalMapping; |
| 110 | 114 |
| 111 // An enum used by GetMinOrMaxAppLaunchOrdinalsOnPage to specify which | 115 // An enum used by GetMinOrMaxAppLaunchOrdinalsOnPage to specify which |
| 112 // value should be returned. | 116 // value should be returned. |
| 113 enum AppLaunchOrdinalReturn {MIN_ORDINAL, MAX_ORDINAL}; | 117 enum AppLaunchOrdinalReturn {MIN_ORDINAL, MAX_ORDINAL}; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 syncer::StringOrdinal* page_ordinal, | 176 syncer::StringOrdinal* page_ordinal, |
| 173 syncer::StringOrdinal* app_launch_ordinal) const; | 177 syncer::StringOrdinal* app_launch_ordinal) const; |
| 174 | 178 |
| 175 // Returns |app_launch_ordinal| if it has no collision in the page specified | 179 // Returns |app_launch_ordinal| if it has no collision in the page specified |
| 176 // by |page_ordinal|. Otherwise, returns an ordinal after |app_launch_ordinal| | 180 // by |page_ordinal|. Otherwise, returns an ordinal after |app_launch_ordinal| |
| 177 // that has no conflict. | 181 // that has no conflict. |
| 178 syncer::StringOrdinal ResolveCollision( | 182 syncer::StringOrdinal ResolveCollision( |
| 179 const syncer::StringOrdinal& page_ordinal, | 183 const syncer::StringOrdinal& page_ordinal, |
| 180 const syncer::StringOrdinal& app_launch_ordinal) const; | 184 const syncer::StringOrdinal& app_launch_ordinal) const; |
| 181 | 185 |
| 186 // Returns the number of non hidden items in |m|. | |
|
tapted
2013/02/26 03:38:49
ubernit: "non" -> "non-"
koz (OOO until 15th September)
2013/02/26 03:58:37
hahaha ubernit. I love it! Fixed :-)
| |
| 187 size_t CountNonHiddenItems(const AppLaunchOrdinalMap& m) const; | |
| 188 | |
| 182 ExtensionScopedPrefs* extension_scoped_prefs_; // Weak, owns this instance. | 189 ExtensionScopedPrefs* extension_scoped_prefs_; // Weak, owns this instance. |
| 183 PrefService* pref_service_; // Weak. | 190 PrefService* pref_service_; // Weak. |
| 184 ExtensionServiceInterface* extension_service_; // Weak. | 191 ExtensionServiceInterface* extension_service_; // Weak. |
| 185 | 192 |
| 186 // A map of all the StringOrdinal page ordinals mapping to the collections of | 193 // A map of all the StringOrdinal page ordinals mapping to the collections of |
| 187 // app launch ordinals that exist on that page. This is used for mapping | 194 // app launch ordinals that exist on that page. This is used for mapping |
| 188 // StringOrdinals to their Integer equivalent as well as quick lookup of the | 195 // StringOrdinals to their Integer equivalent as well as quick lookup of the |
| 189 // any collision of on the NTP (icons with the same page and same app launch | 196 // any collision of on the NTP (icons with the same page and same app launch |
| 190 // ordinals). The possiblity of collisions means that a multimap must be used | 197 // ordinals). The possiblity of collisions means that a multimap must be used |
| 191 // (although the collisions must all be resolved once all the syncing is | 198 // (although the collisions must all be resolved once all the syncing is |
| 192 // done). | 199 // done). |
| 193 // The StringOrdinal is the app launch ordinal and the string is the extension | 200 // The StringOrdinal is the app launch ordinal and the string is the extension |
| 194 // id. | 201 // id. |
| 195 typedef std::multimap< | 202 typedef std::multimap< |
| 196 syncer::StringOrdinal, std::string, | 203 syncer::StringOrdinal, std::string, |
| 197 syncer::StringOrdinal::LessThanFn> AppLaunchOrdinalMap; | 204 syncer::StringOrdinal::LessThanFn> AppLaunchOrdinalMap; |
| 198 // The StringOrdinal is the page ordinal and the AppLaunchOrdinalMap is the | 205 // The StringOrdinal is the page ordinal and the AppLaunchOrdinalMap is the |
| 199 // contents of that page. | 206 // contents of that page. |
| 200 typedef std::map< | 207 typedef std::map< |
| 201 syncer::StringOrdinal, AppLaunchOrdinalMap, | 208 syncer::StringOrdinal, AppLaunchOrdinalMap, |
| 202 syncer::StringOrdinal::LessThanFn> PageOrdinalMap; | 209 syncer::StringOrdinal::LessThanFn> PageOrdinalMap; |
| 203 PageOrdinalMap ntp_ordinal_map_; | 210 PageOrdinalMap ntp_ordinal_map_; |
| 204 | 211 |
| 205 // Defines the default ordinals. | 212 // Defines the default ordinals. |
| 206 AppOrdinalsMap default_ordinals_; | 213 AppOrdinalsMap default_ordinals_; |
| 207 | 214 |
| 215 // The set of extensions that don't appear in the new tab page. | |
| 216 std::set<std::string> hidden_extensions_; | |
| 217 | |
| 208 DISALLOW_COPY_AND_ASSIGN(ExtensionSorting); | 218 DISALLOW_COPY_AND_ASSIGN(ExtensionSorting); |
| 209 }; | 219 }; |
| 210 | 220 |
| 211 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SORTING_H_ | 221 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SORTING_H_ |
| OLD | NEW |