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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <iterator> | 10 #include <iterator> |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 new_value.scriptable_hosts()); | 660 new_value.scriptable_hosts()); |
661 } | 661 } |
662 } | 662 } |
663 | 663 |
664 int ExtensionPrefs::IncrementAcknowledgePromptCount( | 664 int ExtensionPrefs::IncrementAcknowledgePromptCount( |
665 const std::string& extension_id) { | 665 const std::string& extension_id) { |
666 int count = 0; | 666 int count = 0; |
667 ReadPrefAsInteger(extension_id, kPrefAcknowledgePromptCount, &count); | 667 ReadPrefAsInteger(extension_id, kPrefAcknowledgePromptCount, &count); |
668 ++count; | 668 ++count; |
669 UpdateExtensionPref(extension_id, kPrefAcknowledgePromptCount, | 669 UpdateExtensionPref(extension_id, kPrefAcknowledgePromptCount, |
670 new base::FundamentalValue(count)); | 670 new base::Value(count)); |
671 return count; | 671 return count; |
672 } | 672 } |
673 | 673 |
674 bool ExtensionPrefs::IsExternalExtensionAcknowledged( | 674 bool ExtensionPrefs::IsExternalExtensionAcknowledged( |
675 const std::string& extension_id) const { | 675 const std::string& extension_id) const { |
676 return ReadPrefAsBooleanAndReturn(extension_id, kPrefExternalAcknowledged); | 676 return ReadPrefAsBooleanAndReturn(extension_id, kPrefExternalAcknowledged); |
677 } | 677 } |
678 | 678 |
679 void ExtensionPrefs::AcknowledgeExternalExtension( | 679 void ExtensionPrefs::AcknowledgeExternalExtension( |
680 const std::string& extension_id) { | 680 const std::string& extension_id) { |
681 DCHECK(crx_file::id_util::IdIsValid(extension_id)); | 681 DCHECK(crx_file::id_util::IdIsValid(extension_id)); |
682 UpdateExtensionPref(extension_id, kPrefExternalAcknowledged, | 682 UpdateExtensionPref(extension_id, kPrefExternalAcknowledged, |
683 new base::FundamentalValue(true)); | 683 new base::Value(true)); |
684 UpdateExtensionPref(extension_id, kPrefAcknowledgePromptCount, NULL); | 684 UpdateExtensionPref(extension_id, kPrefAcknowledgePromptCount, NULL); |
685 } | 685 } |
686 | 686 |
687 bool ExtensionPrefs::IsBlacklistedExtensionAcknowledged( | 687 bool ExtensionPrefs::IsBlacklistedExtensionAcknowledged( |
688 const std::string& extension_id) const { | 688 const std::string& extension_id) const { |
689 return ReadPrefAsBooleanAndReturn(extension_id, kPrefBlacklistAcknowledged); | 689 return ReadPrefAsBooleanAndReturn(extension_id, kPrefBlacklistAcknowledged); |
690 } | 690 } |
691 | 691 |
692 void ExtensionPrefs::AcknowledgeBlacklistedExtension( | 692 void ExtensionPrefs::AcknowledgeBlacklistedExtension( |
693 const std::string& extension_id) { | 693 const std::string& extension_id) { |
694 DCHECK(crx_file::id_util::IdIsValid(extension_id)); | 694 DCHECK(crx_file::id_util::IdIsValid(extension_id)); |
695 UpdateExtensionPref(extension_id, kPrefBlacklistAcknowledged, | 695 UpdateExtensionPref(extension_id, kPrefBlacklistAcknowledged, |
696 new base::FundamentalValue(true)); | 696 new base::Value(true)); |
697 UpdateExtensionPref(extension_id, kPrefAcknowledgePromptCount, NULL); | 697 UpdateExtensionPref(extension_id, kPrefAcknowledgePromptCount, NULL); |
698 } | 698 } |
699 | 699 |
700 bool ExtensionPrefs::IsExternalInstallFirstRun( | 700 bool ExtensionPrefs::IsExternalInstallFirstRun( |
701 const std::string& extension_id) const { | 701 const std::string& extension_id) const { |
702 return ReadPrefAsBooleanAndReturn(extension_id, kPrefExternalInstallFirstRun); | 702 return ReadPrefAsBooleanAndReturn(extension_id, kPrefExternalInstallFirstRun); |
703 } | 703 } |
704 | 704 |
705 void ExtensionPrefs::SetExternalInstallFirstRun( | 705 void ExtensionPrefs::SetExternalInstallFirstRun( |
706 const std::string& extension_id) { | 706 const std::string& extension_id) { |
707 DCHECK(crx_file::id_util::IdIsValid(extension_id)); | 707 DCHECK(crx_file::id_util::IdIsValid(extension_id)); |
708 UpdateExtensionPref(extension_id, kPrefExternalInstallFirstRun, | 708 UpdateExtensionPref(extension_id, kPrefExternalInstallFirstRun, |
709 new base::FundamentalValue(true)); | 709 new base::Value(true)); |
710 } | 710 } |
711 | 711 |
712 bool ExtensionPrefs::SetAlertSystemFirstRun() { | 712 bool ExtensionPrefs::SetAlertSystemFirstRun() { |
713 if (prefs_->GetBoolean(pref_names::kAlertsInitialized)) { | 713 if (prefs_->GetBoolean(pref_names::kAlertsInitialized)) { |
714 return true; | 714 return true; |
715 } | 715 } |
716 prefs_->SetBoolean(pref_names::kAlertsInitialized, true); | 716 prefs_->SetBoolean(pref_names::kAlertsInitialized, true); |
717 return false; | 717 return false; |
718 } | 718 } |
719 | 719 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 new_value = Extension::DISABLE_NONE; | 786 new_value = Extension::DISABLE_NONE; |
787 break; | 787 break; |
788 } | 788 } |
789 | 789 |
790 if (old_value == new_value) // no change, return. | 790 if (old_value == new_value) // no change, return. |
791 return; | 791 return; |
792 | 792 |
793 if (new_value == Extension::DISABLE_NONE) { | 793 if (new_value == Extension::DISABLE_NONE) { |
794 UpdateExtensionPref(extension_id, kPrefDisableReasons, NULL); | 794 UpdateExtensionPref(extension_id, kPrefDisableReasons, NULL); |
795 } else { | 795 } else { |
796 UpdateExtensionPref(extension_id, | 796 UpdateExtensionPref(extension_id, kPrefDisableReasons, |
797 kPrefDisableReasons, | 797 new base::Value(new_value)); |
798 new base::FundamentalValue(new_value)); | |
799 } | 798 } |
800 | 799 |
801 for (auto& observer : observer_list_) | 800 for (auto& observer : observer_list_) |
802 observer.OnExtensionDisableReasonsChanged(extension_id, new_value); | 801 observer.OnExtensionDisableReasonsChanged(extension_id, new_value); |
803 } | 802 } |
804 | 803 |
805 std::set<std::string> ExtensionPrefs::GetBlacklistedExtensions() const { | 804 std::set<std::string> ExtensionPrefs::GetBlacklistedExtensions() const { |
806 std::set<std::string> ids; | 805 std::set<std::string> ids; |
807 | 806 |
808 const base::DictionaryValue* extensions = | 807 const base::DictionaryValue* extensions = |
(...skipping 20 matching lines...) Expand all Loading... |
829 bool is_blacklisted) { | 828 bool is_blacklisted) { |
830 bool currently_blacklisted = IsExtensionBlacklisted(extension_id); | 829 bool currently_blacklisted = IsExtensionBlacklisted(extension_id); |
831 if (is_blacklisted == currently_blacklisted) | 830 if (is_blacklisted == currently_blacklisted) |
832 return; | 831 return; |
833 | 832 |
834 // Always make sure the "acknowledged" bit is cleared since the blacklist bit | 833 // Always make sure the "acknowledged" bit is cleared since the blacklist bit |
835 // is changing. | 834 // is changing. |
836 UpdateExtensionPref(extension_id, kPrefBlacklistAcknowledged, NULL); | 835 UpdateExtensionPref(extension_id, kPrefBlacklistAcknowledged, NULL); |
837 | 836 |
838 if (is_blacklisted) { | 837 if (is_blacklisted) { |
839 UpdateExtensionPref(extension_id, | 838 UpdateExtensionPref(extension_id, kPrefBlacklist, new base::Value(true)); |
840 kPrefBlacklist, | |
841 new base::FundamentalValue(true)); | |
842 } else { | 839 } else { |
843 UpdateExtensionPref(extension_id, kPrefBlacklist, NULL); | 840 UpdateExtensionPref(extension_id, kPrefBlacklist, NULL); |
844 const base::DictionaryValue* dict = GetExtensionPref(extension_id); | 841 const base::DictionaryValue* dict = GetExtensionPref(extension_id); |
845 if (dict && dict->empty()) | 842 if (dict && dict->empty()) |
846 DeleteExtensionPrefs(extension_id); | 843 DeleteExtensionPrefs(extension_id); |
847 } | 844 } |
848 } | 845 } |
849 | 846 |
850 bool ExtensionPrefs::IsExtensionBlacklisted(const std::string& id) const { | 847 bool ExtensionPrefs::IsExtensionBlacklisted(const std::string& id) const { |
851 const base::DictionaryValue* ext_prefs = GetExtensionPref(id); | 848 const base::DictionaryValue* ext_prefs = GetExtensionPref(id); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 bool ExtensionPrefs::GetActiveBit(const std::string& extension_id) const { | 933 bool ExtensionPrefs::GetActiveBit(const std::string& extension_id) const { |
937 const base::DictionaryValue* dictionary = GetExtensionPref(extension_id); | 934 const base::DictionaryValue* dictionary = GetExtensionPref(extension_id); |
938 bool result = false; | 935 bool result = false; |
939 if (dictionary && dictionary->GetBoolean(kActiveBit, &result)) | 936 if (dictionary && dictionary->GetBoolean(kActiveBit, &result)) |
940 return result; | 937 return result; |
941 return false; | 938 return false; |
942 } | 939 } |
943 | 940 |
944 void ExtensionPrefs::SetActiveBit(const std::string& extension_id, | 941 void ExtensionPrefs::SetActiveBit(const std::string& extension_id, |
945 bool active) { | 942 bool active) { |
946 UpdateExtensionPref(extension_id, kActiveBit, | 943 UpdateExtensionPref(extension_id, kActiveBit, new base::Value(active)); |
947 new base::FundamentalValue(active)); | |
948 } | 944 } |
949 | 945 |
950 std::unique_ptr<const PermissionSet> ExtensionPrefs::GetGrantedPermissions( | 946 std::unique_ptr<const PermissionSet> ExtensionPrefs::GetGrantedPermissions( |
951 const std::string& extension_id) const { | 947 const std::string& extension_id) const { |
952 CHECK(crx_file::id_util::IdIsValid(extension_id)); | 948 CHECK(crx_file::id_util::IdIsValid(extension_id)); |
953 return ReadPrefAsPermissionSet(extension_id, kPrefGrantedPermissions); | 949 return ReadPrefAsPermissionSet(extension_id, kPrefGrantedPermissions); |
954 } | 950 } |
955 | 951 |
956 void ExtensionPrefs::AddGrantedPermissions(const std::string& extension_id, | 952 void ExtensionPrefs::AddGrantedPermissions(const std::string& extension_id, |
957 const PermissionSet& permissions) { | 953 const PermissionSet& permissions) { |
(...skipping 29 matching lines...) Expand all Loading... |
987 } | 983 } |
988 | 984 |
989 void ExtensionPrefs::SetActivePermissions(const std::string& extension_id, | 985 void ExtensionPrefs::SetActivePermissions(const std::string& extension_id, |
990 const PermissionSet& permissions) { | 986 const PermissionSet& permissions) { |
991 SetExtensionPrefPermissionSet( | 987 SetExtensionPrefPermissionSet( |
992 extension_id, kPrefActivePermissions, permissions); | 988 extension_id, kPrefActivePermissions, permissions); |
993 } | 989 } |
994 | 990 |
995 void ExtensionPrefs::SetExtensionRunning(const std::string& extension_id, | 991 void ExtensionPrefs::SetExtensionRunning(const std::string& extension_id, |
996 bool is_running) { | 992 bool is_running) { |
997 base::Value* value = new base::FundamentalValue(is_running); | 993 base::Value* value = new base::Value(is_running); |
998 UpdateExtensionPref(extension_id, kPrefRunning, value); | 994 UpdateExtensionPref(extension_id, kPrefRunning, value); |
999 } | 995 } |
1000 | 996 |
1001 bool ExtensionPrefs::IsExtensionRunning(const std::string& extension_id) const { | 997 bool ExtensionPrefs::IsExtensionRunning(const std::string& extension_id) const { |
1002 const base::DictionaryValue* extension = GetExtensionPref(extension_id); | 998 const base::DictionaryValue* extension = GetExtensionPref(extension_id); |
1003 if (!extension) | 999 if (!extension) |
1004 return false; | 1000 return false; |
1005 bool running = false; | 1001 bool running = false; |
1006 extension->GetBoolean(kPrefRunning, &running); | 1002 extension->GetBoolean(kPrefRunning, &running); |
1007 return running; | 1003 return running; |
1008 } | 1004 } |
1009 | 1005 |
1010 void ExtensionPrefs::SetIsActive(const std::string& extension_id, | 1006 void ExtensionPrefs::SetIsActive(const std::string& extension_id, |
1011 bool is_active) { | 1007 bool is_active) { |
1012 base::Value* value = new base::FundamentalValue(is_active); | 1008 base::Value* value = new base::Value(is_active); |
1013 UpdateExtensionPref(extension_id, kIsActive, value); | 1009 UpdateExtensionPref(extension_id, kIsActive, value); |
1014 } | 1010 } |
1015 | 1011 |
1016 bool ExtensionPrefs::IsActive(const std::string& extension_id) const { | 1012 bool ExtensionPrefs::IsActive(const std::string& extension_id) const { |
1017 const base::DictionaryValue* extension = GetExtensionPref(extension_id); | 1013 const base::DictionaryValue* extension = GetExtensionPref(extension_id); |
1018 if (!extension) | 1014 if (!extension) |
1019 return false; | 1015 return false; |
1020 bool is_active = false; | 1016 bool is_active = false; |
1021 extension->GetBoolean(kIsActive, &is_active); | 1017 extension->GetBoolean(kIsActive, &is_active); |
1022 return is_active; | 1018 return is_active; |
1023 } | 1019 } |
1024 | 1020 |
1025 bool ExtensionPrefs::IsIncognitoEnabled(const std::string& extension_id) const { | 1021 bool ExtensionPrefs::IsIncognitoEnabled(const std::string& extension_id) const { |
1026 return ReadPrefAsBooleanAndReturn(extension_id, kPrefIncognitoEnabled); | 1022 return ReadPrefAsBooleanAndReturn(extension_id, kPrefIncognitoEnabled); |
1027 } | 1023 } |
1028 | 1024 |
1029 void ExtensionPrefs::SetIsIncognitoEnabled(const std::string& extension_id, | 1025 void ExtensionPrefs::SetIsIncognitoEnabled(const std::string& extension_id, |
1030 bool enabled) { | 1026 bool enabled) { |
1031 UpdateExtensionPref(extension_id, kPrefIncognitoEnabled, | 1027 UpdateExtensionPref(extension_id, kPrefIncognitoEnabled, |
1032 new base::FundamentalValue(enabled)); | 1028 new base::Value(enabled)); |
1033 extension_pref_value_map_->SetExtensionIncognitoState(extension_id, enabled); | 1029 extension_pref_value_map_->SetExtensionIncognitoState(extension_id, enabled); |
1034 } | 1030 } |
1035 | 1031 |
1036 bool ExtensionPrefs::AllowFileAccess(const std::string& extension_id) const { | 1032 bool ExtensionPrefs::AllowFileAccess(const std::string& extension_id) const { |
1037 return ReadPrefAsBooleanAndReturn(extension_id, kPrefAllowFileAccess); | 1033 return ReadPrefAsBooleanAndReturn(extension_id, kPrefAllowFileAccess); |
1038 } | 1034 } |
1039 | 1035 |
1040 void ExtensionPrefs::SetAllowFileAccess(const std::string& extension_id, | 1036 void ExtensionPrefs::SetAllowFileAccess(const std::string& extension_id, |
1041 bool allow) { | 1037 bool allow) { |
1042 UpdateExtensionPref(extension_id, kPrefAllowFileAccess, | 1038 UpdateExtensionPref(extension_id, kPrefAllowFileAccess, |
1043 new base::FundamentalValue(allow)); | 1039 new base::Value(allow)); |
1044 } | 1040 } |
1045 | 1041 |
1046 bool ExtensionPrefs::HasAllowFileAccessSetting( | 1042 bool ExtensionPrefs::HasAllowFileAccessSetting( |
1047 const std::string& extension_id) const { | 1043 const std::string& extension_id) const { |
1048 const base::DictionaryValue* ext = GetExtensionPref(extension_id); | 1044 const base::DictionaryValue* ext = GetExtensionPref(extension_id); |
1049 return ext && ext->HasKey(kPrefAllowFileAccess); | 1045 return ext && ext->HasKey(kPrefAllowFileAccess); |
1050 } | 1046 } |
1051 | 1047 |
1052 bool ExtensionPrefs::DoesExtensionHaveState( | 1048 bool ExtensionPrefs::DoesExtensionHaveState( |
1053 const std::string& id, Extension::State check_state) const { | 1049 const std::string& id, Extension::State check_state) const { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 void ExtensionPrefs::OnExtensionUninstalled(const std::string& extension_id, | 1103 void ExtensionPrefs::OnExtensionUninstalled(const std::string& extension_id, |
1108 const Manifest::Location& location, | 1104 const Manifest::Location& location, |
1109 bool external_uninstall) { | 1105 bool external_uninstall) { |
1110 app_sorting()->ClearOrdinals(extension_id); | 1106 app_sorting()->ClearOrdinals(extension_id); |
1111 | 1107 |
1112 // For external extensions, we save a preference reminding ourself not to try | 1108 // For external extensions, we save a preference reminding ourself not to try |
1113 // and install the extension anymore (except when |external_uninstall| is | 1109 // and install the extension anymore (except when |external_uninstall| is |
1114 // true, which signifies that the registry key was deleted or the pref file | 1110 // true, which signifies that the registry key was deleted or the pref file |
1115 // no longer lists the extension). | 1111 // no longer lists the extension). |
1116 if (!external_uninstall && Manifest::IsExternalLocation(location)) { | 1112 if (!external_uninstall && Manifest::IsExternalLocation(location)) { |
1117 UpdateExtensionPref(extension_id, kPrefState, | 1113 UpdateExtensionPref( |
1118 new base::FundamentalValue( | 1114 extension_id, kPrefState, |
1119 Extension::EXTERNAL_EXTENSION_UNINSTALLED)); | 1115 new base::Value(Extension::EXTERNAL_EXTENSION_UNINSTALLED)); |
1120 extension_pref_value_map_->SetExtensionState(extension_id, false); | 1116 extension_pref_value_map_->SetExtensionState(extension_id, false); |
1121 for (auto& observer : observer_list_) | 1117 for (auto& observer : observer_list_) |
1122 observer.OnExtensionStateChanged(extension_id, false); | 1118 observer.OnExtensionStateChanged(extension_id, false); |
1123 } else { | 1119 } else { |
1124 DeleteExtensionPrefs(extension_id); | 1120 DeleteExtensionPrefs(extension_id); |
1125 } | 1121 } |
1126 } | 1122 } |
1127 | 1123 |
1128 void ExtensionPrefs::SetExtensionEnabled(const std::string& extension_id) { | 1124 void ExtensionPrefs::SetExtensionEnabled(const std::string& extension_id) { |
1129 UpdateExtensionPref(extension_id, kPrefState, | 1125 UpdateExtensionPref(extension_id, kPrefState, |
1130 new base::FundamentalValue(Extension::ENABLED)); | 1126 new base::Value(Extension::ENABLED)); |
1131 extension_pref_value_map_->SetExtensionState(extension_id, true); | 1127 extension_pref_value_map_->SetExtensionState(extension_id, true); |
1132 UpdateExtensionPref(extension_id, kPrefDisableReasons, nullptr); | 1128 UpdateExtensionPref(extension_id, kPrefDisableReasons, nullptr); |
1133 for (auto& observer : observer_list_) | 1129 for (auto& observer : observer_list_) |
1134 observer.OnExtensionStateChanged(extension_id, true); | 1130 observer.OnExtensionStateChanged(extension_id, true); |
1135 } | 1131 } |
1136 | 1132 |
1137 void ExtensionPrefs::SetExtensionDisabled(const std::string& extension_id, | 1133 void ExtensionPrefs::SetExtensionDisabled(const std::string& extension_id, |
1138 int disable_reasons) { | 1134 int disable_reasons) { |
1139 if (!IsExternalExtensionUninstalled(extension_id)) { | 1135 if (!IsExternalExtensionUninstalled(extension_id)) { |
1140 UpdateExtensionPref(extension_id, kPrefState, | 1136 UpdateExtensionPref(extension_id, kPrefState, |
1141 new base::FundamentalValue(Extension::DISABLED)); | 1137 new base::Value(Extension::DISABLED)); |
1142 extension_pref_value_map_->SetExtensionState(extension_id, false); | 1138 extension_pref_value_map_->SetExtensionState(extension_id, false); |
1143 } | 1139 } |
1144 UpdateExtensionPref(extension_id, kPrefDisableReasons, | 1140 UpdateExtensionPref(extension_id, kPrefDisableReasons, |
1145 new base::FundamentalValue(disable_reasons)); | 1141 new base::Value(disable_reasons)); |
1146 for (auto& observer : observer_list_) | 1142 for (auto& observer : observer_list_) |
1147 observer.OnExtensionStateChanged(extension_id, false); | 1143 observer.OnExtensionStateChanged(extension_id, false); |
1148 } | 1144 } |
1149 | 1145 |
1150 void ExtensionPrefs::SetExtensionBlacklistState(const std::string& extension_id, | 1146 void ExtensionPrefs::SetExtensionBlacklistState(const std::string& extension_id, |
1151 BlacklistState state) { | 1147 BlacklistState state) { |
1152 SetExtensionBlacklisted(extension_id, state == BLACKLISTED_MALWARE); | 1148 SetExtensionBlacklisted(extension_id, state == BLACKLISTED_MALWARE); |
1153 UpdateExtensionPref(extension_id, kPrefBlacklistState, | 1149 UpdateExtensionPref(extension_id, kPrefBlacklistState, |
1154 new base::FundamentalValue(state)); | 1150 new base::Value(state)); |
1155 } | 1151 } |
1156 | 1152 |
1157 BlacklistState ExtensionPrefs::GetExtensionBlacklistState( | 1153 BlacklistState ExtensionPrefs::GetExtensionBlacklistState( |
1158 const std::string& extension_id) const { | 1154 const std::string& extension_id) const { |
1159 if (IsExtensionBlacklisted(extension_id)) | 1155 if (IsExtensionBlacklisted(extension_id)) |
1160 return BLACKLISTED_MALWARE; | 1156 return BLACKLISTED_MALWARE; |
1161 const base::DictionaryValue* ext_prefs = GetExtensionPref(extension_id); | 1157 const base::DictionaryValue* ext_prefs = GetExtensionPref(extension_id); |
1162 int int_value = 0; | 1158 int int_value = 0; |
1163 if (ext_prefs && ext_prefs->GetInteger(kPrefBlacklistState, &int_value)) | 1159 if (ext_prefs && ext_prefs->GetInteger(kPrefBlacklistState, &int_value)) |
1164 return static_cast<BlacklistState>(int_value); | 1160 return static_cast<BlacklistState>(int_value); |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1429 | 1425 |
1430 return extensions_info; | 1426 return extensions_info; |
1431 } | 1427 } |
1432 | 1428 |
1433 bool ExtensionPrefs::WasAppDraggedByUser( | 1429 bool ExtensionPrefs::WasAppDraggedByUser( |
1434 const std::string& extension_id) const { | 1430 const std::string& extension_id) const { |
1435 return ReadPrefAsBooleanAndReturn(extension_id, kPrefUserDraggedApp); | 1431 return ReadPrefAsBooleanAndReturn(extension_id, kPrefUserDraggedApp); |
1436 } | 1432 } |
1437 | 1433 |
1438 void ExtensionPrefs::SetAppDraggedByUser(const std::string& extension_id) { | 1434 void ExtensionPrefs::SetAppDraggedByUser(const std::string& extension_id) { |
1439 UpdateExtensionPref(extension_id, kPrefUserDraggedApp, | 1435 UpdateExtensionPref(extension_id, kPrefUserDraggedApp, new base::Value(true)); |
1440 new base::FundamentalValue(true)); | |
1441 } | 1436 } |
1442 | 1437 |
1443 bool ExtensionPrefs::IsFromWebStore( | 1438 bool ExtensionPrefs::IsFromWebStore( |
1444 const std::string& extension_id) const { | 1439 const std::string& extension_id) const { |
1445 const base::DictionaryValue* dictionary = GetExtensionPref(extension_id); | 1440 const base::DictionaryValue* dictionary = GetExtensionPref(extension_id); |
1446 bool result = false; | 1441 bool result = false; |
1447 if (dictionary && dictionary->GetBoolean(kPrefFromWebStore, &result)) | 1442 if (dictionary && dictionary->GetBoolean(kPrefFromWebStore, &result)) |
1448 return result; | 1443 return result; |
1449 return false; | 1444 return false; |
1450 } | 1445 } |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1713 prefs_->SetInteger(kCorruptedDisableCount, count + 1); | 1708 prefs_->SetInteger(kCorruptedDisableCount, count + 1); |
1714 } | 1709 } |
1715 | 1710 |
1716 bool ExtensionPrefs::NeedsSync(const std::string& extension_id) const { | 1711 bool ExtensionPrefs::NeedsSync(const std::string& extension_id) const { |
1717 return ReadPrefAsBooleanAndReturn(extension_id, kPrefNeedsSync); | 1712 return ReadPrefAsBooleanAndReturn(extension_id, kPrefNeedsSync); |
1718 } | 1713 } |
1719 | 1714 |
1720 void ExtensionPrefs::SetNeedsSync(const std::string& extension_id, | 1715 void ExtensionPrefs::SetNeedsSync(const std::string& extension_id, |
1721 bool needs_sync) { | 1716 bool needs_sync) { |
1722 UpdateExtensionPref(extension_id, kPrefNeedsSync, | 1717 UpdateExtensionPref(extension_id, kPrefNeedsSync, |
1723 needs_sync ? new base::FundamentalValue(true) : nullptr); | 1718 needs_sync ? new base::Value(true) : nullptr); |
1724 } | 1719 } |
1725 | 1720 |
1726 ExtensionPrefs::ExtensionPrefs( | 1721 ExtensionPrefs::ExtensionPrefs( |
1727 content::BrowserContext* browser_context, | 1722 content::BrowserContext* browser_context, |
1728 PrefService* prefs, | 1723 PrefService* prefs, |
1729 const base::FilePath& root_dir, | 1724 const base::FilePath& root_dir, |
1730 ExtensionPrefValueMap* extension_pref_value_map, | 1725 ExtensionPrefValueMap* extension_pref_value_map, |
1731 std::unique_ptr<TimeProvider> time_provider, | 1726 std::unique_ptr<TimeProvider> time_provider, |
1732 bool extensions_disabled, | 1727 bool extensions_disabled, |
1733 const std::vector<ExtensionPrefsObserver*>& early_observers) | 1728 const std::vector<ExtensionPrefsObserver*>& early_observers) |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1830 } | 1825 } |
1831 } | 1826 } |
1832 | 1827 |
1833 void ExtensionPrefs::PopulateExtensionInfoPrefs( | 1828 void ExtensionPrefs::PopulateExtensionInfoPrefs( |
1834 const Extension* extension, | 1829 const Extension* extension, |
1835 const base::Time install_time, | 1830 const base::Time install_time, |
1836 Extension::State initial_state, | 1831 Extension::State initial_state, |
1837 int install_flags, | 1832 int install_flags, |
1838 const std::string& install_parameter, | 1833 const std::string& install_parameter, |
1839 base::DictionaryValue* extension_dict) const { | 1834 base::DictionaryValue* extension_dict) const { |
1840 extension_dict->Set(kPrefState, new base::FundamentalValue(initial_state)); | 1835 extension_dict->Set(kPrefState, new base::Value(initial_state)); |
1841 extension_dict->Set(kPrefLocation, | 1836 extension_dict->Set(kPrefLocation, new base::Value(extension->location())); |
1842 new base::FundamentalValue(extension->location())); | |
1843 extension_dict->Set(kPrefCreationFlags, | 1837 extension_dict->Set(kPrefCreationFlags, |
1844 new base::FundamentalValue(extension->creation_flags())); | 1838 new base::Value(extension->creation_flags())); |
1845 extension_dict->Set(kPrefFromWebStore, | 1839 extension_dict->Set(kPrefFromWebStore, |
1846 new base::FundamentalValue(extension->from_webstore())); | 1840 new base::Value(extension->from_webstore())); |
1847 extension_dict->Set(kPrefFromBookmark, | 1841 extension_dict->Set(kPrefFromBookmark, |
1848 new base::FundamentalValue(extension->from_bookmark())); | 1842 new base::Value(extension->from_bookmark())); |
1849 extension_dict->Set( | 1843 extension_dict->Set(kPrefWasInstalledByDefault, |
1850 kPrefWasInstalledByDefault, | 1844 new base::Value(extension->was_installed_by_default())); |
1851 new base::FundamentalValue(extension->was_installed_by_default())); | 1845 extension_dict->Set(kPrefWasInstalledByOem, |
1852 extension_dict->Set( | 1846 new base::Value(extension->was_installed_by_oem())); |
1853 kPrefWasInstalledByOem, | |
1854 new base::FundamentalValue(extension->was_installed_by_oem())); | |
1855 extension_dict->Set(kPrefInstallTime, | 1847 extension_dict->Set(kPrefInstallTime, |
1856 new base::StringValue( | 1848 new base::StringValue( |
1857 base::Int64ToString(install_time.ToInternalValue()))); | 1849 base::Int64ToString(install_time.ToInternalValue()))); |
1858 if (install_flags & kInstallFlagIsBlacklistedForMalware) | 1850 if (install_flags & kInstallFlagIsBlacklistedForMalware) |
1859 extension_dict->Set(kPrefBlacklist, new base::FundamentalValue(true)); | 1851 extension_dict->Set(kPrefBlacklist, new base::Value(true)); |
1860 | 1852 |
1861 base::FilePath::StringType path = MakePathRelative(install_directory_, | 1853 base::FilePath::StringType path = MakePathRelative(install_directory_, |
1862 extension->path()); | 1854 extension->path()); |
1863 extension_dict->Set(kPrefPath, new base::StringValue(path)); | 1855 extension_dict->Set(kPrefPath, new base::StringValue(path)); |
1864 if (!install_parameter.empty()) { | 1856 if (!install_parameter.empty()) { |
1865 extension_dict->Set(kPrefInstallParam, | 1857 extension_dict->Set(kPrefInstallParam, |
1866 new base::StringValue(install_parameter)); | 1858 new base::StringValue(install_parameter)); |
1867 } | 1859 } |
1868 // We store prefs about LOAD extensions, but don't cache their manifest | 1860 // We store prefs about LOAD extensions, but don't cache their manifest |
1869 // since it may change on disk. | 1861 // since it may change on disk. |
1870 if (!Manifest::IsUnpackedLocation(extension->location())) { | 1862 if (!Manifest::IsUnpackedLocation(extension->location())) { |
1871 extension_dict->Set(kPrefManifest, | 1863 extension_dict->Set(kPrefManifest, |
1872 extension->manifest()->value()->DeepCopy()); | 1864 extension->manifest()->value()->DeepCopy()); |
1873 } | 1865 } |
1874 | 1866 |
1875 // Only writes kPrefDoNotSync when it is not the default. | 1867 // Only writes kPrefDoNotSync when it is not the default. |
1876 if (install_flags & kInstallFlagDoNotSync) | 1868 if (install_flags & kInstallFlagDoNotSync) |
1877 extension_dict->Set(kPrefDoNotSync, new base::FundamentalValue(true)); | 1869 extension_dict->Set(kPrefDoNotSync, new base::Value(true)); |
1878 else | 1870 else |
1879 extension_dict->Remove(kPrefDoNotSync, NULL); | 1871 extension_dict->Remove(kPrefDoNotSync, NULL); |
1880 } | 1872 } |
1881 | 1873 |
1882 void ExtensionPrefs::InitExtensionControlledPrefs( | 1874 void ExtensionPrefs::InitExtensionControlledPrefs( |
1883 ExtensionPrefValueMap* value_map) { | 1875 ExtensionPrefValueMap* value_map) { |
1884 TRACE_EVENT0("browser,startup", | 1876 TRACE_EVENT0("browser,startup", |
1885 "ExtensionPrefs::InitExtensionControlledPrefs") | 1877 "ExtensionPrefs::InitExtensionControlledPrefs") |
1886 SCOPED_UMA_HISTOGRAM_TIMER("Extensions.InitExtensionControlledPrefsTime"); | 1878 SCOPED_UMA_HISTOGRAM_TIMER("Extensions.InitExtensionControlledPrefsTime"); |
1887 | 1879 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1969 bool is_incognito_enabled = IsIncognitoEnabled(extension_id); | 1961 bool is_incognito_enabled = IsIncognitoEnabled(extension_id); |
1970 | 1962 |
1971 extension_pref_value_map_->RegisterExtension( | 1963 extension_pref_value_map_->RegisterExtension( |
1972 extension_id, install_time, is_enabled, is_incognito_enabled); | 1964 extension_id, install_time, is_enabled, is_incognito_enabled); |
1973 | 1965 |
1974 for (auto& observer : observer_list_) | 1966 for (auto& observer : observer_list_) |
1975 observer.OnExtensionRegistered(extension_id, install_time, is_enabled); | 1967 observer.OnExtensionRegistered(extension_id, install_time, is_enabled); |
1976 } | 1968 } |
1977 | 1969 |
1978 } // namespace extensions | 1970 } // namespace extensions |
OLD | NEW |