| 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" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/value_conversions.h" | 14 #include "base/value_conversions.h" |
| 15 #include "chrome/browser/extensions/api/content_settings/content_settings_store.
h" | |
| 16 #include "components/user_prefs/pref_registry_syncable.h" | 15 #include "components/user_prefs/pref_registry_syncable.h" |
| 17 #include "extensions/browser/admin_policy.h" | 16 #include "extensions/browser/admin_policy.h" |
| 18 #include "extensions/browser/app_sorting.h" | 17 #include "extensions/browser/app_sorting.h" |
| 19 #include "extensions/browser/event_router.h" | 18 #include "extensions/browser/event_router.h" |
| 20 #include "extensions/browser/extension_pref_store.h" | 19 #include "extensions/browser/extension_pref_store.h" |
| 21 #include "extensions/browser/extension_prefs_factory.h" | 20 #include "extensions/browser/extension_prefs_factory.h" |
| 22 #include "extensions/browser/pref_names.h" | 21 #include "extensions/browser/pref_names.h" |
| 23 #include "extensions/common/feature_switch.h" | 22 #include "extensions/common/feature_switch.h" |
| 24 #include "extensions/common/manifest.h" | 23 #include "extensions/common/manifest.h" |
| 25 #include "extensions/common/permissions/permission_set.h" | 24 #include "extensions/common/permissions/permission_set.h" |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 if (!source_dict->GetDictionary(key, &preferences)) | 250 if (!source_dict->GetDictionary(key, &preferences)) |
| 252 return; | 251 return; |
| 253 | 252 |
| 254 for (base::DictionaryValue::Iterator iter(*preferences); !iter.IsAtEnd(); | 253 for (base::DictionaryValue::Iterator iter(*preferences); !iter.IsAtEnd(); |
| 255 iter.Advance()) { | 254 iter.Advance()) { |
| 256 value_map->SetExtensionPref( | 255 value_map->SetExtensionPref( |
| 257 extension_id, iter.key(), scope, iter.value().DeepCopy()); | 256 extension_id, iter.key(), scope, iter.value().DeepCopy()); |
| 258 } | 257 } |
| 259 } | 258 } |
| 260 | 259 |
| 261 void InitExtensionControlledPrefs(ExtensionPrefs* prefs, | |
| 262 ExtensionPrefValueMap* value_map) { | |
| 263 ExtensionIdList extension_ids; | |
| 264 prefs->GetExtensions(&extension_ids); | |
| 265 | |
| 266 for (ExtensionIdList::iterator extension_id = extension_ids.begin(); | |
| 267 extension_id != extension_ids.end(); | |
| 268 ++extension_id) { | |
| 269 base::Time install_time = prefs->GetInstallTime(*extension_id); | |
| 270 bool is_enabled = !prefs->IsExtensionDisabled(*extension_id); | |
| 271 bool is_incognito_enabled = prefs->IsIncognitoEnabled(*extension_id); | |
| 272 value_map->RegisterExtension( | |
| 273 *extension_id, install_time, is_enabled, is_incognito_enabled); | |
| 274 prefs->content_settings_store()->RegisterExtension( | |
| 275 *extension_id, install_time, is_enabled); | |
| 276 | |
| 277 // Set regular extension controlled prefs. | |
| 278 LoadExtensionControlledPrefs( | |
| 279 prefs, value_map, *extension_id, kExtensionPrefsScopeRegular); | |
| 280 // Set incognito extension controlled prefs. | |
| 281 LoadExtensionControlledPrefs(prefs, | |
| 282 value_map, | |
| 283 *extension_id, | |
| 284 kExtensionPrefsScopeIncognitoPersistent); | |
| 285 // Set regular-only extension controlled prefs. | |
| 286 LoadExtensionControlledPrefs( | |
| 287 prefs, value_map, *extension_id, kExtensionPrefsScopeRegularOnly); | |
| 288 | |
| 289 // Set content settings. | |
| 290 const base::ListValue* content_settings = NULL; | |
| 291 if (prefs->ReadPrefAsList(*extension_id, | |
| 292 pref_names::kPrefContentSettings, | |
| 293 &content_settings)) { | |
| 294 prefs->content_settings_store()->SetExtensionContentSettingFromList( | |
| 295 *extension_id, content_settings, kExtensionPrefsScopeRegular); | |
| 296 } | |
| 297 if (prefs->ReadPrefAsList(*extension_id, | |
| 298 pref_names::kPrefIncognitoContentSettings, | |
| 299 &content_settings)) { | |
| 300 prefs->content_settings_store()->SetExtensionContentSettingFromList( | |
| 301 *extension_id, | |
| 302 content_settings, | |
| 303 kExtensionPrefsScopeIncognitoPersistent); | |
| 304 } | |
| 305 } | |
| 306 } | |
| 307 | |
| 308 } // namespace | 260 } // namespace |
| 309 | 261 |
| 310 // | 262 // |
| 311 // TimeProvider | 263 // TimeProvider |
| 312 // | 264 // |
| 313 | 265 |
| 314 ExtensionPrefs::TimeProvider::TimeProvider() { | 266 ExtensionPrefs::TimeProvider::TimeProvider() { |
| 315 } | 267 } |
| 316 | 268 |
| 317 ExtensionPrefs::TimeProvider::~TimeProvider() { | 269 ExtensionPrefs::TimeProvider::~TimeProvider() { |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 } | 455 } |
| 504 ScopedExtensionPrefUpdate update(prefs_, extension_id); | 456 ScopedExtensionPrefUpdate update(prefs_, extension_id); |
| 505 if (data_value) | 457 if (data_value) |
| 506 update->Set(key, data_value); | 458 update->Set(key, data_value); |
| 507 else | 459 else |
| 508 update->Remove(key, NULL); | 460 update->Remove(key, NULL); |
| 509 } | 461 } |
| 510 | 462 |
| 511 void ExtensionPrefs::DeleteExtensionPrefs(const std::string& extension_id) { | 463 void ExtensionPrefs::DeleteExtensionPrefs(const std::string& extension_id) { |
| 512 extension_pref_value_map_->UnregisterExtension(extension_id); | 464 extension_pref_value_map_->UnregisterExtension(extension_id); |
| 513 content_settings_store_->UnregisterExtension(extension_id); | 465 FOR_EACH_OBSERVER( |
| 466 Observer, observer_list_, OnExtensionPrefsDeleted(extension_id)); |
| 514 DictionaryPrefUpdate update(prefs_, pref_names::kExtensions); | 467 DictionaryPrefUpdate update(prefs_, pref_names::kExtensions); |
| 515 base::DictionaryValue* dict = update.Get(); | 468 base::DictionaryValue* dict = update.Get(); |
| 516 dict->Remove(extension_id, NULL); | 469 dict->Remove(extension_id, NULL); |
| 517 } | 470 } |
| 518 | 471 |
| 519 bool ExtensionPrefs::ReadPrefAsBoolean(const std::string& extension_id, | 472 bool ExtensionPrefs::ReadPrefAsBoolean(const std::string& extension_id, |
| 520 const std::string& pref_key, | 473 const std::string& pref_key, |
| 521 bool* out_value) const { | 474 bool* out_value) const { |
| 522 const base::DictionaryValue* ext = GetExtensionPref(extension_id); | 475 const base::DictionaryValue* ext = GetExtensionPref(extension_id); |
| 523 if (!ext || !ext->GetBoolean(pref_key, out_value)) | 476 if (!ext || !ext->GetBoolean(pref_key, out_value)) |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1250 | 1203 |
| 1251 // For external extensions, we save a preference reminding ourself not to try | 1204 // For external extensions, we save a preference reminding ourself not to try |
| 1252 // and install the extension anymore (except when |external_uninstall| is | 1205 // and install the extension anymore (except when |external_uninstall| is |
| 1253 // true, which signifies that the registry key was deleted or the pref file | 1206 // true, which signifies that the registry key was deleted or the pref file |
| 1254 // no longer lists the extension). | 1207 // no longer lists the extension). |
| 1255 if (!external_uninstall && Manifest::IsExternalLocation(location)) { | 1208 if (!external_uninstall && Manifest::IsExternalLocation(location)) { |
| 1256 UpdateExtensionPref(extension_id, kPrefState, | 1209 UpdateExtensionPref(extension_id, kPrefState, |
| 1257 new base::FundamentalValue( | 1210 new base::FundamentalValue( |
| 1258 Extension::EXTERNAL_EXTENSION_UNINSTALLED)); | 1211 Extension::EXTERNAL_EXTENSION_UNINSTALLED)); |
| 1259 extension_pref_value_map_->SetExtensionState(extension_id, false); | 1212 extension_pref_value_map_->SetExtensionState(extension_id, false); |
| 1260 content_settings_store_->SetExtensionState(extension_id, false); | 1213 FOR_EACH_OBSERVER( |
| 1214 Observer, observer_list_, OnExtensionStateChanged(extension_id, false)); |
| 1261 } else { | 1215 } else { |
| 1262 int creation_flags = GetCreationFlags(extension_id); | 1216 int creation_flags = GetCreationFlags(extension_id); |
| 1263 if (creation_flags & Extension::IS_EPHEMERAL) { | 1217 if (creation_flags & Extension::IS_EPHEMERAL) { |
| 1264 // Keep ephemeral apps around, but mark them as evicted. | 1218 // Keep ephemeral apps around, but mark them as evicted. |
| 1265 UpdateExtensionPref(extension_id, kPrefEvictedEphemeralApp, | 1219 UpdateExtensionPref(extension_id, kPrefEvictedEphemeralApp, |
| 1266 new base::FundamentalValue(true)); | 1220 new base::FundamentalValue(true)); |
| 1267 } else { | 1221 } else { |
| 1268 DeleteExtensionPrefs(extension_id); | 1222 DeleteExtensionPrefs(extension_id); |
| 1269 } | 1223 } |
| 1270 } | 1224 } |
| 1271 } | 1225 } |
| 1272 | 1226 |
| 1273 void ExtensionPrefs::SetExtensionState(const std::string& extension_id, | 1227 void ExtensionPrefs::SetExtensionState(const std::string& extension_id, |
| 1274 Extension::State state) { | 1228 Extension::State state) { |
| 1275 UpdateExtensionPref(extension_id, kPrefState, | 1229 UpdateExtensionPref(extension_id, kPrefState, |
| 1276 new base::FundamentalValue(state)); | 1230 new base::FundamentalValue(state)); |
| 1277 bool enabled = (state == Extension::ENABLED); | 1231 bool enabled = (state == Extension::ENABLED); |
| 1278 extension_pref_value_map_->SetExtensionState(extension_id, enabled); | 1232 extension_pref_value_map_->SetExtensionState(extension_id, enabled); |
| 1279 content_settings_store_->SetExtensionState(extension_id, enabled); | 1233 FOR_EACH_OBSERVER( |
| 1234 Observer, observer_list_, OnExtensionStateChanged(extension_id, enabled)); |
| 1280 } | 1235 } |
| 1281 | 1236 |
| 1282 void ExtensionPrefs::SetExtensionBlacklistState(const std::string& extension_id, | 1237 void ExtensionPrefs::SetExtensionBlacklistState(const std::string& extension_id, |
| 1283 BlacklistState state) { | 1238 BlacklistState state) { |
| 1284 SetExtensionBlacklisted(extension_id, state == BLACKLISTED_MALWARE); | 1239 SetExtensionBlacklisted(extension_id, state == BLACKLISTED_MALWARE); |
| 1285 UpdateExtensionPref(extension_id, kPrefBlacklistState, | 1240 UpdateExtensionPref(extension_id, kPrefBlacklistState, |
| 1286 new base::FundamentalValue(state)); | 1241 new base::FundamentalValue(state)); |
| 1287 } | 1242 } |
| 1288 | 1243 |
| 1289 BlacklistState ExtensionPrefs::GetExtensionBlacklistState( | 1244 BlacklistState ExtensionPrefs::GetExtensionBlacklistState( |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1776 } | 1731 } |
| 1777 | 1732 |
| 1778 void ExtensionPrefs::AddObserver(Observer* observer) { | 1733 void ExtensionPrefs::AddObserver(Observer* observer) { |
| 1779 observer_list_.AddObserver(observer); | 1734 observer_list_.AddObserver(observer); |
| 1780 } | 1735 } |
| 1781 | 1736 |
| 1782 void ExtensionPrefs::RemoveObserver(Observer* observer) { | 1737 void ExtensionPrefs::RemoveObserver(Observer* observer) { |
| 1783 observer_list_.RemoveObserver(observer); | 1738 observer_list_.RemoveObserver(observer); |
| 1784 } | 1739 } |
| 1785 | 1740 |
| 1741 void ExtensionPrefs::Initialize() { InitPrefStore(); } |
| 1742 |
| 1786 void ExtensionPrefs::FixMissingPrefs(const ExtensionIdList& extension_ids) { | 1743 void ExtensionPrefs::FixMissingPrefs(const ExtensionIdList& extension_ids) { |
| 1787 // Fix old entries that did not get an installation time entry when they | 1744 // Fix old entries that did not get an installation time entry when they |
| 1788 // were installed or don't have a preferences field. | 1745 // were installed or don't have a preferences field. |
| 1789 for (ExtensionIdList::const_iterator ext_id = extension_ids.begin(); | 1746 for (ExtensionIdList::const_iterator ext_id = extension_ids.begin(); |
| 1790 ext_id != extension_ids.end(); ++ext_id) { | 1747 ext_id != extension_ids.end(); ++ext_id) { |
| 1791 if (GetInstallTime(*ext_id) == base::Time()) { | 1748 if (GetInstallTime(*ext_id) == base::Time()) { |
| 1792 VLOG(1) << "Could not parse installation time of extension " | 1749 VLOG(1) << "Could not parse installation time of extension " |
| 1793 << *ext_id << ". It was probably installed before setting " | 1750 << *ext_id << ". It was probably installed before setting " |
| 1794 << kPrefInstallTime << " was introduced. Updating " | 1751 << kPrefInstallTime << " was introduced. Updating " |
| 1795 << kPrefInstallTime << " to the current time."; | 1752 << kPrefInstallTime << " to the current time."; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1819 ScopedExtensionPrefUpdate update(prefs_, *ext_id); | 1776 ScopedExtensionPrefUpdate update(prefs_, *ext_id); |
| 1820 // This creates an empty dictionary if none is stored. | 1777 // This creates an empty dictionary if none is stored. |
| 1821 update.Get(); | 1778 update.Get(); |
| 1822 } | 1779 } |
| 1823 | 1780 |
| 1824 FixMissingPrefs(extension_ids); | 1781 FixMissingPrefs(extension_ids); |
| 1825 MigratePermissions(extension_ids); | 1782 MigratePermissions(extension_ids); |
| 1826 MigrateDisableReasons(extension_ids); | 1783 MigrateDisableReasons(extension_ids); |
| 1827 app_sorting_->Initialize(extension_ids); | 1784 app_sorting_->Initialize(extension_ids); |
| 1828 | 1785 |
| 1829 InitExtensionControlledPrefs(this, extension_pref_value_map_); | 1786 InitExtensionControlledPrefs(extension_pref_value_map_); |
| 1830 | 1787 |
| 1831 extension_pref_value_map_->NotifyInitializationCompleted(); | 1788 extension_pref_value_map_->NotifyInitializationCompleted(); |
| 1832 } | 1789 } |
| 1833 | 1790 |
| 1834 bool ExtensionPrefs::HasIncognitoPrefValue(const std::string& pref_key) { | 1791 bool ExtensionPrefs::HasIncognitoPrefValue(const std::string& pref_key) { |
| 1835 bool has_incognito_pref_value = false; | 1792 bool has_incognito_pref_value = false; |
| 1836 extension_pref_value_map_->GetEffectivePrefValue(pref_key, | 1793 extension_pref_value_map_->GetEffectivePrefValue(pref_key, |
| 1837 true, | 1794 true, |
| 1838 &has_incognito_pref_value); | 1795 &has_incognito_pref_value); |
| 1839 return has_incognito_pref_value; | 1796 return has_incognito_pref_value; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1918 PrefService* prefs, | 1875 PrefService* prefs, |
| 1919 const base::FilePath& root_dir, | 1876 const base::FilePath& root_dir, |
| 1920 ExtensionPrefValueMap* extension_pref_value_map, | 1877 ExtensionPrefValueMap* extension_pref_value_map, |
| 1921 scoped_ptr<AppSorting> app_sorting, | 1878 scoped_ptr<AppSorting> app_sorting, |
| 1922 scoped_ptr<TimeProvider> time_provider, | 1879 scoped_ptr<TimeProvider> time_provider, |
| 1923 bool extensions_disabled) | 1880 bool extensions_disabled) |
| 1924 : prefs_(prefs), | 1881 : prefs_(prefs), |
| 1925 install_directory_(root_dir), | 1882 install_directory_(root_dir), |
| 1926 extension_pref_value_map_(extension_pref_value_map), | 1883 extension_pref_value_map_(extension_pref_value_map), |
| 1927 app_sorting_(app_sorting.Pass()), | 1884 app_sorting_(app_sorting.Pass()), |
| 1928 content_settings_store_(new ContentSettingsStore()), | |
| 1929 time_provider_(time_provider.Pass()), | 1885 time_provider_(time_provider.Pass()), |
| 1930 extensions_disabled_(extensions_disabled) { | 1886 extensions_disabled_(extensions_disabled) { |
| 1931 app_sorting_->SetExtensionScopedPrefs(this); | 1887 app_sorting_->SetExtensionScopedPrefs(this); |
| 1932 MakePathsRelative(); | 1888 MakePathsRelative(); |
| 1933 InitPrefStore(); | |
| 1934 } | 1889 } |
| 1935 | 1890 |
| 1936 void ExtensionPrefs::SetNeedsStorageGarbageCollection(bool value) { | 1891 void ExtensionPrefs::SetNeedsStorageGarbageCollection(bool value) { |
| 1937 prefs_->SetBoolean(pref_names::kStorageGarbageCollect, value); | 1892 prefs_->SetBoolean(pref_names::kStorageGarbageCollect, value); |
| 1938 } | 1893 } |
| 1939 | 1894 |
| 1940 bool ExtensionPrefs::NeedsStorageGarbageCollection() { | 1895 bool ExtensionPrefs::NeedsStorageGarbageCollection() { |
| 1941 return prefs_->GetBoolean(pref_names::kStorageGarbageCollect); | 1896 return prefs_->GetBoolean(pref_names::kStorageGarbageCollect); |
| 1942 } | 1897 } |
| 1943 | 1898 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2084 new base::StringValue(install_parameter)); | 2039 new base::StringValue(install_parameter)); |
| 2085 } | 2040 } |
| 2086 // We store prefs about LOAD extensions, but don't cache their manifest | 2041 // We store prefs about LOAD extensions, but don't cache their manifest |
| 2087 // since it may change on disk. | 2042 // since it may change on disk. |
| 2088 if (!Manifest::IsUnpackedLocation(extension->location())) { | 2043 if (!Manifest::IsUnpackedLocation(extension->location())) { |
| 2089 extension_dict->Set(kPrefManifest, | 2044 extension_dict->Set(kPrefManifest, |
| 2090 extension->manifest()->value()->DeepCopy()); | 2045 extension->manifest()->value()->DeepCopy()); |
| 2091 } | 2046 } |
| 2092 } | 2047 } |
| 2093 | 2048 |
| 2049 void ExtensionPrefs::InitExtensionControlledPrefs( |
| 2050 ExtensionPrefValueMap* value_map) { |
| 2051 ExtensionIdList extension_ids; |
| 2052 GetExtensions(&extension_ids); |
| 2053 |
| 2054 for (ExtensionIdList::iterator extension_id = extension_ids.begin(); |
| 2055 extension_id != extension_ids.end(); |
| 2056 ++extension_id) { |
| 2057 base::Time install_time = GetInstallTime(*extension_id); |
| 2058 bool is_enabled = !IsExtensionDisabled(*extension_id); |
| 2059 bool is_incognito_enabled = IsIncognitoEnabled(*extension_id); |
| 2060 value_map->RegisterExtension( |
| 2061 *extension_id, install_time, is_enabled, is_incognito_enabled); |
| 2062 |
| 2063 FOR_EACH_OBSERVER( |
| 2064 Observer, |
| 2065 observer_list_, |
| 2066 OnExtensionRegistered(*extension_id, install_time, is_enabled)); |
| 2067 |
| 2068 // Set regular extension controlled prefs. |
| 2069 LoadExtensionControlledPrefs( |
| 2070 this, value_map, *extension_id, kExtensionPrefsScopeRegular); |
| 2071 // Set incognito extension controlled prefs. |
| 2072 LoadExtensionControlledPrefs(this, |
| 2073 value_map, |
| 2074 *extension_id, |
| 2075 kExtensionPrefsScopeIncognitoPersistent); |
| 2076 // Set regular-only extension controlled prefs. |
| 2077 LoadExtensionControlledPrefs( |
| 2078 this, value_map, *extension_id, kExtensionPrefsScopeRegularOnly); |
| 2079 |
| 2080 FOR_EACH_OBSERVER( |
| 2081 Observer, observer_list_, OnExtensionPrefsLoaded(*extension_id)); |
| 2082 } |
| 2083 } |
| 2084 |
| 2094 void ExtensionPrefs::FinishExtensionInfoPrefs( | 2085 void ExtensionPrefs::FinishExtensionInfoPrefs( |
| 2095 const std::string& extension_id, | 2086 const std::string& extension_id, |
| 2096 const base::Time install_time, | 2087 const base::Time install_time, |
| 2097 bool needs_sort_ordinal, | 2088 bool needs_sort_ordinal, |
| 2098 const syncer::StringOrdinal& suggested_page_ordinal, | 2089 const syncer::StringOrdinal& suggested_page_ordinal, |
| 2099 base::DictionaryValue* extension_dict) { | 2090 base::DictionaryValue* extension_dict) { |
| 2100 // Reinitializes various preferences with empty dictionaries. | 2091 // Reinitializes various preferences with empty dictionaries. |
| 2101 if (!extension_dict->HasKey(pref_names::kPrefPreferences)) { | 2092 if (!extension_dict->HasKey(pref_names::kPrefPreferences)) { |
| 2102 extension_dict->Set(pref_names::kPrefPreferences, | 2093 extension_dict->Set(pref_names::kPrefPreferences, |
| 2103 new base::DictionaryValue); | 2094 new base::DictionaryValue); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2125 // out of date. | 2116 // out of date. |
| 2126 extension_dict->Remove(kDelayedInstallInfo, NULL); | 2117 extension_dict->Remove(kDelayedInstallInfo, NULL); |
| 2127 | 2118 |
| 2128 // Clear state that may be registered from a previous install. | 2119 // Clear state that may be registered from a previous install. |
| 2129 extension_dict->Remove(EventRouter::kRegisteredEvents, NULL); | 2120 extension_dict->Remove(EventRouter::kRegisteredEvents, NULL); |
| 2130 | 2121 |
| 2131 // When evicted ephemeral apps are re-installed, this flag must be reset. | 2122 // When evicted ephemeral apps are re-installed, this flag must be reset. |
| 2132 extension_dict->Remove(kPrefEvictedEphemeralApp, NULL); | 2123 extension_dict->Remove(kPrefEvictedEphemeralApp, NULL); |
| 2133 | 2124 |
| 2134 // FYI, all code below here races on sudden shutdown because |extension_dict|, | 2125 // FYI, all code below here races on sudden shutdown because |extension_dict|, |
| 2135 // |app_sorting_|, |extension_pref_value_map_|, and |content_settings_store_| | 2126 // |app_sorting_|, |extension_pref_value_map_|, and (potentially) observers |
| 2136 // are updated non-transactionally. This is probably not fixable without | 2127 // are updated non-transactionally. This is probably not fixable without |
| 2137 // nested transactional updates to pref dictionaries. | 2128 // nested transactional updates to pref dictionaries. |
| 2138 if (needs_sort_ordinal) | 2129 if (needs_sort_ordinal) |
| 2139 app_sorting_->EnsureValidOrdinals(extension_id, suggested_page_ordinal); | 2130 app_sorting_->EnsureValidOrdinals(extension_id, suggested_page_ordinal); |
| 2140 | 2131 |
| 2141 bool is_enabled = false; | 2132 bool is_enabled = false; |
| 2142 int initial_state; | 2133 int initial_state; |
| 2143 if (extension_dict->GetInteger(kPrefState, &initial_state)) { | 2134 if (extension_dict->GetInteger(kPrefState, &initial_state)) { |
| 2144 is_enabled = initial_state == Extension::ENABLED; | 2135 is_enabled = initial_state == Extension::ENABLED; |
| 2145 } | 2136 } |
| 2146 bool is_incognito_enabled = IsIncognitoEnabled(extension_id); | 2137 bool is_incognito_enabled = IsIncognitoEnabled(extension_id); |
| 2147 | 2138 |
| 2148 extension_pref_value_map_->RegisterExtension( | 2139 extension_pref_value_map_->RegisterExtension( |
| 2149 extension_id, install_time, is_enabled, is_incognito_enabled); | 2140 extension_id, install_time, is_enabled, is_incognito_enabled); |
| 2150 content_settings_store_->RegisterExtension(extension_id, install_time, | 2141 |
| 2151 is_enabled); | 2142 FOR_EACH_OBSERVER( |
| 2143 Observer, |
| 2144 observer_list_, |
| 2145 OnExtensionRegistered(extension_id, install_time, is_enabled)); |
| 2152 } | 2146 } |
| 2153 | 2147 |
| 2154 } // namespace extensions | 2148 } // namespace extensions |
| OLD | NEW |