Index: extensions/browser/extension_prefs.cc |
diff --git a/extensions/browser/extension_prefs.cc b/extensions/browser/extension_prefs.cc |
index e9b4a765facb73e3a9b1ca20767a5690a221f6dd..3776b6a024da7a9a6e61675eb50a6b63277f960d 100644 |
--- a/extensions/browser/extension_prefs.cc |
+++ b/extensions/browser/extension_prefs.cc |
@@ -185,6 +185,9 @@ const char kPrefLastLaunchTime[] = "last_launch_time"; |
// of time. |
const char kPrefEvictedEphemeralApp[] = "evicted_ephemeral_app"; |
+// A preference indicating whether the extension is an ephemeral app. |
+const char kPrefEphemeralApp[] = "ephemeral_app"; |
+ |
// Am installation parameter bundled with an extension. |
const char kPrefInstallParam[] = "install_parameter"; |
@@ -1226,6 +1229,7 @@ void ExtensionPrefs::OnExtensionInstalled( |
const Extension* extension, |
Extension::State initial_state, |
bool blacklisted_for_malware, |
+ bool is_ephemeral, |
const syncer::StringOrdinal& page_ordinal, |
const std::string& install_parameter) { |
ScopedExtensionPrefUpdate update(prefs_, extension->id()); |
@@ -1235,6 +1239,7 @@ void ExtensionPrefs::OnExtensionInstalled( |
install_time, |
initial_state, |
blacklisted_for_malware, |
+ is_ephemeral, |
install_parameter, |
extension_dict); |
FinishExtensionInfoPrefs(extension->id(), install_time, |
@@ -1260,8 +1265,7 @@ void ExtensionPrefs::OnExtensionUninstalled(const std::string& extension_id, |
observer_list_, |
OnExtensionStateChanged(extension_id, false)); |
} else { |
- int creation_flags = GetCreationFlags(extension_id); |
- if (creation_flags & Extension::IS_EPHEMERAL) { |
+ if (IsEphemeralApp(extension_id)) { |
// Keep ephemeral apps around, but mark them as evicted. |
UpdateExtensionPref(extension_id, kPrefEvictedEphemeralApp, |
new base::FundamentalValue(true)); |
@@ -1457,6 +1461,7 @@ void ExtensionPrefs::SetDelayedInstallInfo( |
const Extension* extension, |
Extension::State initial_state, |
bool blacklisted_for_malware, |
+ bool is_ephemeral, |
DelayReason delay_reason, |
const syncer::StringOrdinal& page_ordinal, |
const std::string& install_parameter) { |
@@ -1465,6 +1470,7 @@ void ExtensionPrefs::SetDelayedInstallInfo( |
time_provider_->GetCurrentTime(), |
initial_state, |
blacklisted_for_malware, |
+ is_ephemeral, |
install_parameter, |
extension_dict); |
@@ -1623,12 +1629,17 @@ scoped_ptr<ExtensionInfo> ExtensionPrefs::GetEvictedEphemeralAppInfo( |
void ExtensionPrefs::RemoveEvictedEphemeralApp( |
const std::string& extension_id) { |
- bool evicted_ephemeral_app = false; |
- if (ReadPrefAsBoolean(extension_id, |
- kPrefEvictedEphemeralApp, |
- &evicted_ephemeral_app) && evicted_ephemeral_app) { |
+ if (ReadPrefAsBooleanAndReturn(extension_id, kPrefEvictedEphemeralApp)) |
DeleteExtensionPrefs(extension_id); |
- } |
+} |
+ |
+bool ExtensionPrefs::IsEphemeralApp(const std::string& extension_id) const { |
+ if (ReadPrefAsBooleanAndReturn(extension_id, kPrefEphemeralApp)) |
+ return true; |
+ |
+ // Ephemerality was previously stored in the creation flags, so we must also |
+ // check it for backcompatibility. |
+ return (GetCreationFlags(extension_id) & Extension::IS_EPHEMERAL) != 0; |
} |
bool ExtensionPrefs::WasAppDraggedByUser(const std::string& extension_id) { |
@@ -2096,6 +2107,7 @@ void ExtensionPrefs::PopulateExtensionInfoPrefs( |
const base::Time install_time, |
Extension::State initial_state, |
bool blacklisted_for_malware, |
+ bool is_ephemeral, |
const std::string& install_parameter, |
base::DictionaryValue* extension_dict) { |
// Leave the state blank for component extensions so that old chrome versions |
@@ -2121,6 +2133,8 @@ void ExtensionPrefs::PopulateExtensionInfoPrefs( |
extension_dict->Set(kPrefInstallTime, |
new base::StringValue( |
base::Int64ToString(install_time.ToInternalValue()))); |
+ extension_dict->Set(kPrefEphemeralApp, |
+ new base::FundamentalValue(is_ephemeral)); |
if (blacklisted_for_malware) |
extension_dict->Set(kPrefBlacklist, new base::FundamentalValue(true)); |