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

Unified Diff: extensions/browser/extension_prefs.cc

Issue 282103003: Moved IS_EPHEMERAL flag to extension prefs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix up file header Created 6 years, 7 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
« no previous file with comments | « extensions/browser/extension_prefs.h ('k') | extensions/browser/extension_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/extension_prefs.cc
diff --git a/extensions/browser/extension_prefs.cc b/extensions/browser/extension_prefs.cc
index 4443ee67d076bc4c29ba49e712b051c116a95d76..1e4ec9e240ee8aeb96a504177b7a000db9a345f4 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";
@@ -1232,6 +1235,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());
@@ -1241,6 +1245,7 @@ void ExtensionPrefs::OnExtensionInstalled(
install_time,
initial_state,
blacklisted_for_malware,
+ is_ephemeral,
install_parameter,
extension_dict);
FinishExtensionInfoPrefs(extension->id(), install_time,
@@ -1266,8 +1271,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));
@@ -1463,6 +1467,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) {
@@ -1471,6 +1476,7 @@ void ExtensionPrefs::SetDelayedInstallInfo(
time_provider_->GetCurrentTime(),
initial_state,
blacklisted_for_malware,
+ is_ephemeral,
install_parameter,
extension_dict);
@@ -1629,12 +1635,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) {
@@ -2102,6 +2113,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
@@ -2130,6 +2142,11 @@ void ExtensionPrefs::PopulateExtensionInfoPrefs(
if (blacklisted_for_malware)
extension_dict->Set(kPrefBlacklist, new base::FundamentalValue(true));
+ if (is_ephemeral)
+ extension_dict->Set(kPrefEphemeralApp, new base::FundamentalValue(true));
+ else
+ extension_dict->Remove(kPrefEphemeralApp, NULL);
+
base::FilePath::StringType path = MakePathRelative(install_directory_,
extension->path());
extension_dict->Set(kPrefPath, new base::StringValue(path));
« no previous file with comments | « extensions/browser/extension_prefs.h ('k') | extensions/browser/extension_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698