| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "extensions/browser/extension_prefs.h" | 5 #include "extensions/browser/extension_prefs.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/prefs/pref_notifier.h" | 10 #include "base/prefs/pref_notifier.h" |
| (...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1633 return GetInstalledInfoHelper(extension_id, extension_prefs); | 1633 return GetInstalledInfoHelper(extension_id, extension_prefs); |
| 1634 } | 1634 } |
| 1635 | 1635 |
| 1636 void ExtensionPrefs::RemoveEvictedEphemeralApp( | 1636 void ExtensionPrefs::RemoveEvictedEphemeralApp( |
| 1637 const std::string& extension_id) { | 1637 const std::string& extension_id) { |
| 1638 if (ReadPrefAsBooleanAndReturn(extension_id, kPrefEvictedEphemeralApp)) | 1638 if (ReadPrefAsBooleanAndReturn(extension_id, kPrefEvictedEphemeralApp)) |
| 1639 DeleteExtensionPrefs(extension_id); | 1639 DeleteExtensionPrefs(extension_id); |
| 1640 } | 1640 } |
| 1641 | 1641 |
| 1642 bool ExtensionPrefs::IsEphemeralApp(const std::string& extension_id) const { | 1642 bool ExtensionPrefs::IsEphemeralApp(const std::string& extension_id) const { |
| 1643 // Hide the data of evicted ephemeral apps. |
| 1644 if (ReadPrefAsBooleanAndReturn(extension_id, kPrefEvictedEphemeralApp)) |
| 1645 return false; |
| 1646 |
| 1643 if (ReadPrefAsBooleanAndReturn(extension_id, kPrefEphemeralApp)) | 1647 if (ReadPrefAsBooleanAndReturn(extension_id, kPrefEphemeralApp)) |
| 1644 return true; | 1648 return true; |
| 1645 | 1649 |
| 1646 // Ephemerality was previously stored in the creation flags, so we must also | 1650 // Ephemerality was previously stored in the creation flags, so we must also |
| 1647 // check it for backcompatibility. | 1651 // check it for backcompatibility. |
| 1648 return (GetCreationFlags(extension_id) & Extension::IS_EPHEMERAL) != 0; | 1652 return (GetCreationFlags(extension_id) & Extension::IS_EPHEMERAL) != 0; |
| 1649 } | 1653 } |
| 1650 | 1654 |
| 1655 void ExtensionPrefs::OnEphemeralAppInstalled(const std::string& extension_id) { |
| 1656 DCHECK(IsEphemeralApp(extension_id)); |
| 1657 |
| 1658 ScopedExtensionPrefUpdate update(prefs_, extension_id); |
| 1659 update->Set(kPrefEphemeralApp, new base::FundamentalValue(false)); |
| 1660 |
| 1661 DCHECK(!IsEvictedEphemeralApp(update.Get())); |
| 1662 update->Remove(kPrefEvictedEphemeralApp, NULL); |
| 1663 } |
| 1664 |
| 1651 bool ExtensionPrefs::WasAppDraggedByUser(const std::string& extension_id) { | 1665 bool ExtensionPrefs::WasAppDraggedByUser(const std::string& extension_id) { |
| 1652 return ReadPrefAsBooleanAndReturn(extension_id, kPrefUserDraggedApp); | 1666 return ReadPrefAsBooleanAndReturn(extension_id, kPrefUserDraggedApp); |
| 1653 } | 1667 } |
| 1654 | 1668 |
| 1655 void ExtensionPrefs::SetAppDraggedByUser(const std::string& extension_id) { | 1669 void ExtensionPrefs::SetAppDraggedByUser(const std::string& extension_id) { |
| 1656 UpdateExtensionPref(extension_id, kPrefUserDraggedApp, | 1670 UpdateExtensionPref(extension_id, kPrefUserDraggedApp, |
| 1657 new base::FundamentalValue(true)); | 1671 new base::FundamentalValue(true)); |
| 1658 } | 1672 } |
| 1659 | 1673 |
| 1660 bool ExtensionPrefs::IsFromWebStore( | 1674 bool ExtensionPrefs::IsFromWebStore( |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2135 new base::FundamentalValue(extension->was_installed_by_default())); | 2149 new base::FundamentalValue(extension->was_installed_by_default())); |
| 2136 extension_dict->Set( | 2150 extension_dict->Set( |
| 2137 kPrefWasInstalledByOem, | 2151 kPrefWasInstalledByOem, |
| 2138 new base::FundamentalValue(extension->was_installed_by_oem())); | 2152 new base::FundamentalValue(extension->was_installed_by_oem())); |
| 2139 extension_dict->Set(kPrefInstallTime, | 2153 extension_dict->Set(kPrefInstallTime, |
| 2140 new base::StringValue( | 2154 new base::StringValue( |
| 2141 base::Int64ToString(install_time.ToInternalValue()))); | 2155 base::Int64ToString(install_time.ToInternalValue()))); |
| 2142 if (blacklisted_for_malware) | 2156 if (blacklisted_for_malware) |
| 2143 extension_dict->Set(kPrefBlacklist, new base::FundamentalValue(true)); | 2157 extension_dict->Set(kPrefBlacklist, new base::FundamentalValue(true)); |
| 2144 | 2158 |
| 2145 if (is_ephemeral) | 2159 extension_dict->Set(kPrefEphemeralApp, |
| 2146 extension_dict->Set(kPrefEphemeralApp, new base::FundamentalValue(true)); | 2160 new base::FundamentalValue(is_ephemeral)); |
| 2147 else | |
| 2148 extension_dict->Remove(kPrefEphemeralApp, NULL); | |
| 2149 | 2161 |
| 2150 base::FilePath::StringType path = MakePathRelative(install_directory_, | 2162 base::FilePath::StringType path = MakePathRelative(install_directory_, |
| 2151 extension->path()); | 2163 extension->path()); |
| 2152 extension_dict->Set(kPrefPath, new base::StringValue(path)); | 2164 extension_dict->Set(kPrefPath, new base::StringValue(path)); |
| 2153 if (!install_parameter.empty()) { | 2165 if (!install_parameter.empty()) { |
| 2154 extension_dict->Set(kPrefInstallParam, | 2166 extension_dict->Set(kPrefInstallParam, |
| 2155 new base::StringValue(install_parameter)); | 2167 new base::StringValue(install_parameter)); |
| 2156 } | 2168 } |
| 2157 // We store prefs about LOAD extensions, but don't cache their manifest | 2169 // We store prefs about LOAD extensions, but don't cache their manifest |
| 2158 // since it may change on disk. | 2170 // since it may change on disk. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2256 extension_pref_value_map_->RegisterExtension( | 2268 extension_pref_value_map_->RegisterExtension( |
| 2257 extension_id, install_time, is_enabled, is_incognito_enabled); | 2269 extension_id, install_time, is_enabled, is_incognito_enabled); |
| 2258 | 2270 |
| 2259 FOR_EACH_OBSERVER( | 2271 FOR_EACH_OBSERVER( |
| 2260 ExtensionPrefsObserver, | 2272 ExtensionPrefsObserver, |
| 2261 observer_list_, | 2273 observer_list_, |
| 2262 OnExtensionRegistered(extension_id, install_time, is_enabled)); | 2274 OnExtensionRegistered(extension_id, install_time, is_enabled)); |
| 2263 } | 2275 } |
| 2264 | 2276 |
| 2265 } // namespace extensions | 2277 } // namespace extensions |
| OLD | NEW |