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

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

Issue 83023010: Remove ExtensionPrefs's dependency on ChromeAppSorting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: change a LOG(INFO) that i know nothing about to a VLOG(1) Created 7 years, 1 month 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 | Annotate | Revision Log
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 <iterator> 7 #include <iterator>
8 8
9 #include "base/prefs/pref_notifier.h" 9 #include "base/prefs/pref_notifier.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/value_conversions.h" 13 #include "base/value_conversions.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/extensions/api/content_settings/content_settings_store. h" 15 #include "chrome/browser/extensions/api/content_settings/content_settings_store. h"
16 #include "chrome/browser/extensions/api/preference/preference_api.h" 16 #include "chrome/browser/extensions/api/preference/preference_api.h"
17 #include "chrome/browser/extensions/chrome_app_sorting.h"
18 #include "chrome/browser/extensions/extension_pref_store.h" 17 #include "chrome/browser/extensions/extension_pref_store.h"
19 #include "chrome/browser/extensions/extension_prefs_factory.h" 18 #include "chrome/browser/extensions/extension_prefs_factory.h"
20 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/ui/host_desktop.h" 20 #include "chrome/browser/ui/host_desktop.h"
22 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
23 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 22 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
24 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
25 #include "chrome/common/url_constants.h" 24 #include "chrome/common/url_constants.h"
26 #include "components/user_prefs/pref_registry_syncable.h" 25 #include "components/user_prefs/pref_registry_syncable.h"
27 #include "content/public/browser/notification_service.h" 26 #include "content/public/browser/notification_service.h"
28 #include "extensions/browser/admin_policy.h" 27 #include "extensions/browser/admin_policy.h"
28 #include "extensions/browser/app_sorting.h"
29 #include "extensions/browser/event_router.h" 29 #include "extensions/browser/event_router.h"
30 #include "extensions/browser/pref_names.h" 30 #include "extensions/browser/pref_names.h"
31 #include "extensions/common/feature_switch.h" 31 #include "extensions/common/feature_switch.h"
32 #include "extensions/common/manifest.h" 32 #include "extensions/common/manifest.h"
33 #include "extensions/common/permissions/permission_set.h" 33 #include "extensions/common/permissions/permission_set.h"
34 #include "extensions/common/permissions/permissions_info.h" 34 #include "extensions/common/permissions/permissions_info.h"
35 #include "extensions/common/url_pattern.h" 35 #include "extensions/common/url_pattern.h"
36 #include "extensions/common/user_script.h" 36 #include "extensions/common/user_script.h"
37 #include "grit/generated_resources.h" 37 #include "grit/generated_resources.h"
38 #include "ui/base/l10n/l10n_util.h" 38 #include "ui/base/l10n/l10n_util.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 310
311 // 311 //
312 // ExtensionPrefs 312 // ExtensionPrefs
313 // 313 //
314 314
315 // static 315 // static
316 ExtensionPrefs* ExtensionPrefs::Create( 316 ExtensionPrefs* ExtensionPrefs::Create(
317 PrefService* prefs, 317 PrefService* prefs,
318 const base::FilePath& root_dir, 318 const base::FilePath& root_dir,
319 ExtensionPrefValueMap* extension_pref_value_map, 319 ExtensionPrefValueMap* extension_pref_value_map,
320 scoped_ptr<AppSorting> app_sorting,
320 bool extensions_disabled) { 321 bool extensions_disabled) {
321 return ExtensionPrefs::Create(prefs, 322 return ExtensionPrefs::Create(prefs,
322 root_dir, 323 root_dir,
323 extension_pref_value_map, 324 extension_pref_value_map,
325 app_sorting.Pass(),
324 extensions_disabled, 326 extensions_disabled,
325 make_scoped_ptr(new TimeProvider())); 327 make_scoped_ptr(new TimeProvider()));
326 } 328 }
327 329
328 // static 330 // static
329 ExtensionPrefs* ExtensionPrefs::Create( 331 ExtensionPrefs* ExtensionPrefs::Create(
330 PrefService* pref_service, 332 PrefService* pref_service,
331 const base::FilePath& root_dir, 333 const base::FilePath& root_dir,
332 ExtensionPrefValueMap* extension_pref_value_map, 334 ExtensionPrefValueMap* extension_pref_value_map,
335 scoped_ptr<AppSorting> app_sorting,
333 bool extensions_disabled, 336 bool extensions_disabled,
334 scoped_ptr<TimeProvider> time_provider) { 337 scoped_ptr<TimeProvider> time_provider) {
335 scoped_ptr<ExtensionPrefs> prefs( 338 return new ExtensionPrefs(pref_service,
336 new ExtensionPrefs(pref_service, 339 root_dir,
337 root_dir, 340 extension_pref_value_map,
338 extension_pref_value_map, 341 app_sorting.Pass(),
339 time_provider.Pass(), 342 time_provider.Pass(),
340 extensions_disabled)); 343 extensions_disabled);
341 return prefs.release();
342 } 344 }
343 345
344 ExtensionPrefs::~ExtensionPrefs() { 346 ExtensionPrefs::~ExtensionPrefs() {
345 } 347 }
346 348
347 // static 349 // static
348 ExtensionPrefs* ExtensionPrefs::Get(Profile* profile) { 350 ExtensionPrefs* ExtensionPrefs::Get(Profile* profile) {
349 return ExtensionPrefsFactory::GetInstance()->GetForProfile(profile); 351 return ExtensionPrefsFactory::GetInstance()->GetForProfile(profile);
350 } 352 }
351 353
(...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 } 1662 }
1661 return result; 1663 return result;
1662 } 1664 }
1663 1665
1664 void ExtensionPrefs::FixMissingPrefs(const ExtensionIdList& extension_ids) { 1666 void ExtensionPrefs::FixMissingPrefs(const ExtensionIdList& extension_ids) {
1665 // Fix old entries that did not get an installation time entry when they 1667 // Fix old entries that did not get an installation time entry when they
1666 // were installed or don't have a preferences field. 1668 // were installed or don't have a preferences field.
1667 for (ExtensionIdList::const_iterator ext_id = extension_ids.begin(); 1669 for (ExtensionIdList::const_iterator ext_id = extension_ids.begin();
1668 ext_id != extension_ids.end(); ++ext_id) { 1670 ext_id != extension_ids.end(); ++ext_id) {
1669 if (GetInstallTime(*ext_id) == base::Time()) { 1671 if (GetInstallTime(*ext_id) == base::Time()) {
1670 LOG(INFO) << "Could not parse installation time of extension " 1672 VLOG(1) << "Could not parse installation time of extension "
1671 << *ext_id << ". It was probably installed before setting " 1673 << *ext_id << ". It was probably installed before setting "
1672 << kPrefInstallTime << " was introduced. Updating " 1674 << kPrefInstallTime << " was introduced. Updating "
1673 << kPrefInstallTime << " to the current time."; 1675 << kPrefInstallTime << " to the current time.";
1674 const base::Time install_time = time_provider_->GetCurrentTime(); 1676 const base::Time install_time = time_provider_->GetCurrentTime();
1675 UpdateExtensionPref(*ext_id, 1677 UpdateExtensionPref(*ext_id,
1676 kPrefInstallTime, 1678 kPrefInstallTime,
1677 new base::StringValue(base::Int64ToString( 1679 new base::StringValue(base::Int64ToString(
1678 install_time.ToInternalValue()))); 1680 install_time.ToInternalValue())));
1679 } 1681 }
1680 } 1682 }
1681 } 1683 }
1682 1684
1683 void ExtensionPrefs::InitPrefStore() { 1685 void ExtensionPrefs::InitPrefStore() {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 DVLOG(1) << "SetInstallSignature - clearing"; 1771 DVLOG(1) << "SetInstallSignature - clearing";
1770 prefs_->ClearPref(kInstallSignature); 1772 prefs_->ClearPref(kInstallSignature);
1771 } 1773 }
1772 } 1774 }
1773 1775
1774 1776
1775 ExtensionPrefs::ExtensionPrefs( 1777 ExtensionPrefs::ExtensionPrefs(
1776 PrefService* prefs, 1778 PrefService* prefs,
1777 const base::FilePath& root_dir, 1779 const base::FilePath& root_dir,
1778 ExtensionPrefValueMap* extension_pref_value_map, 1780 ExtensionPrefValueMap* extension_pref_value_map,
1781 scoped_ptr<AppSorting> app_sorting,
1779 scoped_ptr<TimeProvider> time_provider, 1782 scoped_ptr<TimeProvider> time_provider,
1780 bool extensions_disabled) 1783 bool extensions_disabled)
1781 : prefs_(prefs), 1784 : prefs_(prefs),
1782 install_directory_(root_dir), 1785 install_directory_(root_dir),
1783 extension_pref_value_map_(extension_pref_value_map), 1786 extension_pref_value_map_(extension_pref_value_map),
1784 app_sorting_(new ChromeAppSorting(this)), 1787 app_sorting_(app_sorting.Pass()),
1785 content_settings_store_(new ContentSettingsStore()), 1788 content_settings_store_(new ContentSettingsStore()),
1786 time_provider_(time_provider.Pass()), 1789 time_provider_(time_provider.Pass()),
1787 extensions_disabled_(extensions_disabled) { 1790 extensions_disabled_(extensions_disabled) {
1791 app_sorting_->SetExtensionScopedPrefs(this),
1788 MakePathsRelative(); 1792 MakePathsRelative();
1789 InitPrefStore(); 1793 InitPrefStore();
1790 } 1794 }
1791 1795
1792 void ExtensionPrefs::SetNeedsStorageGarbageCollection(bool value) { 1796 void ExtensionPrefs::SetNeedsStorageGarbageCollection(bool value) {
1793 prefs_->SetBoolean(prefs::kExtensionStorageGarbageCollect, value); 1797 prefs_->SetBoolean(prefs::kExtensionStorageGarbageCollect, value);
1794 } 1798 }
1795 1799
1796 bool ExtensionPrefs::NeedsStorageGarbageCollection() { 1800 bool ExtensionPrefs::NeedsStorageGarbageCollection() {
1797 return prefs_->GetBoolean(prefs::kExtensionStorageGarbageCollect); 1801 return prefs_->GetBoolean(prefs::kExtensionStorageGarbageCollect);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 is_enabled = initial_state == Extension::ENABLED; 1980 is_enabled = initial_state == Extension::ENABLED;
1977 } 1981 }
1978 1982
1979 extension_pref_value_map_->RegisterExtension(extension_id, install_time, 1983 extension_pref_value_map_->RegisterExtension(extension_id, install_time,
1980 is_enabled); 1984 is_enabled);
1981 content_settings_store_->RegisterExtension(extension_id, install_time, 1985 content_settings_store_->RegisterExtension(extension_id, install_time,
1982 is_enabled); 1986 is_enabled);
1983 } 1987 }
1984 1988
1985 } // namespace extensions 1989 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs.h ('k') | chrome/browser/extensions/extension_prefs_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698