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

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

Issue 14973007: Auto-install/uninstall shared module dependencies for extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: feedback Created 7 years, 6 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 80213913bf1b18a786d136e77786958270c64b8d..e9fcb46d558f1c49f4a334e58cb5135aff44054a 100644
--- a/chrome/browser/extensions/extension_prefs.cc
+++ b/chrome/browser/extensions/extension_prefs.cc
@@ -118,6 +118,9 @@ const char kExtensionsBlacklistUpdate[] = "extensions.blacklistupdate";
// updates that were waiting for idle.
const char kDelayedInstallInfo[] = "idle_install_info";
+// Reason why the extension's install was delayed.
+const char kDelayedInstallReason[] = "delay_install_reason";
+
// Path for the suggested page ordinal of a delayed extension install.
const char kPrefSuggestedPageOrdinal[] = "suggested_page_ordinal";
@@ -1394,6 +1397,7 @@ ExtensionPrefs::GetInstalledExtensionsInfo() const {
void ExtensionPrefs::SetDelayedInstallInfo(
const Extension* extension,
Extension::State initial_state,
+ DelayReason delay_reason,
const syncer::StringOrdinal& page_ordinal) {
DictionaryValue* extension_dict = new DictionaryValue();
PopulateExtensionInfoPrefs(extension, time_provider_->GetCurrentTime(),
@@ -1408,6 +1412,8 @@ void ExtensionPrefs::SetDelayedInstallInfo(
page_ordinal.IsValid() ? page_ordinal.ToInternalValue()
: std::string());
}
+ extension_dict->SetInteger(kDelayedInstallReason,
+ static_cast<int>(delay_reason));
UpdateExtensionPref(extension->id(), kDelayedInstallInfo, extension_dict);
}
@@ -1443,6 +1449,7 @@ bool ExtensionPrefs::FinishDelayedInstallInfo(
needs_sort_ordinal = true;
pending_install_dict->Remove(kPrefSuggestedPageOrdinal, NULL);
}
+ pending_install_dict->Remove(kDelayedInstallReason, NULL);
const base::Time install_time = time_provider_->GetCurrentTime();
pending_install_dict->Set(
@@ -1471,6 +1478,24 @@ scoped_ptr<ExtensionInfo> ExtensionPrefs::GetDelayedInstallInfo(
return GetInstalledInfoHelper(extension_id, ext);
}
+ExtensionPrefs::DelayReason ExtensionPrefs::GetDelayedInstallReason(
+ const std::string& extension_id) const {
+ const DictionaryValue* extension_prefs =
+ GetExtensionPref(extension_id);
+ if (!extension_prefs)
+ return DELAY_REASON_NONE;
+
+ const DictionaryValue* ext = NULL;
+ if (!extension_prefs->GetDictionary(kDelayedInstallInfo, &ext))
+ return DELAY_REASON_NONE;
+
+ int delay_reason;
+ if (!ext->GetInteger(kDelayedInstallReason, &delay_reason))
+ return DELAY_REASON_NONE;
+
+ return static_cast<DelayReason>(delay_reason);
+}
+
scoped_ptr<ExtensionPrefs::ExtensionsInfo> ExtensionPrefs::
GetAllDelayedInstallInfo() const {
scoped_ptr<ExtensionsInfo> extensions_info(new ExtensionsInfo);
@@ -1547,6 +1572,16 @@ int ExtensionPrefs::GetCreationFlags(const std::string& extension_id) const {
return creation_flags;
}
+int ExtensionPrefs::GetDelayedInstallCreationFlags(
+ const std::string& extension_id) const {
+ int creation_flags = Extension::NO_FLAGS;
+ const DictionaryValue* delayed_info = NULL;
+ if (ReadPrefAsDictionary(extension_id, kDelayedInstallInfo, &delayed_info)) {
+ delayed_info->GetInteger(kPrefCreationFlags, &creation_flags);
+ }
+ 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