| Index: chrome/browser/extensions/extension_prefs.h
|
| diff --git a/chrome/browser/extensions/extension_prefs.h b/chrome/browser/extensions/extension_prefs.h
|
| index d7760a76d98a7210d7a0aae4bbb75cdd10689c7c..08f29e7c1acbd5f5ba657f31db6be1b6b6a838a0 100644
|
| --- a/chrome/browser/extensions/extension_prefs.h
|
| +++ b/chrome/browser/extensions/extension_prefs.h
|
| @@ -16,6 +16,7 @@
|
| #include "chrome/browser/extensions/extension_prefs_scope.h"
|
| #include "chrome/browser/prefs/pref_service.h"
|
| #include "chrome/common/extensions/extension.h"
|
| +#include "chrome/common/string_ordinal.h"
|
| #include "googleurl/src/gurl.h"
|
|
|
| class ExtensionPrefValueMap;
|
| @@ -99,11 +100,12 @@ class ExtensionPrefs : public ExtensionContentSettingsStore::Observer {
|
| void SetToolbarOrder(const std::vector<std::string>& extension_ids);
|
|
|
| // Called when an extension is installed, so that prefs get created.
|
| - // If |page_index| is -1, and the then a page will be found for the App.
|
| + // If |page_index| is an invalid ordinal, then a page will be found
|
| + // for the App.
|
| void OnExtensionInstalled(const Extension* extension,
|
| Extension::State initial_state,
|
| bool from_webstore,
|
| - int page_index);
|
| + StringOrdinal page_index);
|
|
|
| // Called when an extension is uninstalled, so that prefs get cleaned up.
|
| void OnExtensionUninstalled(const std::string& extension_id,
|
| @@ -304,37 +306,53 @@ class ExtensionPrefs : public ExtensionContentSettingsStore::Observer {
|
| bool GetWebStoreLogin(std::string* result);
|
| void SetWebStoreLogin(const std::string& login);
|
|
|
| + // Get the first page index StringOrdinal value.
|
| + StringOrdinal GetFirstAppPage() const;
|
| +
|
| + // Create a StringOrdinal which will be the first element for the given page.
|
| + StringOrdinal CreateFirstAppLaunchIndex(const StringOrdinal& page_index)
|
| + const;
|
| +
|
| // Get the application launch index for an extension with |extension_id|. This
|
| // determines the order of which the applications appear on the New Tab Page.
|
| - // A value of 0 generally indicates top left. If the extension has no launch
|
| - // index a -1 value is returned.
|
| - int GetAppLaunchIndex(const std::string& extension_id);
|
| + // A value close to |A*| generally indicates top left. If the extension has no
|
| + // launch index an invalid StringOrdinal is returned.
|
| + StringOrdinal GetAppLaunchIndex(const std::string& extension_id) const;
|
|
|
| // Sets a specific launch index for an extension with |extension_id|.
|
| - void SetAppLaunchIndex(const std::string& extension_id, int index);
|
| + void SetAppLaunchIndex(const std::string& extension_id,
|
| + const StringOrdinal& index);
|
|
|
| - // Gets the next available application launch index. This is 1 higher than the
|
| + // Gets the next available application launch index. This is higher than the
|
| // highest current application launch index found for the page |on_page|.
|
| - int GetNextAppLaunchIndex(int on_page);
|
| + StringOrdinal GetNextAppLaunchIndex(const StringOrdinal& on_page) const;
|
|
|
| - // Gets the page a new app should install to. Starts on page 0, and if there
|
| - // are N or more apps on it, tries to install on the next page.
|
| - int GetNaturalAppPageIndex();
|
| + // Gets the page a new app should install to. Starts on the first page, and if
|
| + // there are N or more apps on it, tries to install on the next page.
|
| + StringOrdinal GetNaturalAppPageIndex() const;
|
|
|
| // Sets the order the apps should be displayed in the app launcher.
|
| - void SetAppLauncherOrder(const std::vector<std::string>& extension_ids);
|
| + void SetAppLauncherOrder(const std::vector<std::string>& extension_ids,
|
| + const std::string& moved_extension_id);
|
|
|
| // Get the application page index for an extension with |extension_id|. This
|
| // determines which page an app will appear on in page-based NTPs. If
|
| - // the app has no page specified, -1 is returned.
|
| - int GetPageIndex(const std::string& extension_id);
|
| + // the app has no page specified, kUnsetIndex is returned.
|
| + StringOrdinal GetPageIndex(const std::string& extension_id) const;
|
|
|
| // Sets a specific page index for an extension with |extension_id|.
|
| - void SetPageIndex(const std::string& extension_id, int index);
|
| + void SetPageIndex(const std::string& extension_id,
|
| + const StringOrdinal& index);
|
|
|
| // Removes the page index for an extension.
|
| void ClearPageIndex(const std::string& extension_id);
|
|
|
| + // Convert the page index StringOrdinal value to its integer equivalent.
|
| + int PageIndexAsInteger(const StringOrdinal& page_index) const;
|
| +
|
| + // Converts the page index integer to its StringOrdinal equivalent.
|
| + StringOrdinal PageIndexAsStringOrdinal(size_t page_index);
|
| +
|
| // Returns true if the user repositioned the app on the app launcher via drag
|
| // and drop.
|
| bool WasAppDraggedByUser(const std::string& extension_id);
|
| @@ -457,6 +475,11 @@ class ExtensionPrefs : public ExtensionContentSettingsStore::Observer {
|
| const std::string& pref_key,
|
| const base::ListValue** out_value);
|
|
|
| + // Reads a string pref |pref_key| from extension with id |extension_id|.
|
| + bool ReadExtensionPrefString(const std::string& extension_id,
|
| + const std::string& pref_key,
|
| + std::string* out_value) const;
|
| +
|
| // Interprets the list pref, |pref_key| in |extension_id|'s preferences, as a
|
| // URLPatternSet. The |valid_schemes| specify how to parse the URLPatterns.
|
| bool ReadExtensionPrefURLPatternSet(const std::string& extension_id,
|
| @@ -514,17 +537,42 @@ class ExtensionPrefs : public ExtensionContentSettingsStore::Observer {
|
| // Migrates the permissions data in the pref store.
|
| void MigratePermissions(const ExtensionIdSet& extension_ids);
|
|
|
| + // Migrates the app launcher and page index values.
|
| + void MigrateAppIndex(const ExtensionIdSet& extension_ids);
|
| +
|
| // Checks whether there is a state pref for the extension and if so, whether
|
| // it matches |check_state|.
|
| bool DoesExtensionHaveState(const std::string& id,
|
| Extension::State check_state) const;
|
|
|
| + // Searches though all loaded apps and returns all the app launch indices that
|
| + // appear on the page |page_index|.
|
| + void GetAllAppLaunchIndicesOnPageSorted(
|
| + const StringOrdinal& page_index,
|
| + std::set<StringOrdinal, StringOrdinalLessThan>* indices_on_page) const;
|
| +
|
| + // Initialize the |page_index_map_| with the page indexes used by the
|
| + // given extensions.
|
| + void InitializePageIndexMap(const ExtensionIdSet& extension_ids);
|
| +
|
| + // Called when an application changes the value of its page index so that
|
| + // |page_index_map_| is aware that |old_value| page index has been
|
| + // replace by the |new_value| page index and adjusts its mapping accordingly.
|
| + // This works with valid and invalid StringOrdinals.
|
| + void UpdatePageIndexMap(const StringOrdinal& old_value,
|
| + const StringOrdinal& new_value);
|
| +
|
| // The pref service specific to this set of extension prefs. Owned by profile.
|
| PrefService* prefs_;
|
|
|
| // Base extensions install directory.
|
| FilePath install_directory_;
|
|
|
| + // A map of all the StringOrdinal page indices mapping to how often they are
|
| + // used, this is used for mapping the StringOrdinals to their integer
|
| + // equivalent as well as quick lookup of the sorted StringOrdinals.
|
| + std::map<StringOrdinal, int, StringOrdinalLessThan> page_index_map_;
|
| +
|
| // Weak pointer, owned by Profile.
|
| ExtensionPrefValueMap* extension_pref_value_map_;
|
|
|
|
|