| 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/manifest.h" | 18 #include "chrome/common/extensions/manifest.h" |
| 19 #include "chrome/common/extensions/url_pattern.h" | 19 #include "chrome/common/extensions/url_pattern.h" |
| 20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 21 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
| 22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 23 | 23 |
| 24 using extensions::Extension; |
| 25 using extensions::ExtensionInfo; |
| 26 |
| 24 namespace { | 27 namespace { |
| 25 | 28 |
| 26 // Additional preferences keys | 29 // Additional preferences keys |
| 27 | 30 |
| 28 // Where an extension was installed from. (see Extension::Location) | 31 // Where an extension was installed from. (see Extension::Location) |
| 29 const char kPrefLocation[] = "location"; | 32 const char kPrefLocation[] = "location"; |
| 30 | 33 |
| 31 // Enabled, disabled, killed, etc. (see Extension::State) | 34 // Enabled, disabled, killed, etc. (see Extension::State) |
| 32 const char kPrefState[] = "state"; | 35 const char kPrefState[] = "state"; |
| 33 | 36 |
| (...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 } | 846 } |
| 844 | 847 |
| 845 void ExtensionPrefs::SetActiveBit(const std::string& extension_id, | 848 void ExtensionPrefs::SetActiveBit(const std::string& extension_id, |
| 846 bool active) { | 849 bool active) { |
| 847 UpdateExtensionPref(extension_id, kActiveBit, | 850 UpdateExtensionPref(extension_id, kActiveBit, |
| 848 Value::CreateBooleanValue(active)); | 851 Value::CreateBooleanValue(active)); |
| 849 } | 852 } |
| 850 | 853 |
| 851 void ExtensionPrefs::MigratePermissions(const ExtensionIdSet& extension_ids) { | 854 void ExtensionPrefs::MigratePermissions(const ExtensionIdSet& extension_ids) { |
| 852 ExtensionPermissionsInfo* info = ExtensionPermissionsInfo::GetInstance(); | 855 ExtensionPermissionsInfo* info = ExtensionPermissionsInfo::GetInstance(); |
| 853 for (ExtensionIdSet::const_iterator ext_id = extension_ids.begin(); | 856 for (ExtensionIdSet::const_iterator ext_id = |
| 854 ext_id != extension_ids.end(); ++ext_id) { | 857 extension_ids.begin(); ext_id != extension_ids.end(); ++ext_id) { |
| 855 | 858 |
| 856 // An extension's granted permissions need to be migrated if the | 859 // An extension's granted permissions need to be migrated if the |
| 857 // full_access bit is present. This bit was always present in the previous | 860 // full_access bit is present. This bit was always present in the previous |
| 858 // scheme and is never present now. | 861 // scheme and is never present now. |
| 859 bool full_access; | 862 bool full_access; |
| 860 const DictionaryValue* ext = GetExtensionPref(*ext_id); | 863 const DictionaryValue* ext = GetExtensionPref(*ext_id); |
| 861 if (!ext || !ext->GetBoolean(kPrefOldGrantedFullAccess, &full_access)) | 864 if (!ext || !ext->GetBoolean(kPrefOldGrantedFullAccess, &full_access)) |
| 862 continue; | 865 continue; |
| 863 | 866 |
| 864 // Remove the full access bit (empty list will get trimmed). | 867 // Remove the full access bit (empty list will get trimmed). |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 const std::string& id) const { | 1157 const std::string& id) const { |
| 1155 return DoesExtensionHaveState(id, Extension::EXTERNAL_EXTENSION_UNINSTALLED); | 1158 return DoesExtensionHaveState(id, Extension::EXTERNAL_EXTENSION_UNINSTALLED); |
| 1156 } | 1159 } |
| 1157 | 1160 |
| 1158 bool ExtensionPrefs::IsExtensionDisabled( | 1161 bool ExtensionPrefs::IsExtensionDisabled( |
| 1159 const std::string& id) const { | 1162 const std::string& id) const { |
| 1160 return DoesExtensionHaveState(id, Extension::DISABLED); | 1163 return DoesExtensionHaveState(id, Extension::DISABLED); |
| 1161 } | 1164 } |
| 1162 | 1165 |
| 1163 std::vector<std::string> ExtensionPrefs::GetToolbarOrder() { | 1166 std::vector<std::string> ExtensionPrefs::GetToolbarOrder() { |
| 1164 ExtensionPrefs::ExtensionIdSet extension_ids; | 1167 ExtensionIdSet extension_ids; |
| 1165 const ListValue* toolbar_order = prefs_->GetList(kExtensionToolbar); | 1168 const ListValue* toolbar_order = prefs_->GetList(kExtensionToolbar); |
| 1166 if (toolbar_order) { | 1169 if (toolbar_order) { |
| 1167 for (size_t i = 0; i < toolbar_order->GetSize(); ++i) { | 1170 for (size_t i = 0; i < toolbar_order->GetSize(); ++i) { |
| 1168 std::string extension_id; | 1171 std::string extension_id; |
| 1169 if (toolbar_order->GetString(i, &extension_id)) | 1172 if (toolbar_order->GetString(i, &extension_id)) |
| 1170 extension_ids.push_back(extension_id); | 1173 extension_ids.push_back(extension_id); |
| 1171 } | 1174 } |
| 1172 } | 1175 } |
| 1173 return extension_ids; | 1176 return extension_ids; |
| 1174 } | 1177 } |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1894 prefs->RegisterStringPref(prefs::kExtensionBlacklistUpdateVersion, | 1897 prefs->RegisterStringPref(prefs::kExtensionBlacklistUpdateVersion, |
| 1895 "0", // default value | 1898 "0", // default value |
| 1896 PrefService::UNSYNCABLE_PREF); | 1899 PrefService::UNSYNCABLE_PREF); |
| 1897 prefs->RegisterInt64Pref(prefs::kLastExtensionsUpdateCheck, | 1900 prefs->RegisterInt64Pref(prefs::kLastExtensionsUpdateCheck, |
| 1898 0, // default value | 1901 0, // default value |
| 1899 PrefService::UNSYNCABLE_PREF); | 1902 PrefService::UNSYNCABLE_PREF); |
| 1900 prefs->RegisterInt64Pref(prefs::kNextExtensionsUpdateCheck, | 1903 prefs->RegisterInt64Pref(prefs::kNextExtensionsUpdateCheck, |
| 1901 0, // default value | 1904 0, // default value |
| 1902 PrefService::UNSYNCABLE_PREF); | 1905 PrefService::UNSYNCABLE_PREF); |
| 1903 } | 1906 } |
| OLD | NEW |