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

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

Issue 9340007: Make the Chrome Web Store Icon Syncable (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Removing braces Created 8 years, 10 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.cc
diff --git a/chrome/browser/extensions/extension_sorting.cc b/chrome/browser/extensions/extension_sorting.cc
index 993eb0937d4c94769bf13acd4ad53c0bbd865999..2bb20171cece1da028350f7dc871f4e9d95523b2 100644
--- a/chrome/browser/extensions/extension_sorting.cc
+++ b/chrome/browser/extensions/extension_sorting.cc
@@ -190,6 +190,27 @@ void ExtensionSorting::FixNTPOrdinalCollisions() {
content::NotificationService::NoDetails());
}
+void ExtensionSorting::EnsureValidOrdinals(const std::string& extension_id) {
+ StringOrdinal page_ordinal = GetPageOrdinal(extension_id);
+ if (!page_ordinal.IsValid()) {
+ // The webstore app should always start be on the first page.
+ page_ordinal = extension_id == extension_misc::kWebStoreAppId ?
+ CreateFirstAppPageOrdinal() :
+ GetNaturalAppPageOrdinal();
+ SetPageOrdinal(extension_id, page_ordinal);
+ }
+
+ StringOrdinal app_launch_ordinal = GetAppLaunchOrdinal(extension_id);
+ if (!app_launch_ordinal.IsValid()) {
+ // The webstore app should always start in the position.
+ app_launch_ordinal = extension_id == extension_misc::kWebStoreAppId ?
+ CreateFirstAppLaunchOrdinal(page_ordinal) :
+ CreateNextAppLaunchOrdinal(page_ordinal);
+ SetAppLaunchOrdinal(extension_id,
+ app_launch_ordinal);
+ }
+}
+
void ExtensionSorting::OnExtensionMoved(
const std::string& moved_extension_id,
const std::string& predecessor_extension_id,
@@ -243,10 +264,14 @@ void ExtensionSorting::SetAppLaunchOrdinal(
extension_id, page_ordinal, GetAppLaunchOrdinal(extension_id));
AddOrdinalMapping(extension_id, page_ordinal, new_app_launch_ordinal);
+ Value* new_value = new_app_launch_ordinal.IsValid() ?
+ Value::CreateStringValue(new_app_launch_ordinal.ToString()) :
+ NULL;
+
extension_scoped_prefs_->UpdateExtensionPref(
extension_id,
kPrefAppLaunchOrdinal,
- Value::CreateStringValue(new_app_launch_ordinal.ToString()));
+ new_value);
}
StringOrdinal ExtensionSorting::CreateFirstAppLaunchOrdinal(
@@ -320,10 +345,14 @@ void ExtensionSorting::SetPageOrdinal(const std::string& extension_id,
extension_id, GetPageOrdinal(extension_id), app_launch_ordinal);
AddOrdinalMapping(extension_id, new_page_ordinal, app_launch_ordinal);
+ Value* new_value = new_page_ordinal.IsValid() ?
+ Value::CreateStringValue(new_page_ordinal.ToString()) :
+ NULL;
+
extension_scoped_prefs_->UpdateExtensionPref(
extension_id,
kPrefPageOrdinal,
- Value::CreateStringValue(new_page_ordinal.ToString()));
+ new_value);
}
void ExtensionSorting::ClearOrdinals(const std::string& extension_id) {
« no previous file with comments | « chrome/browser/extensions/extension_sorting.h ('k') | chrome/browser/extensions/extension_sorting_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698