| 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" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/value_conversions.h" | 14 #include "base/value_conversions.h" |
| 15 #include "components/crx_file/id_util.h" |
| 15 #include "components/pref_registry/pref_registry_syncable.h" | 16 #include "components/pref_registry/pref_registry_syncable.h" |
| 16 #include "extensions/browser/admin_policy.h" | 17 #include "extensions/browser/admin_policy.h" |
| 17 #include "extensions/browser/app_sorting.h" | 18 #include "extensions/browser/app_sorting.h" |
| 18 #include "extensions/browser/event_router.h" | 19 #include "extensions/browser/event_router.h" |
| 19 #include "extensions/browser/extension_pref_store.h" | 20 #include "extensions/browser/extension_pref_store.h" |
| 20 #include "extensions/browser/extension_prefs_factory.h" | 21 #include "extensions/browser/extension_prefs_factory.h" |
| 21 #include "extensions/browser/extension_prefs_observer.h" | 22 #include "extensions/browser/extension_prefs_observer.h" |
| 22 #include "extensions/browser/install_flag.h" | 23 #include "extensions/browser/install_flag.h" |
| 23 #include "extensions/browser/pref_names.h" | 24 #include "extensions/browser/pref_names.h" |
| 24 #include "extensions/common/feature_switch.h" | 25 #include "extensions/common/feature_switch.h" |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 // ScopedUpdate | 281 // ScopedUpdate |
| 281 // | 282 // |
| 282 template <typename T, base::Value::Type type_enum_value> | 283 template <typename T, base::Value::Type type_enum_value> |
| 283 ExtensionPrefs::ScopedUpdate<T, type_enum_value>::ScopedUpdate( | 284 ExtensionPrefs::ScopedUpdate<T, type_enum_value>::ScopedUpdate( |
| 284 ExtensionPrefs* prefs, | 285 ExtensionPrefs* prefs, |
| 285 const std::string& extension_id, | 286 const std::string& extension_id, |
| 286 const std::string& key) | 287 const std::string& key) |
| 287 : update_(prefs->pref_service(), pref_names::kExtensions), | 288 : update_(prefs->pref_service(), pref_names::kExtensions), |
| 288 extension_id_(extension_id), | 289 extension_id_(extension_id), |
| 289 key_(key) { | 290 key_(key) { |
| 290 DCHECK(Extension::IdIsValid(extension_id_)); | 291 DCHECK(crx_file::id_util::IdIsValid(extension_id_)); |
| 291 } | 292 } |
| 292 | 293 |
| 293 template <typename T, base::Value::Type type_enum_value> | 294 template <typename T, base::Value::Type type_enum_value> |
| 294 ExtensionPrefs::ScopedUpdate<T, type_enum_value>::~ScopedUpdate() { | 295 ExtensionPrefs::ScopedUpdate<T, type_enum_value>::~ScopedUpdate() { |
| 295 } | 296 } |
| 296 | 297 |
| 297 template <typename T, base::Value::Type type_enum_value> | 298 template <typename T, base::Value::Type type_enum_value> |
| 298 T* ExtensionPrefs::ScopedUpdate<T, type_enum_value>::Get() { | 299 T* ExtensionPrefs::ScopedUpdate<T, type_enum_value>::Get() { |
| 299 base::DictionaryValue* dict = update_.Get(); | 300 base::DictionaryValue* dict = update_.Get(); |
| 300 base::DictionaryValue* extension = NULL; | 301 base::DictionaryValue* extension = NULL; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 if (!extensions || | 450 if (!extensions || |
| 450 !extensions->GetDictionary(extension_id, &extension_dict)) { | 451 !extensions->GetDictionary(extension_id, &extension_dict)) { |
| 451 return NULL; | 452 return NULL; |
| 452 } | 453 } |
| 453 return extension_dict; | 454 return extension_dict; |
| 454 } | 455 } |
| 455 | 456 |
| 456 void ExtensionPrefs::UpdateExtensionPref(const std::string& extension_id, | 457 void ExtensionPrefs::UpdateExtensionPref(const std::string& extension_id, |
| 457 const std::string& key, | 458 const std::string& key, |
| 458 base::Value* data_value) { | 459 base::Value* data_value) { |
| 459 if (!Extension::IdIsValid(extension_id)) { | 460 if (!crx_file::id_util::IdIsValid(extension_id)) { |
| 460 NOTREACHED() << "Invalid extension_id " << extension_id; | 461 NOTREACHED() << "Invalid extension_id " << extension_id; |
| 461 return; | 462 return; |
| 462 } | 463 } |
| 463 ScopedExtensionPrefUpdate update(prefs_, extension_id); | 464 ScopedExtensionPrefUpdate update(prefs_, extension_id); |
| 464 if (data_value) | 465 if (data_value) |
| 465 update->Set(key, data_value); | 466 update->Set(key, data_value); |
| 466 else | 467 else |
| 467 update->Remove(key, NULL); | 468 update->Remove(key, NULL); |
| 468 } | 469 } |
| 469 | 470 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 return count; | 677 return count; |
| 677 } | 678 } |
| 678 | 679 |
| 679 bool ExtensionPrefs::IsExternalExtensionAcknowledged( | 680 bool ExtensionPrefs::IsExternalExtensionAcknowledged( |
| 680 const std::string& extension_id) { | 681 const std::string& extension_id) { |
| 681 return ReadPrefAsBooleanAndReturn(extension_id, kPrefExternalAcknowledged); | 682 return ReadPrefAsBooleanAndReturn(extension_id, kPrefExternalAcknowledged); |
| 682 } | 683 } |
| 683 | 684 |
| 684 void ExtensionPrefs::AcknowledgeExternalExtension( | 685 void ExtensionPrefs::AcknowledgeExternalExtension( |
| 685 const std::string& extension_id) { | 686 const std::string& extension_id) { |
| 686 DCHECK(Extension::IdIsValid(extension_id)); | 687 DCHECK(crx_file::id_util::IdIsValid(extension_id)); |
| 687 UpdateExtensionPref(extension_id, kPrefExternalAcknowledged, | 688 UpdateExtensionPref(extension_id, kPrefExternalAcknowledged, |
| 688 new base::FundamentalValue(true)); | 689 new base::FundamentalValue(true)); |
| 689 UpdateExtensionPref(extension_id, kPrefAcknowledgePromptCount, NULL); | 690 UpdateExtensionPref(extension_id, kPrefAcknowledgePromptCount, NULL); |
| 690 } | 691 } |
| 691 | 692 |
| 692 bool ExtensionPrefs::IsBlacklistedExtensionAcknowledged( | 693 bool ExtensionPrefs::IsBlacklistedExtensionAcknowledged( |
| 693 const std::string& extension_id) { | 694 const std::string& extension_id) { |
| 694 return ReadPrefAsBooleanAndReturn(extension_id, kPrefBlacklistAcknowledged); | 695 return ReadPrefAsBooleanAndReturn(extension_id, kPrefBlacklistAcknowledged); |
| 695 } | 696 } |
| 696 | 697 |
| 697 void ExtensionPrefs::AcknowledgeBlacklistedExtension( | 698 void ExtensionPrefs::AcknowledgeBlacklistedExtension( |
| 698 const std::string& extension_id) { | 699 const std::string& extension_id) { |
| 699 DCHECK(Extension::IdIsValid(extension_id)); | 700 DCHECK(crx_file::id_util::IdIsValid(extension_id)); |
| 700 UpdateExtensionPref(extension_id, kPrefBlacklistAcknowledged, | 701 UpdateExtensionPref(extension_id, kPrefBlacklistAcknowledged, |
| 701 new base::FundamentalValue(true)); | 702 new base::FundamentalValue(true)); |
| 702 UpdateExtensionPref(extension_id, kPrefAcknowledgePromptCount, NULL); | 703 UpdateExtensionPref(extension_id, kPrefAcknowledgePromptCount, NULL); |
| 703 } | 704 } |
| 704 | 705 |
| 705 bool ExtensionPrefs::IsExternalInstallFirstRun( | 706 bool ExtensionPrefs::IsExternalInstallFirstRun( |
| 706 const std::string& extension_id) { | 707 const std::string& extension_id) { |
| 707 return ReadPrefAsBooleanAndReturn(extension_id, kPrefExternalInstallFirstRun); | 708 return ReadPrefAsBooleanAndReturn(extension_id, kPrefExternalInstallFirstRun); |
| 708 } | 709 } |
| 709 | 710 |
| 710 void ExtensionPrefs::SetExternalInstallFirstRun( | 711 void ExtensionPrefs::SetExternalInstallFirstRun( |
| 711 const std::string& extension_id) { | 712 const std::string& extension_id) { |
| 712 DCHECK(Extension::IdIsValid(extension_id)); | 713 DCHECK(crx_file::id_util::IdIsValid(extension_id)); |
| 713 UpdateExtensionPref(extension_id, kPrefExternalInstallFirstRun, | 714 UpdateExtensionPref(extension_id, kPrefExternalInstallFirstRun, |
| 714 new base::FundamentalValue(true)); | 715 new base::FundamentalValue(true)); |
| 715 } | 716 } |
| 716 | 717 |
| 717 bool ExtensionPrefs::HasWipeoutBeenAcknowledged( | 718 bool ExtensionPrefs::HasWipeoutBeenAcknowledged( |
| 718 const std::string& extension_id) { | 719 const std::string& extension_id) { |
| 719 return ReadPrefAsBooleanAndReturn(extension_id, kPrefWipeoutAcknowledged); | 720 return ReadPrefAsBooleanAndReturn(extension_id, kPrefWipeoutAcknowledged); |
| 720 } | 721 } |
| 721 | 722 |
| 722 void ExtensionPrefs::SetWipeoutAcknowledged( | 723 void ExtensionPrefs::SetWipeoutAcknowledged( |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 int64 value; | 947 int64 value; |
| 947 if (ReadInt64(dictionary, key, &value)) | 948 if (ReadInt64(dictionary, key, &value)) |
| 948 return base::Time::FromInternalValue(value); | 949 return base::Time::FromInternalValue(value); |
| 949 | 950 |
| 950 return base::Time(); | 951 return base::Time(); |
| 951 } | 952 } |
| 952 | 953 |
| 953 } // namespace | 954 } // namespace |
| 954 | 955 |
| 955 base::Time ExtensionPrefs::LastPingDay(const std::string& extension_id) const { | 956 base::Time ExtensionPrefs::LastPingDay(const std::string& extension_id) const { |
| 956 DCHECK(Extension::IdIsValid(extension_id)); | 957 DCHECK(crx_file::id_util::IdIsValid(extension_id)); |
| 957 return ReadTime(GetExtensionPref(extension_id), kLastPingDay); | 958 return ReadTime(GetExtensionPref(extension_id), kLastPingDay); |
| 958 } | 959 } |
| 959 | 960 |
| 960 void ExtensionPrefs::SetLastPingDay(const std::string& extension_id, | 961 void ExtensionPrefs::SetLastPingDay(const std::string& extension_id, |
| 961 const base::Time& time) { | 962 const base::Time& time) { |
| 962 DCHECK(Extension::IdIsValid(extension_id)); | 963 DCHECK(crx_file::id_util::IdIsValid(extension_id)); |
| 963 ScopedExtensionPrefUpdate update(prefs_, extension_id); | 964 ScopedExtensionPrefUpdate update(prefs_, extension_id); |
| 964 SaveTime(update.Get(), kLastPingDay, time); | 965 SaveTime(update.Get(), kLastPingDay, time); |
| 965 } | 966 } |
| 966 | 967 |
| 967 base::Time ExtensionPrefs::BlacklistLastPingDay() const { | 968 base::Time ExtensionPrefs::BlacklistLastPingDay() const { |
| 968 return ReadTime(prefs_->GetDictionary(kExtensionsBlacklistUpdate), | 969 return ReadTime(prefs_->GetDictionary(kExtensionsBlacklistUpdate), |
| 969 kLastPingDay); | 970 kLastPingDay); |
| 970 } | 971 } |
| 971 | 972 |
| 972 void ExtensionPrefs::SetBlacklistLastPingDay(const base::Time& time) { | 973 void ExtensionPrefs::SetBlacklistLastPingDay(const base::Time& time) { |
| 973 DictionaryPrefUpdate update(prefs_, kExtensionsBlacklistUpdate); | 974 DictionaryPrefUpdate update(prefs_, kExtensionsBlacklistUpdate); |
| 974 SaveTime(update.Get(), kLastPingDay, time); | 975 SaveTime(update.Get(), kLastPingDay, time); |
| 975 } | 976 } |
| 976 | 977 |
| 977 base::Time ExtensionPrefs::LastActivePingDay(const std::string& extension_id) { | 978 base::Time ExtensionPrefs::LastActivePingDay(const std::string& extension_id) { |
| 978 DCHECK(Extension::IdIsValid(extension_id)); | 979 DCHECK(crx_file::id_util::IdIsValid(extension_id)); |
| 979 return ReadTime(GetExtensionPref(extension_id), kLastActivePingDay); | 980 return ReadTime(GetExtensionPref(extension_id), kLastActivePingDay); |
| 980 } | 981 } |
| 981 | 982 |
| 982 void ExtensionPrefs::SetLastActivePingDay(const std::string& extension_id, | 983 void ExtensionPrefs::SetLastActivePingDay(const std::string& extension_id, |
| 983 const base::Time& time) { | 984 const base::Time& time) { |
| 984 DCHECK(Extension::IdIsValid(extension_id)); | 985 DCHECK(crx_file::id_util::IdIsValid(extension_id)); |
| 985 ScopedExtensionPrefUpdate update(prefs_, extension_id); | 986 ScopedExtensionPrefUpdate update(prefs_, extension_id); |
| 986 SaveTime(update.Get(), kLastActivePingDay, time); | 987 SaveTime(update.Get(), kLastActivePingDay, time); |
| 987 } | 988 } |
| 988 | 989 |
| 989 bool ExtensionPrefs::GetActiveBit(const std::string& extension_id) { | 990 bool ExtensionPrefs::GetActiveBit(const std::string& extension_id) { |
| 990 const base::DictionaryValue* dictionary = GetExtensionPref(extension_id); | 991 const base::DictionaryValue* dictionary = GetExtensionPref(extension_id); |
| 991 bool result = false; | 992 bool result = false; |
| 992 if (dictionary && dictionary->GetBoolean(kActiveBit, &result)) | 993 if (dictionary && dictionary->GetBoolean(kActiveBit, &result)) |
| 993 return result; | 994 return result; |
| 994 return false; | 995 return false; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1073 UpdateExtensionPref(*ext_id, kPrefDisableReasons, | 1074 UpdateExtensionPref(*ext_id, kPrefDisableReasons, |
| 1074 new base::FundamentalValue(new_value)); | 1075 new base::FundamentalValue(new_value)); |
| 1075 // Remove the old disable reason. | 1076 // Remove the old disable reason. |
| 1076 UpdateExtensionPref(*ext_id, kDeprecatedPrefDisableReason, NULL); | 1077 UpdateExtensionPref(*ext_id, kDeprecatedPrefDisableReason, NULL); |
| 1077 } | 1078 } |
| 1078 } | 1079 } |
| 1079 } | 1080 } |
| 1080 | 1081 |
| 1081 PermissionSet* ExtensionPrefs::GetGrantedPermissions( | 1082 PermissionSet* ExtensionPrefs::GetGrantedPermissions( |
| 1082 const std::string& extension_id) { | 1083 const std::string& extension_id) { |
| 1083 CHECK(Extension::IdIsValid(extension_id)); | 1084 CHECK(crx_file::id_util::IdIsValid(extension_id)); |
| 1084 return ReadPrefAsPermissionSet(extension_id, kPrefGrantedPermissions); | 1085 return ReadPrefAsPermissionSet(extension_id, kPrefGrantedPermissions); |
| 1085 } | 1086 } |
| 1086 | 1087 |
| 1087 void ExtensionPrefs::AddGrantedPermissions( | 1088 void ExtensionPrefs::AddGrantedPermissions( |
| 1088 const std::string& extension_id, | 1089 const std::string& extension_id, |
| 1089 const PermissionSet* permissions) { | 1090 const PermissionSet* permissions) { |
| 1090 CHECK(Extension::IdIsValid(extension_id)); | 1091 CHECK(crx_file::id_util::IdIsValid(extension_id)); |
| 1091 | 1092 |
| 1092 scoped_refptr<PermissionSet> granted_permissions( | 1093 scoped_refptr<PermissionSet> granted_permissions( |
| 1093 GetGrantedPermissions(extension_id)); | 1094 GetGrantedPermissions(extension_id)); |
| 1094 | 1095 |
| 1095 // The new granted permissions are the union of the already granted | 1096 // The new granted permissions are the union of the already granted |
| 1096 // permissions and the newly granted permissions. | 1097 // permissions and the newly granted permissions. |
| 1097 scoped_refptr<PermissionSet> new_perms( | 1098 scoped_refptr<PermissionSet> new_perms( |
| 1098 PermissionSet::CreateUnion( | 1099 PermissionSet::CreateUnion( |
| 1099 permissions, granted_permissions.get())); | 1100 permissions, granted_permissions.get())); |
| 1100 | 1101 |
| 1101 SetExtensionPrefPermissionSet( | 1102 SetExtensionPrefPermissionSet( |
| 1102 extension_id, kPrefGrantedPermissions, new_perms.get()); | 1103 extension_id, kPrefGrantedPermissions, new_perms.get()); |
| 1103 } | 1104 } |
| 1104 | 1105 |
| 1105 void ExtensionPrefs::RemoveGrantedPermissions( | 1106 void ExtensionPrefs::RemoveGrantedPermissions( |
| 1106 const std::string& extension_id, | 1107 const std::string& extension_id, |
| 1107 const PermissionSet* permissions) { | 1108 const PermissionSet* permissions) { |
| 1108 CHECK(Extension::IdIsValid(extension_id)); | 1109 CHECK(crx_file::id_util::IdIsValid(extension_id)); |
| 1109 | 1110 |
| 1110 scoped_refptr<PermissionSet> granted_permissions( | 1111 scoped_refptr<PermissionSet> granted_permissions( |
| 1111 GetGrantedPermissions(extension_id)); | 1112 GetGrantedPermissions(extension_id)); |
| 1112 | 1113 |
| 1113 // The new granted permissions are the difference of the already granted | 1114 // The new granted permissions are the difference of the already granted |
| 1114 // permissions and the newly ungranted permissions. | 1115 // permissions and the newly ungranted permissions. |
| 1115 scoped_refptr<PermissionSet> new_perms( | 1116 scoped_refptr<PermissionSet> new_perms( |
| 1116 PermissionSet::CreateDifference( | 1117 PermissionSet::CreateDifference( |
| 1117 granted_permissions.get(), permissions)); | 1118 granted_permissions.get(), permissions)); |
| 1118 | 1119 |
| 1119 SetExtensionPrefPermissionSet( | 1120 SetExtensionPrefPermissionSet( |
| 1120 extension_id, kPrefGrantedPermissions, new_perms.get()); | 1121 extension_id, kPrefGrantedPermissions, new_perms.get()); |
| 1121 } | 1122 } |
| 1122 | 1123 |
| 1123 PermissionSet* ExtensionPrefs::GetActivePermissions( | 1124 PermissionSet* ExtensionPrefs::GetActivePermissions( |
| 1124 const std::string& extension_id) { | 1125 const std::string& extension_id) { |
| 1125 CHECK(Extension::IdIsValid(extension_id)); | 1126 CHECK(crx_file::id_util::IdIsValid(extension_id)); |
| 1126 return ReadPrefAsPermissionSet(extension_id, kPrefActivePermissions); | 1127 return ReadPrefAsPermissionSet(extension_id, kPrefActivePermissions); |
| 1127 } | 1128 } |
| 1128 | 1129 |
| 1129 void ExtensionPrefs::SetActivePermissions( | 1130 void ExtensionPrefs::SetActivePermissions( |
| 1130 const std::string& extension_id, | 1131 const std::string& extension_id, |
| 1131 const PermissionSet* permissions) { | 1132 const PermissionSet* permissions) { |
| 1132 SetExtensionPrefPermissionSet( | 1133 SetExtensionPrefPermissionSet( |
| 1133 extension_id, kPrefActivePermissions, permissions); | 1134 extension_id, kPrefActivePermissions, permissions); |
| 1134 } | 1135 } |
| 1135 | 1136 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1394 } | 1395 } |
| 1395 | 1396 |
| 1396 scoped_ptr<ExtensionPrefs::ExtensionsInfo> | 1397 scoped_ptr<ExtensionPrefs::ExtensionsInfo> |
| 1397 ExtensionPrefs::GetInstalledExtensionsInfo() const { | 1398 ExtensionPrefs::GetInstalledExtensionsInfo() const { |
| 1398 scoped_ptr<ExtensionsInfo> extensions_info(new ExtensionsInfo); | 1399 scoped_ptr<ExtensionsInfo> extensions_info(new ExtensionsInfo); |
| 1399 | 1400 |
| 1400 const base::DictionaryValue* extensions = | 1401 const base::DictionaryValue* extensions = |
| 1401 prefs_->GetDictionary(pref_names::kExtensions); | 1402 prefs_->GetDictionary(pref_names::kExtensions); |
| 1402 for (base::DictionaryValue::Iterator extension_id(*extensions); | 1403 for (base::DictionaryValue::Iterator extension_id(*extensions); |
| 1403 !extension_id.IsAtEnd(); extension_id.Advance()) { | 1404 !extension_id.IsAtEnd(); extension_id.Advance()) { |
| 1404 if (!Extension::IdIsValid(extension_id.key())) | 1405 if (!crx_file::id_util::IdIsValid(extension_id.key())) |
| 1405 continue; | 1406 continue; |
| 1406 | 1407 |
| 1407 scoped_ptr<ExtensionInfo> info = | 1408 scoped_ptr<ExtensionInfo> info = |
| 1408 GetInstalledExtensionInfo(extension_id.key()); | 1409 GetInstalledExtensionInfo(extension_id.key()); |
| 1409 if (info) | 1410 if (info) |
| 1410 extensions_info->push_back(linked_ptr<ExtensionInfo>(info.release())); | 1411 extensions_info->push_back(linked_ptr<ExtensionInfo>(info.release())); |
| 1411 } | 1412 } |
| 1412 | 1413 |
| 1413 return extensions_info.Pass(); | 1414 return extensions_info.Pass(); |
| 1414 } | 1415 } |
| 1415 | 1416 |
| 1416 scoped_ptr<ExtensionPrefs::ExtensionsInfo> | 1417 scoped_ptr<ExtensionPrefs::ExtensionsInfo> |
| 1417 ExtensionPrefs::GetUninstalledExtensionsInfo() const { | 1418 ExtensionPrefs::GetUninstalledExtensionsInfo() const { |
| 1418 scoped_ptr<ExtensionsInfo> extensions_info(new ExtensionsInfo); | 1419 scoped_ptr<ExtensionsInfo> extensions_info(new ExtensionsInfo); |
| 1419 | 1420 |
| 1420 const base::DictionaryValue* extensions = | 1421 const base::DictionaryValue* extensions = |
| 1421 prefs_->GetDictionary(pref_names::kExtensions); | 1422 prefs_->GetDictionary(pref_names::kExtensions); |
| 1422 for (base::DictionaryValue::Iterator extension_id(*extensions); | 1423 for (base::DictionaryValue::Iterator extension_id(*extensions); |
| 1423 !extension_id.IsAtEnd(); extension_id.Advance()) { | 1424 !extension_id.IsAtEnd(); extension_id.Advance()) { |
| 1424 const base::DictionaryValue* ext = NULL; | 1425 const base::DictionaryValue* ext = NULL; |
| 1425 if (!Extension::IdIsValid(extension_id.key()) || | 1426 if (!crx_file::id_util::IdIsValid(extension_id.key()) || |
| 1426 !IsExternalExtensionUninstalled(extension_id.key()) || | 1427 !IsExternalExtensionUninstalled(extension_id.key()) || |
| 1427 !extension_id.value().GetAsDictionary(&ext)) | 1428 !extension_id.value().GetAsDictionary(&ext)) |
| 1428 continue; | 1429 continue; |
| 1429 | 1430 |
| 1430 scoped_ptr<ExtensionInfo> info = | 1431 scoped_ptr<ExtensionInfo> info = |
| 1431 GetInstalledInfoHelper(extension_id.key(), ext); | 1432 GetInstalledInfoHelper(extension_id.key(), ext); |
| 1432 if (info) | 1433 if (info) |
| 1433 extensions_info->push_back(linked_ptr<ExtensionInfo>(info.release())); | 1434 extensions_info->push_back(linked_ptr<ExtensionInfo>(info.release())); |
| 1434 } | 1435 } |
| 1435 | 1436 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1471 const std::string& extension_id) { | 1472 const std::string& extension_id) { |
| 1472 if (!GetExtensionPref(extension_id)) | 1473 if (!GetExtensionPref(extension_id)) |
| 1473 return false; | 1474 return false; |
| 1474 ScopedExtensionPrefUpdate update(prefs_, extension_id); | 1475 ScopedExtensionPrefUpdate update(prefs_, extension_id); |
| 1475 bool result = update->Remove(kDelayedInstallInfo, NULL); | 1476 bool result = update->Remove(kDelayedInstallInfo, NULL); |
| 1476 return result; | 1477 return result; |
| 1477 } | 1478 } |
| 1478 | 1479 |
| 1479 bool ExtensionPrefs::FinishDelayedInstallInfo( | 1480 bool ExtensionPrefs::FinishDelayedInstallInfo( |
| 1480 const std::string& extension_id) { | 1481 const std::string& extension_id) { |
| 1481 CHECK(Extension::IdIsValid(extension_id)); | 1482 CHECK(crx_file::id_util::IdIsValid(extension_id)); |
| 1482 ScopedExtensionPrefUpdate update(prefs_, extension_id); | 1483 ScopedExtensionPrefUpdate update(prefs_, extension_id); |
| 1483 base::DictionaryValue* extension_dict = update.Get(); | 1484 base::DictionaryValue* extension_dict = update.Get(); |
| 1484 base::DictionaryValue* pending_install_dict = NULL; | 1485 base::DictionaryValue* pending_install_dict = NULL; |
| 1485 if (!extension_dict->GetDictionary(kDelayedInstallInfo, | 1486 if (!extension_dict->GetDictionary(kDelayedInstallInfo, |
| 1486 &pending_install_dict)) { | 1487 &pending_install_dict)) { |
| 1487 return false; | 1488 return false; |
| 1488 } | 1489 } |
| 1489 | 1490 |
| 1490 // Retrieve and clear transient values populated by SetDelayedInstallInfo(). | 1491 // Retrieve and clear transient values populated by SetDelayedInstallInfo(). |
| 1491 // Also do any other data cleanup that makes sense. | 1492 // Also do any other data cleanup that makes sense. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1554 } | 1555 } |
| 1555 | 1556 |
| 1556 scoped_ptr<ExtensionPrefs::ExtensionsInfo> ExtensionPrefs:: | 1557 scoped_ptr<ExtensionPrefs::ExtensionsInfo> ExtensionPrefs:: |
| 1557 GetAllDelayedInstallInfo() const { | 1558 GetAllDelayedInstallInfo() const { |
| 1558 scoped_ptr<ExtensionsInfo> extensions_info(new ExtensionsInfo); | 1559 scoped_ptr<ExtensionsInfo> extensions_info(new ExtensionsInfo); |
| 1559 | 1560 |
| 1560 const base::DictionaryValue* extensions = | 1561 const base::DictionaryValue* extensions = |
| 1561 prefs_->GetDictionary(pref_names::kExtensions); | 1562 prefs_->GetDictionary(pref_names::kExtensions); |
| 1562 for (base::DictionaryValue::Iterator extension_id(*extensions); | 1563 for (base::DictionaryValue::Iterator extension_id(*extensions); |
| 1563 !extension_id.IsAtEnd(); extension_id.Advance()) { | 1564 !extension_id.IsAtEnd(); extension_id.Advance()) { |
| 1564 if (!Extension::IdIsValid(extension_id.key())) | 1565 if (!crx_file::id_util::IdIsValid(extension_id.key())) |
| 1565 continue; | 1566 continue; |
| 1566 | 1567 |
| 1567 scoped_ptr<ExtensionInfo> info = GetDelayedInstallInfo(extension_id.key()); | 1568 scoped_ptr<ExtensionInfo> info = GetDelayedInstallInfo(extension_id.key()); |
| 1568 if (info) | 1569 if (info) |
| 1569 extensions_info->push_back(linked_ptr<ExtensionInfo>(info.release())); | 1570 extensions_info->push_back(linked_ptr<ExtensionInfo>(info.release())); |
| 1570 } | 1571 } |
| 1571 | 1572 |
| 1572 return extensions_info.Pass(); | 1573 return extensions_info.Pass(); |
| 1573 } | 1574 } |
| 1574 | 1575 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1705 if (!extension->GetString(kPrefLastLaunchTime, &launch_time_str)) | 1706 if (!extension->GetString(kPrefLastLaunchTime, &launch_time_str)) |
| 1706 return base::Time(); | 1707 return base::Time(); |
| 1707 int64 launch_time_i64 = 0; | 1708 int64 launch_time_i64 = 0; |
| 1708 if (!base::StringToInt64(launch_time_str, &launch_time_i64)) | 1709 if (!base::StringToInt64(launch_time_str, &launch_time_i64)) |
| 1709 return base::Time(); | 1710 return base::Time(); |
| 1710 return base::Time::FromInternalValue(launch_time_i64); | 1711 return base::Time::FromInternalValue(launch_time_i64); |
| 1711 } | 1712 } |
| 1712 | 1713 |
| 1713 void ExtensionPrefs::SetLastLaunchTime(const std::string& extension_id, | 1714 void ExtensionPrefs::SetLastLaunchTime(const std::string& extension_id, |
| 1714 const base::Time& time) { | 1715 const base::Time& time) { |
| 1715 DCHECK(Extension::IdIsValid(extension_id)); | 1716 DCHECK(crx_file::id_util::IdIsValid(extension_id)); |
| 1716 ScopedExtensionPrefUpdate update(prefs_, extension_id); | 1717 ScopedExtensionPrefUpdate update(prefs_, extension_id); |
| 1717 SaveTime(update.Get(), kPrefLastLaunchTime, time); | 1718 SaveTime(update.Get(), kPrefLastLaunchTime, time); |
| 1718 } | 1719 } |
| 1719 | 1720 |
| 1720 void ExtensionPrefs::GetExtensions(ExtensionIdList* out) { | 1721 void ExtensionPrefs::GetExtensions(ExtensionIdList* out) { |
| 1721 CHECK(out); | 1722 CHECK(out); |
| 1722 | 1723 |
| 1723 scoped_ptr<ExtensionsInfo> extensions_info(GetInstalledExtensionsInfo()); | 1724 scoped_ptr<ExtensionsInfo> extensions_info(GetInstalledExtensionsInfo()); |
| 1724 | 1725 |
| 1725 for (size_t i = 0; i < extensions_info->size(); ++i) { | 1726 for (size_t i = 0; i < extensions_info->size(); ++i) { |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2179 extension_pref_value_map_->RegisterExtension( | 2180 extension_pref_value_map_->RegisterExtension( |
| 2180 extension_id, install_time, is_enabled, is_incognito_enabled); | 2181 extension_id, install_time, is_enabled, is_incognito_enabled); |
| 2181 | 2182 |
| 2182 FOR_EACH_OBSERVER( | 2183 FOR_EACH_OBSERVER( |
| 2183 ExtensionPrefsObserver, | 2184 ExtensionPrefsObserver, |
| 2184 observer_list_, | 2185 observer_list_, |
| 2185 OnExtensionRegistered(extension_id, install_time, is_enabled)); | 2186 OnExtensionRegistered(extension_id, install_time, is_enabled)); |
| 2186 } | 2187 } |
| 2187 | 2188 |
| 2188 } // namespace extensions | 2189 } // namespace extensions |
| OLD | NEW |