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

Unified Diff: chrome/browser/extensions/extension_sorting.h

Issue 10969044: cros: Implement default app ordering. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix a typo Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_sorting.h
diff --git a/chrome/browser/extensions/extension_sorting.h b/chrome/browser/extensions/extension_sorting.h
index 89c19b80d2d89a77861e5b5327f8c30f07f5e599..9778f303edfb8b49c6e081b6bb89c0241e50c076 100644
--- a/chrome/browser/extensions/extension_sorting.h
+++ b/chrome/browser/extensions/extension_sorting.h
@@ -37,8 +37,10 @@ class ExtensionSorting {
void FixNTPOrdinalCollisions();
// This ensures that the extension has valid ordinals, and if it doesn't then
- // properly initialize them.
- void EnsureValidOrdinals(const std::string& extension_id);
+ // properly initialize them. |suggested_page| will be used if it is valid and
+ // the extension has no valid user-set page ordinal.
+ void EnsureValidOrdinals(const std::string& extension_id,
+ const syncer::StringOrdinal& suggested_page);
// Updates the app launcher value for the moved extension so that it is now
// located after the given predecessor and before the successor.
@@ -101,6 +103,7 @@ class ExtensionSorting {
private:
// Unit tests.
+ friend class ExtensionSortingDefaultOrdinalsBase;
friend class ExtensionSortingGetMinOrMaxAppLaunchOrdinalsOnPage;
friend class ExtensionSortingInitializeWithNoApps;
friend class ExtensionSortingPageOrdinalMapping;
@@ -109,6 +112,13 @@ class ExtensionSorting {
// value should be returned.
enum AppLaunchOrdinalReturn {MIN_ORDINAL, MAX_ORDINAL};
+ // Maps an app id to its ordinals.
+ struct AppOrdinals {
+ syncer::StringOrdinal page_ordinal;
+ syncer::StringOrdinal app_launch_ordinal;
+ };
+ typedef std::map<std::string, AppOrdinals> AppOrdinalsMap;
+
// This function returns the lowest ordinal on |page_ordinal| if
// |return_value| == AppLaunchOrdinalReturn::MIN_ORDINAL, otherwise it returns
// the largest ordinal on |page_ordinal|. If there are no apps on the page
@@ -149,6 +159,23 @@ class ExtensionSorting {
// extension is not an application.
void SyncIfNeeded(const std::string& extension_id);
+ // Creates the default ordinals.
+ void CreateDefaultOrdinals();
+
+ // Gets the default ordinals for |extension_id|. Returns false if no default
+ // ordinals for |extension_id| is defined. Otherwise, returns true and
+ // ordinals is updated with corresponding ordinals.
+ bool GetDefaultOrdinals(const std::string& extension_id,
+ syncer::StringOrdinal* page_ordinal,
+ syncer::StringOrdinal* app_launch_ordinal) const;
+
+ // Returns |app_launch_ordinal| if it has no collision in the page specified
+ // by |page_ordinal|. Otherwise, returns an ordinal after |app_launch_ordinal|
+ // that has no conflict.
+ syncer::StringOrdinal ResolveCollision(
+ const syncer::StringOrdinal& page_ordinal,
+ const syncer::StringOrdinal& app_launch_ordinal) const;
+
ExtensionScopedPrefs* extension_scoped_prefs_; // Weak, owns this instance.
PrefService* pref_service_; // Weak.
ExtensionServiceInterface* extension_service_; // Weak.
@@ -172,6 +199,9 @@ class ExtensionSorting {
syncer::StringOrdinal::LessThanFn> PageOrdinalMap;
PageOrdinalMap ntp_ordinal_map_;
+ // Defines the default ordinals.
+ AppOrdinalsMap default_ordinals_;
+
DISALLOW_COPY_AND_ASSIGN(ExtensionSorting);
};

Powered by Google App Engine
This is Rietveld 408576698