Index: chrome/browser/extensions/extension_prefs.cc |
diff --git a/chrome/browser/extensions/extension_prefs.cc b/chrome/browser/extensions/extension_prefs.cc |
index 19e01dba7b8b63d237b2fd84d81476afcc6ccb58..ea19c5fee8fc0cc1f931f29c6c3c540a2d813b83 100644 |
--- a/chrome/browser/extensions/extension_prefs.cc |
+++ b/chrome/browser/extensions/extension_prefs.cc |
@@ -77,6 +77,10 @@ const char kPrefDisableReason[] = "disable_reason"; |
// object stored in the Preferences file. The extensions are stored by ID. |
const char kExtensionToolbar[] = "extensions.toolbar"; |
+const char kExtensionActionBox[] = "extensions.action_box_order"; |
Aaron Boodman
2012/07/02 22:41:34
Comment these.
yefimt
2012/07/11 22:34:34
Done.
|
+ |
+const char kExtensionActionBoxBar[] = "extensions.toolbar_order"; |
Aaron Boodman
2012/07/02 22:41:34
I still think this should be toolbar_order_with_ac
yefimt
2012/07/11 22:34:34
Done.
|
+ |
// The key for a serialized Time value indicating the start of the day (from the |
// server's perspective) an extension last included a "ping" parameter during |
// its update check. |
@@ -1152,27 +1156,26 @@ bool ExtensionPrefs::IsExtensionDisabled( |
} |
std::vector<std::string> ExtensionPrefs::GetToolbarOrder() { |
- ExtensionIdSet extension_ids; |
- const ListValue* toolbar_order = prefs_->GetList(kExtensionToolbar); |
- if (toolbar_order) { |
- for (size_t i = 0; i < toolbar_order->GetSize(); ++i) { |
- std::string extension_id; |
- if (toolbar_order->GetString(i, &extension_id)) |
- extension_ids.push_back(extension_id); |
- } |
- } |
- return extension_ids; |
+ bool action_box_enabled = extensions::switch_utils::IsActionBoxEnabled(); |
+ return GetExtensionsOrder(action_box_enabled ? kExtensionActionBoxBar : |
+ kExtensionToolbar); |
} |
void ExtensionPrefs::SetToolbarOrder( |
const std::vector<std::string>& extension_ids) { |
- ListPrefUpdate update(prefs_, kExtensionToolbar); |
- ListValue* toolbar_order = update.Get(); |
- toolbar_order->Clear(); |
- for (std::vector<std::string>::const_iterator iter = extension_ids.begin(); |
- iter != extension_ids.end(); ++iter) { |
- toolbar_order->Append(new StringValue(*iter)); |
- } |
+ bool action_box_enabled = extensions::switch_utils::IsActionBoxEnabled(); |
+ SetExtensionsOrder(action_box_enabled ? kExtensionActionBoxBar : |
+ kExtensionToolbar, |
+ extension_ids); |
+} |
+ |
+std::vector<std::string> ExtensionPrefs::GetActionBoxOrder() { |
+ return GetExtensionsOrder(kExtensionActionBox); |
+} |
+ |
+void ExtensionPrefs::SetActionBoxOrder( |
+ const std::vector<std::string>& extension_ids) { |
+ SetExtensionsOrder(kExtensionActionBox, extension_ids); |
} |
void ExtensionPrefs::OnExtensionInstalled( |
@@ -1889,6 +1892,8 @@ URLPatternSet ExtensionPrefs::GetAllowedInstallSites() { |
void ExtensionPrefs::RegisterUserPrefs(PrefService* prefs) { |
prefs->RegisterDictionaryPref(kExtensionsPref, PrefService::UNSYNCABLE_PREF); |
prefs->RegisterListPref(kExtensionToolbar, PrefService::UNSYNCABLE_PREF); |
+ prefs->RegisterListPref(kExtensionActionBox, PrefService::UNSYNCABLE_PREF); |
+ prefs->RegisterListPref(kExtensionActionBoxBar, PrefService::UNSYNCABLE_PREF); |
prefs->RegisterIntegerPref(prefs::kExtensionToolbarSize, |
-1, // default value |
PrefService::UNSYNCABLE_PREF); |
@@ -1915,3 +1920,27 @@ void ExtensionPrefs::RegisterUserPrefs(PrefService* prefs) { |
prefs->RegisterListPref(prefs::kExtensionAllowedInstallSites, |
PrefService::UNSYNCABLE_PREF); |
} |
+ |
+std::vector<std::string> ExtensionPrefs::GetExtensionsOrder(const char* pref) { |
+ ExtensionIdSet extension_ids; |
+ const ListValue* list_of_values = prefs_->GetList(pref); |
+ if (list_of_values) { |
Aaron Boodman
2012/07/02 22:41:34
Reverse check and return early.
yefimt
2012/07/11 22:34:34
Done.
|
+ for (size_t i = 0; i < list_of_values->GetSize(); ++i) { |
+ std::string extension_id; |
+ if (list_of_values->GetString(i, &extension_id)) |
+ extension_ids.push_back(extension_id); |
+ } |
+ } |
+ return extension_ids; |
+} |
+ |
+void ExtensionPrefs::SetExtensionsOrder(const char* pref, |
+ const std::vector<std::string>& strings) { |
+ ListPrefUpdate update(prefs_, pref); |
+ ListValue* list_of_values = update.Get(); |
+ list_of_values->Clear(); |
+ for (std::vector<std::string>::const_iterator iter = strings.begin(); |
+ iter != strings.end(); ++iter) { |
+ list_of_values->Append(new StringValue(*iter)); |
+ } |
+} |