| 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/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "base/value_conversions.h" | 12 #include "base/value_conversions.h" |
| 13 #include "chrome/browser/extensions/admin_policy.h" | 13 #include "chrome/browser/extensions/admin_policy.h" |
| 14 #include "chrome/browser/extensions/app_list_extension_ordering.h" |
| 14 #include "chrome/browser/extensions/event_router.h" | 15 #include "chrome/browser/extensions/event_router.h" |
| 15 #include "chrome/browser/extensions/extension_pref_store.h" | 16 #include "chrome/browser/extensions/extension_pref_store.h" |
| 16 #include "chrome/browser/extensions/extension_prefs_factory.h" | 17 #include "chrome/browser/extensions/extension_prefs_factory.h" |
| 17 #include "chrome/browser/extensions/extension_sorting.h" | 18 #include "chrome/browser/extensions/extension_sorting.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/ui/host_desktop.h" | 20 #include "chrome/browser/ui/host_desktop.h" |
| 20 #include "chrome/common/chrome_notification_types.h" | 21 #include "chrome/common/chrome_notification_types.h" |
| 21 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/extensions/feature_switch.h" | 23 #include "chrome/common/extensions/feature_switch.h" |
| 23 #include "chrome/common/extensions/manifest.h" | 24 #include "chrome/common/extensions/manifest.h" |
| (...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1234 extension_dict); | 1235 extension_dict); |
| 1235 FinishExtensionInfoPrefs(extension->id(), install_time, | 1236 FinishExtensionInfoPrefs(extension->id(), install_time, |
| 1236 extension->RequiresSortOrdinal(), | 1237 extension->RequiresSortOrdinal(), |
| 1237 page_ordinal, extension_dict); | 1238 page_ordinal, extension_dict); |
| 1238 } | 1239 } |
| 1239 | 1240 |
| 1240 void ExtensionPrefs::OnExtensionUninstalled(const std::string& extension_id, | 1241 void ExtensionPrefs::OnExtensionUninstalled(const std::string& extension_id, |
| 1241 const Manifest::Location& location, | 1242 const Manifest::Location& location, |
| 1242 bool external_uninstall) { | 1243 bool external_uninstall) { |
| 1243 extension_sorting_->ClearOrdinals(extension_id); | 1244 extension_sorting_->ClearOrdinals(extension_id); |
| 1245 app_list_extension_ordering_->Erase(extension_id); |
| 1244 | 1246 |
| 1245 // For external extensions, we save a preference reminding ourself not to try | 1247 // For external extensions, we save a preference reminding ourself not to try |
| 1246 // and install the extension anymore (except when |external_uninstall| is | 1248 // and install the extension anymore (except when |external_uninstall| is |
| 1247 // true, which signifies that the registry key was deleted or the pref file | 1249 // true, which signifies that the registry key was deleted or the pref file |
| 1248 // no longer lists the extension). | 1250 // no longer lists the extension). |
| 1249 if (!external_uninstall && Manifest::IsExternalLocation(location)) { | 1251 if (!external_uninstall && Manifest::IsExternalLocation(location)) { |
| 1250 UpdateExtensionPref(extension_id, kPrefState, | 1252 UpdateExtensionPref(extension_id, kPrefState, |
| 1251 Value::CreateIntegerValue( | 1253 Value::CreateIntegerValue( |
| 1252 Extension::EXTERNAL_EXTENSION_UNINSTALLED)); | 1254 Extension::EXTERNAL_EXTENSION_UNINSTALLED)); |
| 1253 extension_pref_value_map_->SetExtensionState(extension_id, false); | 1255 extension_pref_value_map_->SetExtensionState(extension_id, false); |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1678 ext_id != extension_ids.end(); ++ext_id) { | 1680 ext_id != extension_ids.end(); ++ext_id) { |
| 1679 ScopedExtensionPrefUpdate update(prefs_, *ext_id); | 1681 ScopedExtensionPrefUpdate update(prefs_, *ext_id); |
| 1680 // This creates an empty dictionary if none is stored. | 1682 // This creates an empty dictionary if none is stored. |
| 1681 update.Get(); | 1683 update.Get(); |
| 1682 } | 1684 } |
| 1683 | 1685 |
| 1684 FixMissingPrefs(extension_ids); | 1686 FixMissingPrefs(extension_ids); |
| 1685 MigratePermissions(extension_ids); | 1687 MigratePermissions(extension_ids); |
| 1686 MigrateDisableReasons(extension_ids); | 1688 MigrateDisableReasons(extension_ids); |
| 1687 extension_sorting_->Initialize(extension_ids); | 1689 extension_sorting_->Initialize(extension_ids); |
| 1690 app_list_extension_ordering_->Initialize(extension_ids); |
| 1688 | 1691 |
| 1689 // Store extension controlled preference values in the | 1692 // Store extension controlled preference values in the |
| 1690 // |extension_pref_value_map_|, which then informs the subscribers | 1693 // |extension_pref_value_map_|, which then informs the subscribers |
| 1691 // (ExtensionPrefStores) about the winning values. | 1694 // (ExtensionPrefStores) about the winning values. |
| 1692 for (ExtensionIdList::iterator ext_id = extension_ids.begin(); | 1695 for (ExtensionIdList::iterator ext_id = extension_ids.begin(); |
| 1693 ext_id != extension_ids.end(); ++ext_id) { | 1696 ext_id != extension_ids.end(); ++ext_id) { |
| 1694 extension_pref_value_map_->RegisterExtension( | 1697 extension_pref_value_map_->RegisterExtension( |
| 1695 *ext_id, | 1698 *ext_id, |
| 1696 GetInstallTime(*ext_id), | 1699 GetInstallTime(*ext_id), |
| 1697 !IsExtensionDisabled(*ext_id)); | 1700 !IsExtensionDisabled(*ext_id)); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1883 ExtensionPrefs::ExtensionPrefs( | 1886 ExtensionPrefs::ExtensionPrefs( |
| 1884 PrefService* prefs, | 1887 PrefService* prefs, |
| 1885 const base::FilePath& root_dir, | 1888 const base::FilePath& root_dir, |
| 1886 ExtensionPrefValueMap* extension_pref_value_map, | 1889 ExtensionPrefValueMap* extension_pref_value_map, |
| 1887 scoped_ptr<TimeProvider> time_provider, | 1890 scoped_ptr<TimeProvider> time_provider, |
| 1888 bool extensions_disabled) | 1891 bool extensions_disabled) |
| 1889 : prefs_(prefs), | 1892 : prefs_(prefs), |
| 1890 install_directory_(root_dir), | 1893 install_directory_(root_dir), |
| 1891 extension_pref_value_map_(extension_pref_value_map), | 1894 extension_pref_value_map_(extension_pref_value_map), |
| 1892 extension_sorting_(new ExtensionSorting(this, prefs)), | 1895 extension_sorting_(new ExtensionSorting(this, prefs)), |
| 1896 app_list_extension_ordering_(new AppListExtensionOrdering(this)), |
| 1893 content_settings_store_(new ContentSettingsStore()), | 1897 content_settings_store_(new ContentSettingsStore()), |
| 1894 time_provider_(time_provider.Pass()), | 1898 time_provider_(time_provider.Pass()), |
| 1895 extensions_disabled_(extensions_disabled) { | 1899 extensions_disabled_(extensions_disabled) { |
| 1896 MakePathsRelative(); | 1900 MakePathsRelative(); |
| 1897 InitPrefStore(); | 1901 InitPrefStore(); |
| 1898 content_settings_store_->AddObserver(this); | 1902 content_settings_store_->AddObserver(this); |
| 1899 } | 1903 } |
| 1900 | 1904 |
| 1901 void ExtensionPrefs::SetNeedsStorageGarbageCollection(bool value) { | 1905 void ExtensionPrefs::SetNeedsStorageGarbageCollection(bool value) { |
| 1902 prefs_->SetBoolean(prefs::kExtensionStorageGarbageCollect, value); | 1906 prefs_->SetBoolean(prefs::kExtensionStorageGarbageCollect, value); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2059 is_enabled = initial_state == Extension::ENABLED; | 2063 is_enabled = initial_state == Extension::ENABLED; |
| 2060 } | 2064 } |
| 2061 | 2065 |
| 2062 extension_pref_value_map_->RegisterExtension(extension_id, install_time, | 2066 extension_pref_value_map_->RegisterExtension(extension_id, install_time, |
| 2063 is_enabled); | 2067 is_enabled); |
| 2064 content_settings_store_->RegisterExtension(extension_id, install_time, | 2068 content_settings_store_->RegisterExtension(extension_id, install_time, |
| 2065 is_enabled); | 2069 is_enabled); |
| 2066 } | 2070 } |
| 2067 | 2071 |
| 2068 } // namespace extensions | 2072 } // namespace extensions |
| OLD | NEW |