| OLD | NEW |
| 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 <iterator> | 7 #include <iterator> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/prefs/pref_notifier.h" | 10 #include "base/prefs/pref_notifier.h" |
| (...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 new base::FundamentalValue(active)); | 998 new base::FundamentalValue(active)); |
| 999 } | 999 } |
| 1000 | 1000 |
| 1001 void ExtensionPrefs::MigratePermissions(const ExtensionIdList& extension_ids) { | 1001 void ExtensionPrefs::MigratePermissions(const ExtensionIdList& extension_ids) { |
| 1002 PermissionsInfo* info = PermissionsInfo::GetInstance(); | 1002 PermissionsInfo* info = PermissionsInfo::GetInstance(); |
| 1003 for (ExtensionIdList::const_iterator ext_id = | 1003 for (ExtensionIdList::const_iterator ext_id = |
| 1004 extension_ids.begin(); ext_id != extension_ids.end(); ++ext_id) { | 1004 extension_ids.begin(); ext_id != extension_ids.end(); ++ext_id) { |
| 1005 // An extension's granted permissions need to be migrated if the | 1005 // An extension's granted permissions need to be migrated if the |
| 1006 // full_access bit is present. This bit was always present in the previous | 1006 // full_access bit is present. This bit was always present in the previous |
| 1007 // scheme and is never present now. | 1007 // scheme and is never present now. |
| 1008 bool full_access; | 1008 bool full_access = false; |
| 1009 const base::DictionaryValue* ext = GetExtensionPref(*ext_id); | 1009 const base::DictionaryValue* ext = GetExtensionPref(*ext_id); |
| 1010 if (!ext || !ext->GetBoolean(kPrefOldGrantedFullAccess, &full_access)) | 1010 if (!ext || !ext->GetBoolean(kPrefOldGrantedFullAccess, &full_access)) |
| 1011 continue; | 1011 continue; |
| 1012 | 1012 |
| 1013 // Remove the full access bit (empty list will get trimmed). | 1013 // Remove the full access bit (empty list will get trimmed). |
| 1014 UpdateExtensionPref( | 1014 UpdateExtensionPref( |
| 1015 *ext_id, kPrefOldGrantedFullAccess, new base::ListValue()); | 1015 *ext_id, kPrefOldGrantedFullAccess, new base::ListValue()); |
| 1016 | 1016 |
| 1017 // Add the plugin permission if the full access bit was set. | 1017 // Add the plugin permission if the full access bit was set. |
| 1018 if (full_access) { | 1018 if (full_access) { |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 SetExtensionBlacklisted(extension_id, state == BLACKLISTED_MALWARE); | 1281 SetExtensionBlacklisted(extension_id, state == BLACKLISTED_MALWARE); |
| 1282 UpdateExtensionPref(extension_id, kPrefBlacklistState, | 1282 UpdateExtensionPref(extension_id, kPrefBlacklistState, |
| 1283 new base::FundamentalValue(state)); | 1283 new base::FundamentalValue(state)); |
| 1284 } | 1284 } |
| 1285 | 1285 |
| 1286 BlacklistState ExtensionPrefs::GetExtensionBlacklistState( | 1286 BlacklistState ExtensionPrefs::GetExtensionBlacklistState( |
| 1287 const std::string& extension_id) { | 1287 const std::string& extension_id) { |
| 1288 if (IsExtensionBlacklisted(extension_id)) | 1288 if (IsExtensionBlacklisted(extension_id)) |
| 1289 return BLACKLISTED_MALWARE; | 1289 return BLACKLISTED_MALWARE; |
| 1290 const base::DictionaryValue* ext_prefs = GetExtensionPref(extension_id); | 1290 const base::DictionaryValue* ext_prefs = GetExtensionPref(extension_id); |
| 1291 int int_value; | 1291 int int_value = 0; |
| 1292 if (ext_prefs && ext_prefs->GetInteger(kPrefBlacklistState, &int_value)) | 1292 if (ext_prefs && ext_prefs->GetInteger(kPrefBlacklistState, &int_value)) |
| 1293 return static_cast<BlacklistState>(int_value); | 1293 return static_cast<BlacklistState>(int_value); |
| 1294 | 1294 |
| 1295 return NOT_BLACKLISTED; | 1295 return NOT_BLACKLISTED; |
| 1296 } | 1296 } |
| 1297 | 1297 |
| 1298 std::string ExtensionPrefs::GetVersionString(const std::string& extension_id) { | 1298 std::string ExtensionPrefs::GetVersionString(const std::string& extension_id) { |
| 1299 const base::DictionaryValue* extension = GetExtensionPref(extension_id); | 1299 const base::DictionaryValue* extension = GetExtensionPref(extension_id); |
| 1300 if (!extension) | 1300 if (!extension) |
| 1301 return std::string(); | 1301 return std::string(); |
| (...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2186 extension_pref_value_map_->RegisterExtension( | 2186 extension_pref_value_map_->RegisterExtension( |
| 2187 extension_id, install_time, is_enabled, is_incognito_enabled); | 2187 extension_id, install_time, is_enabled, is_incognito_enabled); |
| 2188 | 2188 |
| 2189 FOR_EACH_OBSERVER( | 2189 FOR_EACH_OBSERVER( |
| 2190 ExtensionPrefsObserver, | 2190 ExtensionPrefsObserver, |
| 2191 observer_list_, | 2191 observer_list_, |
| 2192 OnExtensionRegistered(extension_id, install_time, is_enabled)); | 2192 OnExtensionRegistered(extension_id, install_time, is_enabled)); |
| 2193 } | 2193 } |
| 2194 | 2194 |
| 2195 } // namespace extensions | 2195 } // namespace extensions |
| OLD | NEW |