[ntp][modules] Create a pref for module orders
With drag and drop, modules can be reordered but these new orders need
to persist with the next NTP load. The pref stores a list of module
ids that will be used when initializing modules (reading and writing of
the pref will be implemented in follow up CLs).
Fixed: 1229338
Change-Id: I76490a5ec2fb76a99306d4b77b5d4f8f72ba81c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3028950
Reviewed-by: Moe Ahmadi <mahmadi@chromium.org>
Commit-Queue: Lydia Lam <lydialam@google.com>
Cr-Commit-Position: refs/heads/master@{#902182}
diff --git a/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc b/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc
index 9b0ef76d..965b3b7 100644
--- a/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc
+++ b/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc
@@ -352,8 +352,9 @@
// static
void NewTabPageHandler::RegisterProfilePrefs(PrefRegistrySimple* registry) {
- registry->RegisterBooleanPref(prefs::kNtpModulesVisible, true);
registry->RegisterListPref(prefs::kNtpDisabledModules, true);
+ registry->RegisterListPref(prefs::kNtpModulesOrder, true);
+ registry->RegisterBooleanPref(prefs::kNtpModulesVisible, true);
}
void NewTabPageHandler::SetMostVisitedSettings(bool custom_links_enabled,
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index cee0b27..c885e700 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -1819,8 +1819,12 @@
const char kNtpCustomBackgroundDict[] = "ntp.custom_background_dict";
const char kNtpCustomBackgroundLocalToDevice[] =
"ntp.custom_background_local_to_device";
-const char kNtpModulesVisible[] = "NewTabPage.ModulesVisible";
+// List keeping track of disabled NTP modules.
const char kNtpDisabledModules[] = "NewTabPage.DisabledModules";
+// List keeping track of NTP modules order.
+const char kNtpModulesOrder[] = "NewTabPage.ModulesOrder";
+// Whether NTP modules are visible.
+const char kNtpModulesVisible[] = "NewTabPage.ModulesVisible";
// List of promos that the user has dismissed while on the NTP.
const char kNtpPromoBlocklist[] = "ntp.promo_blocklist";
// Data associated with search suggestions that appear on the NTP.
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 813799a..6d41f24 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -616,8 +616,9 @@
#else
extern const char kNtpCustomBackgroundDict[];
extern const char kNtpCustomBackgroundLocalToDevice[];
-extern const char kNtpModulesVisible[];
extern const char kNtpDisabledModules[];
+extern const char kNtpModulesOrder[];
+extern const char kNtpModulesVisible[];
extern const char kNtpPromoBlocklist[];
extern const char kNtpSearchSuggestionsBlocklist[];
extern const char kNtpSearchSuggestionsImpressions[];