Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(974)

Unified Diff: chrome/browser/extensions/extension_prefs.cc

Issue 10977048: Fix bug in disabling sync for default apps (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Added a preference for creation_flags, Also added creation_flags check in ReloadExtensions unittest Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);

Powered by Google App Engine
This is Rietveld 408576698