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

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

Issue 1254363004: Move ownership of AppSorting from ExtensionPrefs to ExtensionSystem (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add missing include Created 5 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/extensions/chrome_app_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_CHROME_APP_SORTING_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_CHROME_APP_SORTING_H_
6 #define CHROME_BROWSER_EXTENSIONS_CHROME_APP_SORTING_H_ 6 #define CHROME_BROWSER_EXTENSIONS_CHROME_APP_SORTING_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "extensions/browser/app_sorting.h" 13 #include "extensions/browser/app_sorting.h"
14 #include "extensions/browser/extension_prefs.h" 14 #include "extensions/browser/extension_prefs.h"
15 #include "extensions/common/extension.h" 15 #include "extensions/common/extension.h"
16 #include "sync/api/string_ordinal.h" 16 #include "sync/api/string_ordinal.h"
17 17
18 class PrefService; 18 class PrefService;
19 19
20 namespace extensions { 20 namespace extensions {
21 21
22 class ExtensionScopedPrefs; 22 class ExtensionScopedPrefs;
23 23
24 class ChromeAppSorting : public AppSorting { 24 class ChromeAppSorting : public AppSorting {
25 public: 25 public:
26 explicit ChromeAppSorting(content::BrowserContext* browser_context); 26 explicit ChromeAppSorting(content::BrowserContext* browser_context);
27 ~ChromeAppSorting() override; 27 ~ChromeAppSorting() override;
28 28
29 // AppSorting implementation: 29 // AppSorting implementation:
30 void SetExtensionScopedPrefs(ExtensionScopedPrefs* prefs) override;
31 void CheckExtensionScopedPrefs() const override;
32 void Initialize(const extensions::ExtensionIdList& extension_ids) override;
33 void FixNTPOrdinalCollisions() override; 30 void FixNTPOrdinalCollisions() override;
34 void EnsureValidOrdinals( 31 void EnsureValidOrdinals(
35 const std::string& extension_id, 32 const std::string& extension_id,
36 const syncer::StringOrdinal& suggested_page) override; 33 const syncer::StringOrdinal& suggested_page) override;
37 void OnExtensionMoved(const std::string& moved_extension_id, 34 void OnExtensionMoved(const std::string& moved_extension_id,
38 const std::string& predecessor_extension_id, 35 const std::string& predecessor_extension_id,
39 const std::string& successor_extension_id) override; 36 const std::string& successor_extension_id) override;
40 syncer::StringOrdinal GetAppLaunchOrdinal( 37 syncer::StringOrdinal GetAppLaunchOrdinal(
41 const std::string& extension_id) const override; 38 const std::string& extension_id) const override;
42 void SetAppLaunchOrdinal( 39 void SetAppLaunchOrdinal(
(...skipping 24 matching lines...) Expand all
67 syncer::StringOrdinal::LessThanFn> AppLaunchOrdinalMap; 64 syncer::StringOrdinal::LessThanFn> AppLaunchOrdinalMap;
68 // The StringOrdinal is the page ordinal and the AppLaunchOrdinalMap is the 65 // The StringOrdinal is the page ordinal and the AppLaunchOrdinalMap is the
69 // contents of that page. 66 // contents of that page.
70 typedef std::map< 67 typedef std::map<
71 syncer::StringOrdinal, AppLaunchOrdinalMap, 68 syncer::StringOrdinal, AppLaunchOrdinalMap,
72 syncer::StringOrdinal::LessThanFn> PageOrdinalMap; 69 syncer::StringOrdinal::LessThanFn> PageOrdinalMap;
73 70
74 // Unit tests. 71 // Unit tests.
75 friend class ChromeAppSortingDefaultOrdinalsBase; 72 friend class ChromeAppSortingDefaultOrdinalsBase;
76 friend class ChromeAppSortingGetMinOrMaxAppLaunchOrdinalsOnPage; 73 friend class ChromeAppSortingGetMinOrMaxAppLaunchOrdinalsOnPage;
74 friend class ChromeAppSortingInitialize;
77 friend class ChromeAppSortingInitializeWithNoApps; 75 friend class ChromeAppSortingInitializeWithNoApps;
78 friend class ChromeAppSortingPageOrdinalMapping; 76 friend class ChromeAppSortingPageOrdinalMapping;
79 friend class ChromeAppSortingSetExtensionVisible; 77 friend class ChromeAppSortingSetExtensionVisible;
80 78
81 // An enum used by GetMinOrMaxAppLaunchOrdinalsOnPage to specify which 79 // An enum used by GetMinOrMaxAppLaunchOrdinalsOnPage to specify which
82 // value should be returned. 80 // value should be returned.
83 enum AppLaunchOrdinalReturn {MIN_ORDINAL, MAX_ORDINAL}; 81 enum AppLaunchOrdinalReturn {MIN_ORDINAL, MAX_ORDINAL};
84 82
85 // Maps an app id to its ordinals. 83 // Maps an app id to its ordinals.
86 struct AppOrdinals { 84 struct AppOrdinals {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // Returns |app_launch_ordinal| if it has no collision in the page specified 143 // Returns |app_launch_ordinal| if it has no collision in the page specified
146 // by |page_ordinal|. Otherwise, returns an ordinal after |app_launch_ordinal| 144 // by |page_ordinal|. Otherwise, returns an ordinal after |app_launch_ordinal|
147 // that has no conflict. 145 // that has no conflict.
148 syncer::StringOrdinal ResolveCollision( 146 syncer::StringOrdinal ResolveCollision(
149 const syncer::StringOrdinal& page_ordinal, 147 const syncer::StringOrdinal& page_ordinal,
150 const syncer::StringOrdinal& app_launch_ordinal) const; 148 const syncer::StringOrdinal& app_launch_ordinal) const;
151 149
152 // Returns the number of items in |m| visible on the new tab page. 150 // Returns the number of items in |m| visible on the new tab page.
153 size_t CountItemsVisibleOnNtp(const AppLaunchOrdinalMap& m) const; 151 size_t CountItemsVisibleOnNtp(const AppLaunchOrdinalMap& m) const;
154 152
155 ExtensionScopedPrefs* extension_scoped_prefs_; // Weak, owns this instance.
156 content::BrowserContext* browser_context_; 153 content::BrowserContext* browser_context_;
157 154
158 // A map of all the StringOrdinal page ordinals mapping to the collections of 155 // A map of all the StringOrdinal page ordinals mapping to the collections of
159 // app launch ordinals that exist on that page. This is used for mapping 156 // app launch ordinals that exist on that page. This is used for mapping
160 // StringOrdinals to their Integer equivalent as well as quick lookup of the 157 // StringOrdinals to their Integer equivalent as well as quick lookup of the
161 // any collision of on the NTP (icons with the same page and same app launch 158 // any collision of on the NTP (icons with the same page and same app launch
162 // ordinals). The possiblity of collisions means that a multimap must be used 159 // ordinals). The possiblity of collisions means that a multimap must be used
163 // (although the collisions must all be resolved once all the syncing is 160 // (although the collisions must all be resolved once all the syncing is
164 // done). 161 // done).
165 PageOrdinalMap ntp_ordinal_map_; 162 PageOrdinalMap ntp_ordinal_map_;
166 163
167 // Defines the default ordinals. 164 // Defines the default ordinals.
168 AppOrdinalsMap default_ordinals_; 165 AppOrdinalsMap default_ordinals_;
169 166
170 // Used to construct the default ordinals once when needed instead of on 167 // Used to construct the default ordinals once when needed instead of on
171 // construction when the app order may not have been determined. 168 // construction when the app order may not have been determined.
172 bool default_ordinals_created_; 169 bool default_ordinals_created_;
173 170
174 // The set of extensions that don't appear in the new tab page. 171 // The set of extensions that don't appear in the new tab page.
175 std::set<std::string> ntp_hidden_extensions_; 172 std::set<std::string> ntp_hidden_extensions_;
176 173
177 DISALLOW_COPY_AND_ASSIGN(ChromeAppSorting); 174 DISALLOW_COPY_AND_ASSIGN(ChromeAppSorting);
178 }; 175 };
179 176
180 } // namespace extensions 177 } // namespace extensions
181 178
182 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_APP_SORTING_H_ 179 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_APP_SORTING_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/chrome_app_sorting.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698