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 9ab3412280c34b3160d663931acab9e8d8064de5..180fee382e89e83e295157e37c3f0b3f49030af6 100644 |
| --- a/chrome/browser/extensions/extension_prefs.cc |
| +++ b/chrome/browser/extensions/extension_prefs.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/string_util.h" |
| #include "base/utf_string_conversions.h" |
| #include "chrome/browser/extensions/api/alarms/alarm_manager.h" |
| +#include "chrome/browser/extensions/api/omnibox/omnibox_api.h" |
| #include "chrome/browser/extensions/extension_pref_store.h" |
| #include "chrome/browser/extensions/extension_sorting.h" |
| #include "chrome/browser/prefs/pref_notifier.h" |
| @@ -162,6 +163,9 @@ const char kRegisteredEvents[] = "events"; |
| const char kRegisteredAlarms[] = "alarms"; |
| const char kAlarmScheduledRunTime[] = "scheduled_run_time"; |
| +// Persisted value for omnibox.setDefaultSuggestion. |
| +const char kOmniboxDefaultSuggestion[] = "omnibox_default_suggestion"; |
| + |
| // Provider of write access to a dictionary storing extension prefs. |
| class ScopedExtensionPrefUpdate : public DictionaryPrefUpdate { |
| public: |
| @@ -1001,6 +1005,25 @@ void ExtensionPrefs::SetRegisteredAlarms( |
| UpdateExtensionPref(extension_id, kRegisteredAlarms, list); |
| } |
| +extensions::ExtensionOmniboxSuggestion |
| +ExtensionPrefs::GetOmniboxDefaultSuggestion(const std::string& extension_id) { |
| + extensions::ExtensionOmniboxSuggestion suggestion; |
| + |
| + const base::DictionaryValue* extension = GetExtensionPref(extension_id); |
| + base::DictionaryValue* dict = NULL; |
| + if (extension && extension->GetDictionary(kOmniboxDefaultSuggestion, &dict)) |
| + suggestion.Populate(*dict, false); |
| + |
| + return suggestion; |
| +} |
| + |
| +void ExtensionPrefs::SetOmniboxDefaultSuggestion( |
| + const std::string& extension_id, |
| + const extensions::ExtensionOmniboxSuggestion& suggestion) { |
| + scoped_ptr<base::DictionaryValue> dict = suggestion.ToValue().Pass(); |
| + UpdateExtensionPref(extension_id, kOmniboxDefaultSuggestion, dict.release()); |
|
Yoyo Zhou
2012/05/04 18:50:52
release might be unnecessary here. dict goes out o
Matt Perry
2012/05/04 20:10:12
release() transfers ownership to UpdateExtensionPr
|
| +} |
| + |
| bool ExtensionPrefs::IsIncognitoEnabled(const std::string& extension_id) { |
| return ReadExtensionPrefBoolean(extension_id, kPrefIncognitoEnabled); |
| } |