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/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/extensions/api/alarms/alarm_manager.h" | 10 #include "chrome/browser/extensions/api/alarms/alarm_manager.h" |
11 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" | 11 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" |
12 #include "chrome/browser/extensions/extension_pref_store.h" | 12 #include "chrome/browser/extensions/extension_pref_store.h" |
13 #include "chrome/browser/extensions/extension_sorting.h" | 13 #include "chrome/browser/extensions/extension_sorting.h" |
14 #include "chrome/browser/prefs/pref_notifier.h" | 14 #include "chrome/browser/prefs/pref_notifier.h" |
15 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
16 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 16 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
17 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
18 #include "chrome/common/extensions/extension_switch_utils.h" | 18 #include "chrome/common/extensions/extension_switch_utils.h" |
19 #include "chrome/common/extensions/manifest.h" | 19 #include "chrome/common/extensions/manifest.h" |
20 #include "chrome/common/extensions/url_pattern.h" | 20 #include "chrome/common/extensions/url_pattern.h" |
21 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
22 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
23 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
24 | 24 |
| 25 using extensions::Extension; |
| 26 using extensions::ExtensionInfo; |
| 27 |
25 namespace { | 28 namespace { |
26 | 29 |
27 // Additional preferences keys | 30 // Additional preferences keys |
28 | 31 |
29 // Where an extension was installed from. (see Extension::Location) | 32 // Where an extension was installed from. (see Extension::Location) |
30 const char kPrefLocation[] = "location"; | 33 const char kPrefLocation[] = "location"; |
31 | 34 |
32 // Enabled, disabled, killed, etc. (see Extension::State) | 35 // Enabled, disabled, killed, etc. (see Extension::State) |
33 const char kPrefState[] = "state"; | 36 const char kPrefState[] = "state"; |
34 | 37 |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 } | 851 } |
849 | 852 |
850 void ExtensionPrefs::SetActiveBit(const std::string& extension_id, | 853 void ExtensionPrefs::SetActiveBit(const std::string& extension_id, |
851 bool active) { | 854 bool active) { |
852 UpdateExtensionPref(extension_id, kActiveBit, | 855 UpdateExtensionPref(extension_id, kActiveBit, |
853 Value::CreateBooleanValue(active)); | 856 Value::CreateBooleanValue(active)); |
854 } | 857 } |
855 | 858 |
856 void ExtensionPrefs::MigratePermissions(const ExtensionIdSet& extension_ids) { | 859 void ExtensionPrefs::MigratePermissions(const ExtensionIdSet& extension_ids) { |
857 ExtensionPermissionsInfo* info = ExtensionPermissionsInfo::GetInstance(); | 860 ExtensionPermissionsInfo* info = ExtensionPermissionsInfo::GetInstance(); |
858 for (ExtensionIdSet::const_iterator ext_id = extension_ids.begin(); | 861 for (ExtensionIdSet::const_iterator ext_id = |
859 ext_id != extension_ids.end(); ++ext_id) { | 862 extension_ids.begin(); ext_id != extension_ids.end(); ++ext_id) { |
860 | 863 |
861 // An extension's granted permissions need to be migrated if the | 864 // An extension's granted permissions need to be migrated if the |
862 // full_access bit is present. This bit was always present in the previous | 865 // full_access bit is present. This bit was always present in the previous |
863 // scheme and is never present now. | 866 // scheme and is never present now. |
864 bool full_access; | 867 bool full_access; |
865 const DictionaryValue* ext = GetExtensionPref(*ext_id); | 868 const DictionaryValue* ext = GetExtensionPref(*ext_id); |
866 if (!ext || !ext->GetBoolean(kPrefOldGrantedFullAccess, &full_access)) | 869 if (!ext || !ext->GetBoolean(kPrefOldGrantedFullAccess, &full_access)) |
867 continue; | 870 continue; |
868 | 871 |
869 // Remove the full access bit (empty list will get trimmed). | 872 // Remove the full access bit (empty list will get trimmed). |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 const std::string& id) const { | 1162 const std::string& id) const { |
1160 return DoesExtensionHaveState(id, Extension::EXTERNAL_EXTENSION_UNINSTALLED); | 1163 return DoesExtensionHaveState(id, Extension::EXTERNAL_EXTENSION_UNINSTALLED); |
1161 } | 1164 } |
1162 | 1165 |
1163 bool ExtensionPrefs::IsExtensionDisabled( | 1166 bool ExtensionPrefs::IsExtensionDisabled( |
1164 const std::string& id) const { | 1167 const std::string& id) const { |
1165 return DoesExtensionHaveState(id, Extension::DISABLED); | 1168 return DoesExtensionHaveState(id, Extension::DISABLED); |
1166 } | 1169 } |
1167 | 1170 |
1168 std::vector<std::string> ExtensionPrefs::GetToolbarOrder() { | 1171 std::vector<std::string> ExtensionPrefs::GetToolbarOrder() { |
1169 ExtensionPrefs::ExtensionIdSet extension_ids; | 1172 ExtensionIdSet extension_ids; |
1170 const ListValue* toolbar_order = prefs_->GetList(kExtensionToolbar); | 1173 const ListValue* toolbar_order = prefs_->GetList(kExtensionToolbar); |
1171 if (toolbar_order) { | 1174 if (toolbar_order) { |
1172 for (size_t i = 0; i < toolbar_order->GetSize(); ++i) { | 1175 for (size_t i = 0; i < toolbar_order->GetSize(); ++i) { |
1173 std::string extension_id; | 1176 std::string extension_id; |
1174 if (toolbar_order->GetString(i, &extension_id)) | 1177 if (toolbar_order->GetString(i, &extension_id)) |
1175 extension_ids.push_back(extension_id); | 1178 extension_ids.push_back(extension_id); |
1176 } | 1179 } |
1177 } | 1180 } |
1178 return extension_ids; | 1181 return extension_ids; |
1179 } | 1182 } |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1909 prefs->RegisterStringPref(prefs::kExtensionBlacklistUpdateVersion, | 1912 prefs->RegisterStringPref(prefs::kExtensionBlacklistUpdateVersion, |
1910 "0", // default value | 1913 "0", // default value |
1911 PrefService::UNSYNCABLE_PREF); | 1914 PrefService::UNSYNCABLE_PREF); |
1912 prefs->RegisterInt64Pref(prefs::kLastExtensionsUpdateCheck, | 1915 prefs->RegisterInt64Pref(prefs::kLastExtensionsUpdateCheck, |
1913 0, // default value | 1916 0, // default value |
1914 PrefService::UNSYNCABLE_PREF); | 1917 PrefService::UNSYNCABLE_PREF); |
1915 prefs->RegisterInt64Pref(prefs::kNextExtensionsUpdateCheck, | 1918 prefs->RegisterInt64Pref(prefs::kNextExtensionsUpdateCheck, |
1916 0, // default value | 1919 0, // default value |
1917 PrefService::UNSYNCABLE_PREF); | 1920 PrefService::UNSYNCABLE_PREF); |
1918 } | 1921 } |
OLD | NEW |