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

Side by Side Diff: chrome/browser/extensions/extension_prefs.cc

Issue 17038002: Separate the NTP app ordering from the app list app ordering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rework + fix tests Created 7 years, 4 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 unified diff | Download patch
OLDNEW
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 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 blacklist_state, extension_dict); 1172 blacklist_state, extension_dict);
1173 FinishExtensionInfoPrefs(extension->id(), install_time, 1173 FinishExtensionInfoPrefs(extension->id(), install_time,
1174 extension->RequiresSortOrdinal(), 1174 extension->RequiresSortOrdinal(),
1175 page_ordinal, extension_dict); 1175 page_ordinal, extension_dict);
1176 } 1176 }
1177 1177
1178 void ExtensionPrefs::OnExtensionUninstalled(const std::string& extension_id, 1178 void ExtensionPrefs::OnExtensionUninstalled(const std::string& extension_id,
1179 const Manifest::Location& location, 1179 const Manifest::Location& location,
1180 bool external_uninstall) { 1180 bool external_uninstall) {
1181 extension_sorting_->ClearOrdinals(extension_id); 1181 extension_sorting_->ClearOrdinals(extension_id);
1182 app_list_extension_sorting_->Erase(extension_id);
1182 1183
1183 // For external extensions, we save a preference reminding ourself not to try 1184 // For external extensions, we save a preference reminding ourself not to try
1184 // and install the extension anymore (except when |external_uninstall| is 1185 // and install the extension anymore (except when |external_uninstall| is
1185 // true, which signifies that the registry key was deleted or the pref file 1186 // true, which signifies that the registry key was deleted or the pref file
1186 // no longer lists the extension). 1187 // no longer lists the extension).
1187 if (!external_uninstall && Manifest::IsExternalLocation(location)) { 1188 if (!external_uninstall && Manifest::IsExternalLocation(location)) {
1188 UpdateExtensionPref(extension_id, kPrefState, 1189 UpdateExtensionPref(extension_id, kPrefState,
1189 new base::FundamentalValue( 1190 new base::FundamentalValue(
1190 Extension::EXTERNAL_EXTENSION_UNINSTALLED)); 1191 Extension::EXTERNAL_EXTENSION_UNINSTALLED));
1191 extension_pref_value_map_->SetExtensionState(extension_id, false); 1192 extension_pref_value_map_->SetExtensionState(extension_id, false);
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 ScopedExtensionPrefUpdate update(prefs_, *ext_id); 1625 ScopedExtensionPrefUpdate update(prefs_, *ext_id);
1625 // This creates an empty dictionary if none is stored. 1626 // This creates an empty dictionary if none is stored.
1626 update.Get(); 1627 update.Get();
1627 } 1628 }
1628 1629
1629 FixMissingPrefs(extension_ids); 1630 FixMissingPrefs(extension_ids);
1630 MigratePermissions(extension_ids); 1631 MigratePermissions(extension_ids);
1631 MigrateDisableReasons(extension_ids); 1632 MigrateDisableReasons(extension_ids);
1632 extension_sorting_->Initialize(extension_ids); 1633 extension_sorting_->Initialize(extension_ids);
1633 1634
1635 extensions::ExtensionIdList ntp_sorted_extension_ids;
1636 extension_sorting_->GetOrderedExtensionIds(&ntp_sorted_extension_ids);
1637 app_list_extension_sorting_->Initialize(extension_ids,
1638 ntp_sorted_extension_ids);
1639
1634 PreferenceAPI::InitExtensionControlledPrefs(this, extension_pref_value_map_); 1640 PreferenceAPI::InitExtensionControlledPrefs(this, extension_pref_value_map_);
1635 1641
1636 extension_pref_value_map_->NotifyInitializationCompleted(); 1642 extension_pref_value_map_->NotifyInitializationCompleted();
1637 } 1643 }
1638 1644
1639 bool ExtensionPrefs::HasIncognitoPrefValue(const std::string& pref_key) { 1645 bool ExtensionPrefs::HasIncognitoPrefValue(const std::string& pref_key) {
1640 bool has_incognito_pref_value = false; 1646 bool has_incognito_pref_value = false;
1641 extension_pref_value_map_->GetEffectivePrefValue(pref_key, 1647 extension_pref_value_map_->GetEffectivePrefValue(pref_key,
1642 true, 1648 true,
1643 &has_incognito_pref_value); 1649 &has_incognito_pref_value);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 ExtensionPrefs::ExtensionPrefs( 1693 ExtensionPrefs::ExtensionPrefs(
1688 PrefService* prefs, 1694 PrefService* prefs,
1689 const base::FilePath& root_dir, 1695 const base::FilePath& root_dir,
1690 ExtensionPrefValueMap* extension_pref_value_map, 1696 ExtensionPrefValueMap* extension_pref_value_map,
1691 scoped_ptr<TimeProvider> time_provider, 1697 scoped_ptr<TimeProvider> time_provider,
1692 bool extensions_disabled) 1698 bool extensions_disabled)
1693 : prefs_(prefs), 1699 : prefs_(prefs),
1694 install_directory_(root_dir), 1700 install_directory_(root_dir),
1695 extension_pref_value_map_(extension_pref_value_map), 1701 extension_pref_value_map_(extension_pref_value_map),
1696 extension_sorting_(new ExtensionSorting(this)), 1702 extension_sorting_(new ExtensionSorting(this)),
1703 app_list_extension_sorting_(new AppListExtensionSorting(this)),
1697 content_settings_store_(new ContentSettingsStore()), 1704 content_settings_store_(new ContentSettingsStore()),
1698 time_provider_(time_provider.Pass()), 1705 time_provider_(time_provider.Pass()),
1699 extensions_disabled_(extensions_disabled) { 1706 extensions_disabled_(extensions_disabled) {
1700 MakePathsRelative(); 1707 MakePathsRelative();
1701 InitPrefStore(); 1708 InitPrefStore();
1702 } 1709 }
1703 1710
1704 void ExtensionPrefs::SetNeedsStorageGarbageCollection(bool value) { 1711 void ExtensionPrefs::SetNeedsStorageGarbageCollection(bool value) {
1705 prefs_->SetBoolean(prefs::kExtensionStorageGarbageCollect, value); 1712 prefs_->SetBoolean(prefs::kExtensionStorageGarbageCollect, value);
1706 } 1713 }
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 is_enabled = initial_state == Extension::ENABLED; 1874 is_enabled = initial_state == Extension::ENABLED;
1868 } 1875 }
1869 1876
1870 extension_pref_value_map_->RegisterExtension(extension_id, install_time, 1877 extension_pref_value_map_->RegisterExtension(extension_id, install_time,
1871 is_enabled); 1878 is_enabled);
1872 content_settings_store_->RegisterExtension(extension_id, install_time, 1879 content_settings_store_->RegisterExtension(extension_id, install_time,
1873 is_enabled); 1880 is_enabled);
1874 } 1881 }
1875 1882
1876 } // namespace extensions 1883 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698