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

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

Issue 10068001: [NTP4] Fix empty apps page crash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: estade review Created 8 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_sorting.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 // Removes the ordinal values for an app. 87 // Removes the ordinal values for an app.
88 void ClearOrdinals(const std::string& extension_id); 88 void ClearOrdinals(const std::string& extension_id);
89 89
90 // Convert the page StringOrdinal value to its integer equivalent. This takes 90 // Convert the page StringOrdinal value to its integer equivalent. This takes
91 // O(# of apps) worst-case. 91 // O(# of apps) worst-case.
92 int PageStringOrdinalAsInteger(const StringOrdinal& page_ordinal) const; 92 int PageStringOrdinalAsInteger(const StringOrdinal& page_ordinal) const;
93 93
94 // Converts the page index integer to its StringOrdinal equivalent. This takes 94 // Converts the page index integer to its StringOrdinal equivalent. This takes
95 // O(# of apps) worst-case. 95 // O(# of apps) worst-case.
96 StringOrdinal PageIntegerAsStringOrdinal(size_t page_index) const; 96 StringOrdinal PageIntegerAsStringOrdinal(size_t page_index);
97 97
98 private: 98 private:
99 // Unit tests. 99 // Unit tests.
100 friend class ExtensionSortingGetMinOrMaxAppLaunchOrdinalsOnPage; 100 friend class ExtensionSortingGetMinOrMaxAppLaunchOrdinalsOnPage;
101 friend class ExtensionSortingInitializeWithNoApps; 101 friend class ExtensionSortingInitializeWithNoApps;
102 friend class ExtensionSortingPageOrdinalMapping; 102 friend class ExtensionSortingPageOrdinalMapping;
103 103
104 // An enum used by GetMinOrMaxAppLaunchOrdinalsOnPage to specify which 104 // An enum used by GetMinOrMaxAppLaunchOrdinalsOnPage to specify which
105 // value should be returned. 105 // value should be returned.
106 enum AppLaunchOrdinalReturn {MIN_ORDINAL, MAX_ORDINAL}; 106 enum AppLaunchOrdinalReturn {MIN_ORDINAL, MAX_ORDINAL};
(...skipping 15 matching lines...) Expand all
122 // Migrates the app launcher and page index values. 122 // Migrates the app launcher and page index values.
123 void MigrateAppIndex(const ExtensionPrefs::ExtensionIdSet& extension_ids); 123 void MigrateAppIndex(const ExtensionPrefs::ExtensionIdSet& extension_ids);
124 124
125 // Called to add a new mapping value for |extension_id| with a page ordinal 125 // Called to add a new mapping value for |extension_id| with a page ordinal
126 // of |page_ordinal| and a app launch ordinal of |app_launch_ordinal|. This 126 // of |page_ordinal| and a app launch ordinal of |app_launch_ordinal|. This
127 // works with valid and invalid StringOrdinals. 127 // works with valid and invalid StringOrdinals.
128 void AddOrdinalMapping(const std::string& extension_id, 128 void AddOrdinalMapping(const std::string& extension_id,
129 const StringOrdinal& page_ordinal, 129 const StringOrdinal& page_ordinal,
130 const StringOrdinal& app_launch_ordinal); 130 const StringOrdinal& app_launch_ordinal);
131 131
132 // Ensures |ntp_ordinal_map_| is of |minimum_size| number of entries.
133 void CreateOrdinalsIfNecessary(size_t minimum_size);
134
132 // Removes the mapping for |extension_id| with a page ordinal of 135 // Removes the mapping for |extension_id| with a page ordinal of
133 // |page_ordinal| and a app launch ordinal of |app_launch_ordinal|. If there 136 // |page_ordinal| and a app launch ordinal of |app_launch_ordinal|. If there
134 // is not matching map, nothing happens. This works with valid and invalid 137 // is not matching map, nothing happens. This works with valid and invalid
135 // StringOrdinals. 138 // StringOrdinals.
136 void RemoveOrdinalMapping(const std::string& extension_id, 139 void RemoveOrdinalMapping(const std::string& extension_id,
137 const StringOrdinal& page_ordinal, 140 const StringOrdinal& page_ordinal,
138 const StringOrdinal& app_launch_ordinal); 141 const StringOrdinal& app_launch_ordinal);
139 142
140 // Syncs the extension if needed. It is an error to call this if the 143 // Syncs the extension if needed. It is an error to call this if the
141 // extension is not an application. 144 // extension is not an application.
(...skipping 17 matching lines...) Expand all
159 // The StringOrdinal is the page ordinal and the AppLaunchOrdinalMap is the 162 // The StringOrdinal is the page ordinal and the AppLaunchOrdinalMap is the
160 // contents of that page. 163 // contents of that page.
161 typedef std::map< 164 typedef std::map<
162 StringOrdinal, AppLaunchOrdinalMap, StringOrdinalLessThan> PageOrdinalMap; 165 StringOrdinal, AppLaunchOrdinalMap, StringOrdinalLessThan> PageOrdinalMap;
163 PageOrdinalMap ntp_ordinal_map_; 166 PageOrdinalMap ntp_ordinal_map_;
164 167
165 DISALLOW_COPY_AND_ASSIGN(ExtensionSorting); 168 DISALLOW_COPY_AND_ASSIGN(ExtensionSorting);
166 }; 169 };
167 170
168 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SORTING_H_ 171 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SORTING_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_sorting.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698