Chromium Code Reviews| Index: chrome/browser/extensions/extension_prefs.cc |
| diff --git a/chrome/browser/extensions/extension_prefs.cc b/chrome/browser/extensions/extension_prefs.cc |
| index 52af11b5fb53e1777d11faa74690eb3301cda216..20e2b6bc9f89ae64d9fc14f1568371b7b63d8089 100644 |
| --- a/chrome/browser/extensions/extension_prefs.cc |
| +++ b/chrome/browser/extensions/extension_prefs.cc |
| @@ -69,6 +69,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.actionbox"; |
|
Aaron Boodman
2012/06/12 05:53:44
I would recommend: extensions.action_box_order
yefimt
2012/06/13 01:24:21
Done.
|
| + |
| +const char kExtensionActionboxBar[] = "extensions.actionbox_bar"; |
|
Aaron Boodman
2012/06/12 05:53:44
And: toolbar_order_for_action_box_mode
yefimt
2012/06/13 01:24:21
Changed to toolbar_order.
Assuming that old prefer
|
| + |
| // 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. |
| @@ -1181,27 +1185,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( |
| @@ -1908,6 +1911,8 @@ void ExtensionPrefs::ClearIncognitoSessionOnlyContentSettings() { |
| 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); |
| @@ -1932,3 +1937,27 @@ void ExtensionPrefs::RegisterUserPrefs(PrefService* prefs) { |
| 0, // default value |
| PrefService::UNSYNCABLE_PREF); |
| } |
| + |
| +std::vector<std::string> ExtensionPrefs::GetExtensionsOrder(const char* pref) { |
| + ExtensionIdSet extension_ids; |
| + const ListValue* toolbar_order = prefs_->GetList(pref); |
| + 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; |
| +} |
| + |
| +void ExtensionPrefs::SetExtensionsOrder(const char* pref, |
| + const std::vector<std::string>& extension_ids) { |
| + ListPrefUpdate update(prefs_, pref); |
| + 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)); |
| + } |
| +} |