Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(496)

Side by Side Diff: chrome/browser/extensions/extension_sorting.h

Issue 16032004: Call CreateDefaultOrdinals() when needed, instead of on construction (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comment Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <set>
10 #include <string> 10 #include <string>
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 void SyncIfNeeded(const std::string& extension_id); 178 void SyncIfNeeded(const std::string& extension_id);
179 179
180 // Creates the default ordinals. 180 // Creates the default ordinals.
181 void CreateDefaultOrdinals(); 181 void CreateDefaultOrdinals();
182 182
183 // Gets the default ordinals for |extension_id|. Returns false if no default 183 // Gets the default ordinals for |extension_id|. Returns false if no default
184 // ordinals for |extension_id| is defined. Otherwise, returns true and 184 // ordinals for |extension_id| is defined. Otherwise, returns true and
185 // ordinals is updated with corresponding ordinals. 185 // ordinals is updated with corresponding ordinals.
186 bool GetDefaultOrdinals(const std::string& extension_id, 186 bool GetDefaultOrdinals(const std::string& extension_id,
187 syncer::StringOrdinal* page_ordinal, 187 syncer::StringOrdinal* page_ordinal,
188 syncer::StringOrdinal* app_launch_ordinal) const; 188 syncer::StringOrdinal* app_launch_ordinal);
189 189
190 // Returns |app_launch_ordinal| if it has no collision in the page specified 190 // Returns |app_launch_ordinal| if it has no collision in the page specified
191 // by |page_ordinal|. Otherwise, returns an ordinal after |app_launch_ordinal| 191 // by |page_ordinal|. Otherwise, returns an ordinal after |app_launch_ordinal|
192 // that has no conflict. 192 // that has no conflict.
193 syncer::StringOrdinal ResolveCollision( 193 syncer::StringOrdinal ResolveCollision(
194 const syncer::StringOrdinal& page_ordinal, 194 const syncer::StringOrdinal& page_ordinal,
195 const syncer::StringOrdinal& app_launch_ordinal) const; 195 const syncer::StringOrdinal& app_launch_ordinal) const;
196 196
197 // Returns the number of items in |m| visible on the new tab page. 197 // Returns the number of items in |m| visible on the new tab page.
198 size_t CountItemsVisibleOnNtp(const AppLaunchOrdinalMap& m) const; 198 size_t CountItemsVisibleOnNtp(const AppLaunchOrdinalMap& m) const;
199 199
200 ExtensionScopedPrefs* extension_scoped_prefs_; // Weak, owns this instance. 200 ExtensionScopedPrefs* extension_scoped_prefs_; // Weak, owns this instance.
201 PrefService* pref_service_; // Weak. 201 PrefService* pref_service_; // Weak.
202 ExtensionServiceInterface* extension_service_; // Weak. 202 ExtensionServiceInterface* extension_service_; // Weak.
203 203
204 // A map of all the StringOrdinal page ordinals mapping to the collections of 204 // A map of all the StringOrdinal page ordinals mapping to the collections of
205 // app launch ordinals that exist on that page. This is used for mapping 205 // app launch ordinals that exist on that page. This is used for mapping
206 // StringOrdinals to their Integer equivalent as well as quick lookup of the 206 // StringOrdinals to their Integer equivalent as well as quick lookup of the
207 // any collision of on the NTP (icons with the same page and same app launch 207 // any collision of on the NTP (icons with the same page and same app launch
208 // ordinals). The possiblity of collisions means that a multimap must be used 208 // ordinals). The possiblity of collisions means that a multimap must be used
209 // (although the collisions must all be resolved once all the syncing is 209 // (although the collisions must all be resolved once all the syncing is
210 // done). 210 // done).
211 PageOrdinalMap ntp_ordinal_map_; 211 PageOrdinalMap ntp_ordinal_map_;
212 212
213 // Defines the default ordinals. 213 // Defines the default ordinals.
214 AppOrdinalsMap default_ordinals_; 214 AppOrdinalsMap default_ordinals_;
215 215
216 // Used to construct the default ordinals once when needed instead of on
217 // construction when the app order may not have been determined.
218 bool default_ordinals_created_;
219
216 // The set of extensions that don't appear in the new tab page. 220 // The set of extensions that don't appear in the new tab page.
217 std::set<std::string> ntp_hidden_extensions_; 221 std::set<std::string> ntp_hidden_extensions_;
218 222
219 DISALLOW_COPY_AND_ASSIGN(ExtensionSorting); 223 DISALLOW_COPY_AND_ASSIGN(ExtensionSorting);
220 }; 224 };
221 225
222 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SORTING_H_ 226 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SORTING_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/default_app_order.cc ('k') | chrome/browser/extensions/extension_sorting.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698