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

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

Issue 1251323003: Cleanup: give ChromeAppSorting a BrowserContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 5 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 ExtensionSyncService;
19 class PrefService; 18 class PrefService;
20 19
21 namespace extensions { 20 namespace extensions {
22 21
23 class ExtensionScopedPrefs; 22 class ExtensionScopedPrefs;
24 23
25 class ChromeAppSorting : public AppSorting { 24 class ChromeAppSorting : public AppSorting {
26 public: 25 public:
27 ChromeAppSorting(); 26 explicit ChromeAppSorting(content::BrowserContext* browser_context);
28 ~ChromeAppSorting() override; 27 ~ChromeAppSorting() override;
29 28
30 // AppSorting implementation: 29 // AppSorting implementation:
31 void SetExtensionScopedPrefs(ExtensionScopedPrefs* prefs) override; 30 void SetExtensionScopedPrefs(ExtensionScopedPrefs* prefs) override;
32 void CheckExtensionScopedPrefs() const override; 31 void CheckExtensionScopedPrefs() const override;
33 void SetExtensionSyncService(
34 ExtensionSyncService* extension_sync_service) override;
35 void Initialize(const extensions::ExtensionIdList& extension_ids) override; 32 void Initialize(const extensions::ExtensionIdList& extension_ids) override;
36 void FixNTPOrdinalCollisions() override; 33 void FixNTPOrdinalCollisions() override;
37 void EnsureValidOrdinals( 34 void EnsureValidOrdinals(
38 const std::string& extension_id, 35 const std::string& extension_id,
39 const syncer::StringOrdinal& suggested_page) override; 36 const syncer::StringOrdinal& suggested_page) override;
40 void OnExtensionMoved(const std::string& moved_extension_id, 37 void OnExtensionMoved(const std::string& moved_extension_id,
41 const std::string& predecessor_extension_id, 38 const std::string& predecessor_extension_id,
42 const std::string& successor_extension_id) override; 39 const std::string& successor_extension_id) override;
43 syncer::StringOrdinal GetAppLaunchOrdinal( 40 syncer::StringOrdinal GetAppLaunchOrdinal(
44 const std::string& extension_id) const override; 41 const std::string& extension_id) const override;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // by |page_ordinal|. Otherwise, returns an ordinal after |app_launch_ordinal| 146 // by |page_ordinal|. Otherwise, returns an ordinal after |app_launch_ordinal|
150 // that has no conflict. 147 // that has no conflict.
151 syncer::StringOrdinal ResolveCollision( 148 syncer::StringOrdinal ResolveCollision(
152 const syncer::StringOrdinal& page_ordinal, 149 const syncer::StringOrdinal& page_ordinal,
153 const syncer::StringOrdinal& app_launch_ordinal) const; 150 const syncer::StringOrdinal& app_launch_ordinal) const;
154 151
155 // Returns the number of items in |m| visible on the new tab page. 152 // Returns the number of items in |m| visible on the new tab page.
156 size_t CountItemsVisibleOnNtp(const AppLaunchOrdinalMap& m) const; 153 size_t CountItemsVisibleOnNtp(const AppLaunchOrdinalMap& m) const;
157 154
158 ExtensionScopedPrefs* extension_scoped_prefs_; // Weak, owns this instance. 155 ExtensionScopedPrefs* extension_scoped_prefs_; // Weak, owns this instance.
159 ExtensionSyncService* extension_sync_service_; // Weak. 156 content::BrowserContext* browser_context_;
160 157
161 // A map of all the StringOrdinal page ordinals mapping to the collections of 158 // A map of all the StringOrdinal page ordinals mapping to the collections of
162 // app launch ordinals that exist on that page. This is used for mapping 159 // app launch ordinals that exist on that page. This is used for mapping
163 // StringOrdinals to their Integer equivalent as well as quick lookup of the 160 // StringOrdinals to their Integer equivalent as well as quick lookup of the
164 // any collision of on the NTP (icons with the same page and same app launch 161 // any collision of on the NTP (icons with the same page and same app launch
165 // ordinals). The possiblity of collisions means that a multimap must be used 162 // ordinals). The possiblity of collisions means that a multimap must be used
166 // (although the collisions must all be resolved once all the syncing is 163 // (although the collisions must all be resolved once all the syncing is
167 // done). 164 // done).
168 PageOrdinalMap ntp_ordinal_map_; 165 PageOrdinalMap ntp_ordinal_map_;
169 166
170 // Defines the default ordinals. 167 // Defines the default ordinals.
171 AppOrdinalsMap default_ordinals_; 168 AppOrdinalsMap default_ordinals_;
172 169
173 // Used to construct the default ordinals once when needed instead of on 170 // Used to construct the default ordinals once when needed instead of on
174 // construction when the app order may not have been determined. 171 // construction when the app order may not have been determined.
175 bool default_ordinals_created_; 172 bool default_ordinals_created_;
176 173
177 // The set of extensions that don't appear in the new tab page. 174 // The set of extensions that don't appear in the new tab page.
178 std::set<std::string> ntp_hidden_extensions_; 175 std::set<std::string> ntp_hidden_extensions_;
179 176
180 DISALLOW_COPY_AND_ASSIGN(ChromeAppSorting); 177 DISALLOW_COPY_AND_ASSIGN(ChromeAppSorting);
181 }; 178 };
182 179
183 } // namespace extensions 180 } // namespace extensions
184 181
185 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_APP_SORTING_H_ 182 #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