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 db8181f73ca13ea113c52e35461c0f03d160711b..22d22a8c0b776aa80b76a609754f4a957c7b1267 100644 |
| --- a/chrome/browser/extensions/extension_prefs.cc |
| +++ b/chrome/browser/extensions/extension_prefs.cc |
| @@ -162,6 +162,9 @@ const char kPrefOldGrantedAPIs[] = "granted_permissions.api"; |
| // A preference that indicates when an extension was installed. |
| const char kPrefInstallTime[] = "install_time"; |
| +// A preference which saves the creation flags for extensions. |
| +const char kPrefCreationFlags[] = "creation_flags"; |
| + |
| // A preference that indicates whether the extension was installed from the |
| // Chrome Web Store. |
| const char kPrefFromWebStore[] = "from_webstore"; |
| @@ -1452,6 +1455,8 @@ void ExtensionPrefs::OnExtensionInstalled( |
| extension_dict->Set(kPrefState, Value::CreateIntegerValue(initial_state)); |
| extension_dict->Set(kPrefLocation, |
| Value::CreateIntegerValue(extension->location())); |
| + extension_dict->Set(kPrefCreationFlags, |
| + Value::CreateIntegerValue(extension->creation_flags())); |
| extension_dict->Set(kPrefFromWebStore, |
| Value::CreateBooleanValue(from_webstore)); |
| extension_dict->Set(kPrefFromBookmark, |
| @@ -1865,6 +1870,21 @@ bool ExtensionPrefs::IsFromBookmark( |
| return false; |
| } |
| +int ExtensionPrefs::GetCreationFlags(const std::string& extension_id) const { |
| + const DictionaryValue* dictionary = GetExtensionPref(extension_id); |
| + int creation_flags = 0; |
|
Mihai Parparita -not on Chrome
2012/09/29 00:22:25
There's an Extension::NO_FLAGS value that you can
Gaurav
2012/10/01 22:09:36
Done.
|
| + if (dictionary) { |
| + dictionary->GetInteger(kPrefCreationFlags, &creation_flags); |
|
Mihai Parparita -not on Chrome
2012/09/29 00:22:25
This can still fail (the extension preference dict
Gaurav
2012/10/01 22:09:36
Done.
|
| + } else { |
| + // Since kPrefCreationFlags was added later, it will be missing for |
| + // previously installed extensions. |
| + creation_flags |= IsFromBookmark(extension_id); |
|
Mihai Parparita -not on Chrome
2012/09/29 00:22:25
This won't quite work. You're trying to say:
creat
Gaurav
2012/09/29 00:30:28
My mad, will fix this.
On 2012/09/29 00:22:25, Mi
Gaurav
2012/10/01 22:09:36
Done.
|
| + creation_flags |= IsFromWebStore(extension_id); |
| + creation_flags |= WasInstalledByDefault(extension_id); |
| + } |
| + return creation_flags; |
| +} |
| + |
| bool ExtensionPrefs::WasInstalledByDefault( |
| const std::string& extension_id) const { |
| const DictionaryValue* dictionary = GetExtensionPref(extension_id); |