| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/extensions/extension_prefs.h" | 5 #include "chrome/browser/extensions/extension_prefs.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_notifier.h" | 7 #include "base/prefs/pref_notifier.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1173 extension_dict); | 1173 extension_dict); |
| 1174 FinishExtensionInfoPrefs(extension->id(), install_time, | 1174 FinishExtensionInfoPrefs(extension->id(), install_time, |
| 1175 extension->RequiresSortOrdinal(), | 1175 extension->RequiresSortOrdinal(), |
| 1176 page_ordinal, extension_dict); | 1176 page_ordinal, extension_dict); |
| 1177 } | 1177 } |
| 1178 | 1178 |
| 1179 void ExtensionPrefs::OnExtensionUninstalled(const std::string& extension_id, | 1179 void ExtensionPrefs::OnExtensionUninstalled(const std::string& extension_id, |
| 1180 const Manifest::Location& location, | 1180 const Manifest::Location& location, |
| 1181 bool external_uninstall) { | 1181 bool external_uninstall) { |
| 1182 extension_sorting_->ClearOrdinals(extension_id); | 1182 extension_sorting_->ClearOrdinals(extension_id); |
| 1183 app_list_extension_sorting_->Erase(extension_id); |
| 1183 | 1184 |
| 1184 // For external extensions, we save a preference reminding ourself not to try | 1185 // For external extensions, we save a preference reminding ourself not to try |
| 1185 // and install the extension anymore (except when |external_uninstall| is | 1186 // and install the extension anymore (except when |external_uninstall| is |
| 1186 // true, which signifies that the registry key was deleted or the pref file | 1187 // true, which signifies that the registry key was deleted or the pref file |
| 1187 // no longer lists the extension). | 1188 // no longer lists the extension). |
| 1188 if (!external_uninstall && Manifest::IsExternalLocation(location)) { | 1189 if (!external_uninstall && Manifest::IsExternalLocation(location)) { |
| 1189 UpdateExtensionPref(extension_id, kPrefState, | 1190 UpdateExtensionPref(extension_id, kPrefState, |
| 1190 Value::CreateIntegerValue( | 1191 Value::CreateIntegerValue( |
| 1191 Extension::EXTERNAL_EXTENSION_UNINSTALLED)); | 1192 Extension::EXTERNAL_EXTENSION_UNINSTALLED)); |
| 1192 extension_pref_value_map_->SetExtensionState(extension_id, false); | 1193 extension_pref_value_map_->SetExtensionState(extension_id, false); |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1598 ext_id != extension_ids.end(); ++ext_id) { | 1599 ext_id != extension_ids.end(); ++ext_id) { |
| 1599 ScopedExtensionPrefUpdate update(prefs_, *ext_id); | 1600 ScopedExtensionPrefUpdate update(prefs_, *ext_id); |
| 1600 // This creates an empty dictionary if none is stored. | 1601 // This creates an empty dictionary if none is stored. |
| 1601 update.Get(); | 1602 update.Get(); |
| 1602 } | 1603 } |
| 1603 | 1604 |
| 1604 FixMissingPrefs(extension_ids); | 1605 FixMissingPrefs(extension_ids); |
| 1605 MigratePermissions(extension_ids); | 1606 MigratePermissions(extension_ids); |
| 1606 MigrateDisableReasons(extension_ids); | 1607 MigrateDisableReasons(extension_ids); |
| 1607 extension_sorting_->Initialize(extension_ids); | 1608 extension_sorting_->Initialize(extension_ids); |
| 1609 app_list_extension_sorting_->Initialize(extension_ids); |
| 1608 | 1610 |
| 1609 PreferenceAPI::InitExtensionControlledPrefs(this, extension_pref_value_map_); | 1611 PreferenceAPI::InitExtensionControlledPrefs(this, extension_pref_value_map_); |
| 1610 | 1612 |
| 1611 extension_pref_value_map_->NotifyInitializationCompleted(); | 1613 extension_pref_value_map_->NotifyInitializationCompleted(); |
| 1612 } | 1614 } |
| 1613 | 1615 |
| 1614 bool ExtensionPrefs::HasIncognitoPrefValue(const std::string& pref_key) { | 1616 bool ExtensionPrefs::HasIncognitoPrefValue(const std::string& pref_key) { |
| 1615 bool has_incognito_pref_value = false; | 1617 bool has_incognito_pref_value = false; |
| 1616 extension_pref_value_map_->GetEffectivePrefValue(pref_key, | 1618 extension_pref_value_map_->GetEffectivePrefValue(pref_key, |
| 1617 true, | 1619 true, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1681 ExtensionPrefs::ExtensionPrefs( | 1683 ExtensionPrefs::ExtensionPrefs( |
| 1682 PrefService* prefs, | 1684 PrefService* prefs, |
| 1683 const base::FilePath& root_dir, | 1685 const base::FilePath& root_dir, |
| 1684 ExtensionPrefValueMap* extension_pref_value_map, | 1686 ExtensionPrefValueMap* extension_pref_value_map, |
| 1685 scoped_ptr<TimeProvider> time_provider, | 1687 scoped_ptr<TimeProvider> time_provider, |
| 1686 bool extensions_disabled) | 1688 bool extensions_disabled) |
| 1687 : prefs_(prefs), | 1689 : prefs_(prefs), |
| 1688 install_directory_(root_dir), | 1690 install_directory_(root_dir), |
| 1689 extension_pref_value_map_(extension_pref_value_map), | 1691 extension_pref_value_map_(extension_pref_value_map), |
| 1690 extension_sorting_(new ExtensionSorting(this)), | 1692 extension_sorting_(new ExtensionSorting(this)), |
| 1693 app_list_extension_sorting_(new AppListExtensionSorting(this)), |
| 1691 content_settings_store_(new ContentSettingsStore()), | 1694 content_settings_store_(new ContentSettingsStore()), |
| 1692 time_provider_(time_provider.Pass()), | 1695 time_provider_(time_provider.Pass()), |
| 1693 extensions_disabled_(extensions_disabled) { | 1696 extensions_disabled_(extensions_disabled) { |
| 1694 MakePathsRelative(); | 1697 MakePathsRelative(); |
| 1695 InitPrefStore(); | 1698 InitPrefStore(); |
| 1696 } | 1699 } |
| 1697 | 1700 |
| 1698 void ExtensionPrefs::SetNeedsStorageGarbageCollection(bool value) { | 1701 void ExtensionPrefs::SetNeedsStorageGarbageCollection(bool value) { |
| 1699 prefs_->SetBoolean(prefs::kExtensionStorageGarbageCollect, value); | 1702 prefs_->SetBoolean(prefs::kExtensionStorageGarbageCollect, value); |
| 1700 } | 1703 } |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1858 is_enabled = initial_state == Extension::ENABLED; | 1861 is_enabled = initial_state == Extension::ENABLED; |
| 1859 } | 1862 } |
| 1860 | 1863 |
| 1861 extension_pref_value_map_->RegisterExtension(extension_id, install_time, | 1864 extension_pref_value_map_->RegisterExtension(extension_id, install_time, |
| 1862 is_enabled); | 1865 is_enabled); |
| 1863 content_settings_store_->RegisterExtension(extension_id, install_time, | 1866 content_settings_store_->RegisterExtension(extension_id, install_time, |
| 1864 is_enabled); | 1867 is_enabled); |
| 1865 } | 1868 } |
| 1866 | 1869 |
| 1867 } // namespace extensions | 1870 } // namespace extensions |
| OLD | NEW |