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

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

Issue 1594553004: Extensions: remove DeprecatedDisableReason (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « extensions/browser/extension_prefs.h ('k') | extensions/common/extension.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <iterator> 10 #include <iterator>
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 const char kPrefAcknowledgePromptCount[] = "ack_prompt_count"; 74 const char kPrefAcknowledgePromptCount[] = "ack_prompt_count";
75 75
76 // Indicates whether the user has acknowledged various types of extensions. 76 // Indicates whether the user has acknowledged various types of extensions.
77 const char kPrefExternalAcknowledged[] = "ack_external"; 77 const char kPrefExternalAcknowledged[] = "ack_external";
78 const char kPrefBlacklistAcknowledged[] = "ack_blacklist"; 78 const char kPrefBlacklistAcknowledged[] = "ack_blacklist";
79 79
80 // Indicates whether the external extension was installed during the first 80 // Indicates whether the external extension was installed during the first
81 // run of this profile. 81 // run of this profile.
82 const char kPrefExternalInstallFirstRun[] = "external_first_run"; 82 const char kPrefExternalInstallFirstRun[] = "external_first_run";
83 83
84 // DO NOT USE, use kPrefDisableReasons instead.
85 // Indicates whether the extension was updated while it was disabled.
86 const char kDeprecatedPrefDisableReason[] = "disable_reason";
87
88 // A bitmask of all the reasons an extension is disabled. 84 // A bitmask of all the reasons an extension is disabled.
89 const char kPrefDisableReasons[] = "disable_reasons"; 85 const char kPrefDisableReasons[] = "disable_reasons";
90 86
91 // The key for a serialized Time value indicating the start of the day (from the 87 // The key for a serialized Time value indicating the start of the day (from the
92 // server's perspective) an extension last included a "ping" parameter during 88 // server's perspective) an extension last included a "ping" parameter during
93 // its update check. 89 // its update check.
94 const char kLastPingDay[] = "lastpingday"; 90 const char kLastPingDay[] = "lastpingday";
95 91
96 // Similar to kLastPingDay, but for "active" instead of "rollcall" pings. 92 // Similar to kLastPingDay, but for "active" instead of "rollcall" pings.
97 const char kLastActivePingDay[] = "last_active_pingday"; 93 const char kLastActivePingDay[] = "last_active_pingday";
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 if (ext->GetList(kPrefOldGrantedHosts, &hosts)) { 987 if (ext->GetList(kPrefOldGrantedHosts, &hosts)) {
992 UpdateExtensionPref( 988 UpdateExtensionPref(
993 *ext_id, explicit_hosts, hosts->DeepCopy()); 989 *ext_id, explicit_hosts, hosts->DeepCopy());
994 990
995 // We can get rid of the old one by setting it to an empty list. 991 // We can get rid of the old one by setting it to an empty list.
996 UpdateExtensionPref(*ext_id, kPrefOldGrantedHosts, new base::ListValue()); 992 UpdateExtensionPref(*ext_id, kPrefOldGrantedHosts, new base::ListValue());
997 } 993 }
998 } 994 }
999 } 995 }
1000 996
1001 void ExtensionPrefs::MigrateDisableReasons(
1002 const ExtensionIdList& extension_ids) {
1003 for (ExtensionIdList::const_iterator ext_id =
1004 extension_ids.begin(); ext_id != extension_ids.end(); ++ext_id) {
1005 int value = -1;
1006 if (ReadPrefAsInteger(*ext_id, kDeprecatedPrefDisableReason, &value)) {
1007 int new_value = Extension::DISABLE_NONE;
1008 switch (value) {
1009 case Extension::DEPRECATED_DISABLE_USER_ACTION:
1010 new_value = Extension::DISABLE_USER_ACTION;
1011 break;
1012 case Extension::DEPRECATED_DISABLE_PERMISSIONS_INCREASE:
1013 new_value = Extension::DISABLE_PERMISSIONS_INCREASE;
1014 break;
1015 case Extension::DEPRECATED_DISABLE_RELOAD:
1016 new_value = Extension::DISABLE_RELOAD;
1017 break;
1018 }
1019
1020 UpdateExtensionPref(*ext_id, kPrefDisableReasons,
1021 new base::FundamentalValue(new_value));
1022 // Remove the old disable reason.
1023 UpdateExtensionPref(*ext_id, kDeprecatedPrefDisableReason, NULL);
1024 }
1025 }
1026 }
1027
1028 scoped_ptr<const PermissionSet> ExtensionPrefs::GetGrantedPermissions( 997 scoped_ptr<const PermissionSet> ExtensionPrefs::GetGrantedPermissions(
1029 const std::string& extension_id) const { 998 const std::string& extension_id) const {
1030 CHECK(crx_file::id_util::IdIsValid(extension_id)); 999 CHECK(crx_file::id_util::IdIsValid(extension_id));
1031 return ReadPrefAsPermissionSet(extension_id, kPrefGrantedPermissions); 1000 return ReadPrefAsPermissionSet(extension_id, kPrefGrantedPermissions);
1032 } 1001 }
1033 1002
1034 void ExtensionPrefs::AddGrantedPermissions(const std::string& extension_id, 1003 void ExtensionPrefs::AddGrantedPermissions(const std::string& extension_id,
1035 const PermissionSet& permissions) { 1004 const PermissionSet& permissions) {
1036 CHECK(crx_file::id_util::IdIsValid(extension_id)); 1005 CHECK(crx_file::id_util::IdIsValid(extension_id));
1037 scoped_ptr<const PermissionSet> granted = GetGrantedPermissions(extension_id); 1006 scoped_ptr<const PermissionSet> granted = GetGrantedPermissions(extension_id);
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 // are pruned when persisting the preferences to disk). 1701 // are pruned when persisting the preferences to disk).
1733 for (ExtensionIdList::iterator ext_id = extension_ids.begin(); 1702 for (ExtensionIdList::iterator ext_id = extension_ids.begin();
1734 ext_id != extension_ids.end(); ++ext_id) { 1703 ext_id != extension_ids.end(); ++ext_id) {
1735 ScopedExtensionPrefUpdate update(prefs_, *ext_id); 1704 ScopedExtensionPrefUpdate update(prefs_, *ext_id);
1736 // This creates an empty dictionary if none is stored. 1705 // This creates an empty dictionary if none is stored.
1737 update.Get(); 1706 update.Get();
1738 } 1707 }
1739 1708
1740 FixMissingPrefs(extension_ids); 1709 FixMissingPrefs(extension_ids);
1741 MigratePermissions(extension_ids); 1710 MigratePermissions(extension_ids);
1742 MigrateDisableReasons(extension_ids);
1743 1711
1744 InitExtensionControlledPrefs(extension_pref_value_map_); 1712 InitExtensionControlledPrefs(extension_pref_value_map_);
1745 1713
1746 extension_pref_value_map_->NotifyInitializationCompleted(); 1714 extension_pref_value_map_->NotifyInitializationCompleted();
1747 } 1715 }
1748 1716
1749 bool ExtensionPrefs::HasIncognitoPrefValue(const std::string& pref_key) const { 1717 bool ExtensionPrefs::HasIncognitoPrefValue(const std::string& pref_key) const {
1750 bool has_incognito_pref_value = false; 1718 bool has_incognito_pref_value = false;
1751 extension_pref_value_map_->GetEffectivePrefValue(pref_key, 1719 extension_pref_value_map_->GetEffectivePrefValue(pref_key,
1752 true, 1720 true,
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
2076 extension_pref_value_map_->RegisterExtension( 2044 extension_pref_value_map_->RegisterExtension(
2077 extension_id, install_time, is_enabled, is_incognito_enabled); 2045 extension_id, install_time, is_enabled, is_incognito_enabled);
2078 2046
2079 FOR_EACH_OBSERVER( 2047 FOR_EACH_OBSERVER(
2080 ExtensionPrefsObserver, 2048 ExtensionPrefsObserver,
2081 observer_list_, 2049 observer_list_,
2082 OnExtensionRegistered(extension_id, install_time, is_enabled)); 2050 OnExtensionRegistered(extension_id, install_time, is_enabled));
2083 } 2051 }
2084 2052
2085 } // namespace extensions 2053 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/extension_prefs.h ('k') | extensions/common/extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698