| 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 #pragma once | 7 #pragma once | 
| 8 | 8 | 
| 9 #include <string> | 9 #include <string> | 
| 10 | 10 | 
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" | 
| 12 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" | 
| 13 #include "chrome/browser/extensions/extension_prefs.h" | 13 #include "chrome/browser/extensions/extension_prefs.h" | 
| 14 #include "chrome/common/string_ordinal.h" | 14 #include "chrome/common/string_ordinal.h" | 
| 15 | 15 | 
| 16 class ExtensionScopedPrefs; | 16 class ExtensionScopedPrefs; | 
|  | 17 class ExtensionServiceInterface; | 
| 17 | 18 | 
| 18 class ExtensionSorting { | 19 class ExtensionSorting { | 
| 19  public: | 20  public: | 
| 20   explicit ExtensionSorting(ExtensionScopedPrefs* extension_scoped_prefs, | 21   explicit ExtensionSorting(ExtensionScopedPrefs* extension_scoped_prefs, | 
| 21                             PrefService* pref_service); | 22                             PrefService* pref_service); | 
| 22   ~ExtensionSorting(); | 23   ~ExtensionSorting(); | 
| 23 | 24 | 
|  | 25   // Set up the ExtensionService to inform of changes that require syncing. | 
|  | 26   void SetExtensionService(ExtensionServiceInterface* extension_service); | 
|  | 27 | 
| 24   // Properly initialize ExtensionSorting internal values that require | 28   // Properly initialize ExtensionSorting internal values that require | 
| 25   // |extension_ids|. | 29   // |extension_ids|. | 
| 26   void Initialize(const ExtensionPrefs::ExtensionIdSet& extension_ids); | 30   void Initialize(const ExtensionPrefs::ExtensionIdSet& extension_ids); | 
| 27 | 31 | 
| 28   // Resolves any conflicts the might be created as a result of syncing that | 32   // Resolves any conflicts the might be created as a result of syncing that | 
| 29   // results in two icons having the same page and app launch ordinal. After | 33   // results in two icons having the same page and app launch ordinal. After | 
| 30   // this is called it is guaranteed that there are no collisions of NTP icons. | 34   // this is called it is guaranteed that there are no collisions of NTP icons. | 
| 31   void FixNTPOrdinalCollisions(); | 35   void FixNTPOrdinalCollisions(); | 
| 32 | 36 | 
| 33   // This ensures that the extension has valid ordinals, and if it doesn't then | 37   // This ensures that the extension has valid ordinals, and if it doesn't then | 
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 126                          const StringOrdinal& app_launch_ordinal); | 130                          const StringOrdinal& app_launch_ordinal); | 
| 127 | 131 | 
| 128   // Removes the mapping for |extension_id| with a page ordinal of | 132   // Removes the mapping for |extension_id| with a page ordinal of | 
| 129   // |page_ordinal| and a app launch ordinal of |app_launch_ordinal|. If there | 133   // |page_ordinal| and a app launch ordinal of |app_launch_ordinal|. If there | 
| 130   // is not matching map, nothing happens. This works with valid and invalid | 134   // is not matching map, nothing happens. This works with valid and invalid | 
| 131   // StringOrdinals. | 135   // StringOrdinals. | 
| 132   void RemoveOrdinalMapping(const std::string& extension_id, | 136   void RemoveOrdinalMapping(const std::string& extension_id, | 
| 133                             const StringOrdinal& page_ordinal, | 137                             const StringOrdinal& page_ordinal, | 
| 134                             const StringOrdinal& app_launch_ordinal); | 138                             const StringOrdinal& app_launch_ordinal); | 
| 135 | 139 | 
|  | 140   // Syncs the extension if needed. It is an error to call this if the | 
|  | 141   // extension is not an application. | 
|  | 142   void SyncIfNeeded(const std::string& extension_id); | 
|  | 143 | 
| 136   ExtensionScopedPrefs* extension_scoped_prefs_;  // Weak, owns this instance. | 144   ExtensionScopedPrefs* extension_scoped_prefs_;  // Weak, owns this instance. | 
| 137   PrefService* pref_service_;  // Weak. | 145   PrefService* pref_service_;  // Weak. | 
|  | 146   ExtensionServiceInterface* extension_service_;  // Weak. | 
| 138 | 147 | 
| 139   // A map of all the StringOrdinal page ordinals mapping to the collections of | 148   // A map of all the StringOrdinal page ordinals mapping to the collections of | 
| 140   // app launch ordinals that exist on that page. This is used for mapping | 149   // app launch ordinals that exist on that page. This is used for mapping | 
| 141   // StringOrdinals to their Integer equivalent as well as quick lookup of the | 150   // StringOrdinals to their Integer equivalent as well as quick lookup of the | 
| 142   // any collision of on the NTP (icons with the same page and same app launch | 151   // any collision of on the NTP (icons with the same page and same app launch | 
| 143   // ordinals). The possiblity of collisions means that a multimap must be used | 152   // ordinals). The possiblity of collisions means that a multimap must be used | 
| 144   // (although the collisions must all be resolved once all the syncing is | 153   // (although the collisions must all be resolved once all the syncing is | 
| 145   // done). | 154   // done). | 
| 146   // The StringOrdinal is the app launch ordinal and the string is the extension | 155   // The StringOrdinal is the app launch ordinal and the string is the extension | 
| 147   // id. | 156   // id. | 
| 148   typedef std::multimap< | 157   typedef std::multimap< | 
| 149       StringOrdinal, std::string, StringOrdinalLessThan> AppLaunchOrdinalMap; | 158       StringOrdinal, std::string, StringOrdinalLessThan> AppLaunchOrdinalMap; | 
| 150   // The StringOrdinal is the page ordinal and the AppLaunchOrdinalMap is the | 159   // The StringOrdinal is the page ordinal and the AppLaunchOrdinalMap is the | 
| 151   // contents of that page. | 160   // contents of that page. | 
| 152   typedef std::map< | 161   typedef std::map< | 
| 153       StringOrdinal, AppLaunchOrdinalMap, StringOrdinalLessThan> PageOrdinalMap; | 162       StringOrdinal, AppLaunchOrdinalMap, StringOrdinalLessThan> PageOrdinalMap; | 
| 154   PageOrdinalMap ntp_ordinal_map_; | 163   PageOrdinalMap ntp_ordinal_map_; | 
| 155 | 164 | 
| 156   DISALLOW_COPY_AND_ASSIGN(ExtensionSorting); | 165   DISALLOW_COPY_AND_ASSIGN(ExtensionSorting); | 
| 157 }; | 166 }; | 
| 158 | 167 | 
| 159 #endif  // CHROME_BROWSER_EXTENSIONS_EXTENSION_SORTING_H_ | 168 #endif  // CHROME_BROWSER_EXTENSIONS_EXTENSION_SORTING_H_ | 
| OLD | NEW | 
|---|