Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1022)

Side by Side Diff: extensions/browser/extension_prefs.cc

Issue 2476493003: Remove FundamentalValue
Patch Set: Fix Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 new_value.scriptable_hosts()); 666 new_value.scriptable_hosts());
667 } 667 }
668 } 668 }
669 669
670 int ExtensionPrefs::IncrementAcknowledgePromptCount( 670 int ExtensionPrefs::IncrementAcknowledgePromptCount(
671 const std::string& extension_id) { 671 const std::string& extension_id) {
672 int count = 0; 672 int count = 0;
673 ReadPrefAsInteger(extension_id, kPrefAcknowledgePromptCount, &count); 673 ReadPrefAsInteger(extension_id, kPrefAcknowledgePromptCount, &count);
674 ++count; 674 ++count;
675 UpdateExtensionPref(extension_id, kPrefAcknowledgePromptCount, 675 UpdateExtensionPref(extension_id, kPrefAcknowledgePromptCount,
676 new base::FundamentalValue(count)); 676 new base::Value(count));
677 return count; 677 return count;
678 } 678 }
679 679
680 bool ExtensionPrefs::IsExternalExtensionAcknowledged( 680 bool ExtensionPrefs::IsExternalExtensionAcknowledged(
681 const std::string& extension_id) const { 681 const std::string& extension_id) const {
682 return ReadPrefAsBooleanAndReturn(extension_id, kPrefExternalAcknowledged); 682 return ReadPrefAsBooleanAndReturn(extension_id, kPrefExternalAcknowledged);
683 } 683 }
684 684
685 void ExtensionPrefs::AcknowledgeExternalExtension( 685 void ExtensionPrefs::AcknowledgeExternalExtension(
686 const std::string& extension_id) { 686 const std::string& extension_id) {
687 DCHECK(crx_file::id_util::IdIsValid(extension_id)); 687 DCHECK(crx_file::id_util::IdIsValid(extension_id));
688 UpdateExtensionPref(extension_id, kPrefExternalAcknowledged, 688 UpdateExtensionPref(extension_id, kPrefExternalAcknowledged,
689 new base::FundamentalValue(true)); 689 new base::Value(true));
690 UpdateExtensionPref(extension_id, kPrefAcknowledgePromptCount, NULL); 690 UpdateExtensionPref(extension_id, kPrefAcknowledgePromptCount, NULL);
691 } 691 }
692 692
693 bool ExtensionPrefs::IsBlacklistedExtensionAcknowledged( 693 bool ExtensionPrefs::IsBlacklistedExtensionAcknowledged(
694 const std::string& extension_id) const { 694 const std::string& extension_id) const {
695 return ReadPrefAsBooleanAndReturn(extension_id, kPrefBlacklistAcknowledged); 695 return ReadPrefAsBooleanAndReturn(extension_id, kPrefBlacklistAcknowledged);
696 } 696 }
697 697
698 void ExtensionPrefs::AcknowledgeBlacklistedExtension( 698 void ExtensionPrefs::AcknowledgeBlacklistedExtension(
699 const std::string& extension_id) { 699 const std::string& extension_id) {
700 DCHECK(crx_file::id_util::IdIsValid(extension_id)); 700 DCHECK(crx_file::id_util::IdIsValid(extension_id));
701 UpdateExtensionPref(extension_id, kPrefBlacklistAcknowledged, 701 UpdateExtensionPref(extension_id, kPrefBlacklistAcknowledged,
702 new base::FundamentalValue(true)); 702 new base::Value(true));
703 UpdateExtensionPref(extension_id, kPrefAcknowledgePromptCount, NULL); 703 UpdateExtensionPref(extension_id, kPrefAcknowledgePromptCount, NULL);
704 } 704 }
705 705
706 bool ExtensionPrefs::IsExternalInstallFirstRun( 706 bool ExtensionPrefs::IsExternalInstallFirstRun(
707 const std::string& extension_id) const { 707 const std::string& extension_id) const {
708 return ReadPrefAsBooleanAndReturn(extension_id, kPrefExternalInstallFirstRun); 708 return ReadPrefAsBooleanAndReturn(extension_id, kPrefExternalInstallFirstRun);
709 } 709 }
710 710
711 void ExtensionPrefs::SetExternalInstallFirstRun( 711 void ExtensionPrefs::SetExternalInstallFirstRun(
712 const std::string& extension_id) { 712 const std::string& extension_id) {
713 DCHECK(crx_file::id_util::IdIsValid(extension_id)); 713 DCHECK(crx_file::id_util::IdIsValid(extension_id));
714 UpdateExtensionPref(extension_id, kPrefExternalInstallFirstRun, 714 UpdateExtensionPref(extension_id, kPrefExternalInstallFirstRun,
715 new base::FundamentalValue(true)); 715 new base::Value(true));
716 } 716 }
717 717
718 bool ExtensionPrefs::SetAlertSystemFirstRun() { 718 bool ExtensionPrefs::SetAlertSystemFirstRun() {
719 if (prefs_->GetBoolean(pref_names::kAlertsInitialized)) { 719 if (prefs_->GetBoolean(pref_names::kAlertsInitialized)) {
720 return true; 720 return true;
721 } 721 }
722 prefs_->SetBoolean(pref_names::kAlertsInitialized, true); 722 prefs_->SetBoolean(pref_names::kAlertsInitialized, true);
723 return false; 723 return false;
724 } 724 }
725 725
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 new_value = Extension::DISABLE_NONE; 792 new_value = Extension::DISABLE_NONE;
793 break; 793 break;
794 } 794 }
795 795
796 if (old_value == new_value) // no change, return. 796 if (old_value == new_value) // no change, return.
797 return; 797 return;
798 798
799 if (new_value == Extension::DISABLE_NONE) { 799 if (new_value == Extension::DISABLE_NONE) {
800 UpdateExtensionPref(extension_id, kPrefDisableReasons, NULL); 800 UpdateExtensionPref(extension_id, kPrefDisableReasons, NULL);
801 } else { 801 } else {
802 UpdateExtensionPref(extension_id, 802 UpdateExtensionPref(extension_id, kPrefDisableReasons,
803 kPrefDisableReasons, 803 new base::Value(new_value));
804 new base::FundamentalValue(new_value));
805 } 804 }
806 805
807 for (auto& observer : observer_list_) 806 for (auto& observer : observer_list_)
808 observer.OnExtensionDisableReasonsChanged(extension_id, new_value); 807 observer.OnExtensionDisableReasonsChanged(extension_id, new_value);
809 } 808 }
810 809
811 std::set<std::string> ExtensionPrefs::GetBlacklistedExtensions() const { 810 std::set<std::string> ExtensionPrefs::GetBlacklistedExtensions() const {
812 std::set<std::string> ids; 811 std::set<std::string> ids;
813 812
814 const base::DictionaryValue* extensions = 813 const base::DictionaryValue* extensions =
(...skipping 20 matching lines...) Expand all
835 bool is_blacklisted) { 834 bool is_blacklisted) {
836 bool currently_blacklisted = IsExtensionBlacklisted(extension_id); 835 bool currently_blacklisted = IsExtensionBlacklisted(extension_id);
837 if (is_blacklisted == currently_blacklisted) 836 if (is_blacklisted == currently_blacklisted)
838 return; 837 return;
839 838
840 // Always make sure the "acknowledged" bit is cleared since the blacklist bit 839 // Always make sure the "acknowledged" bit is cleared since the blacklist bit
841 // is changing. 840 // is changing.
842 UpdateExtensionPref(extension_id, kPrefBlacklistAcknowledged, NULL); 841 UpdateExtensionPref(extension_id, kPrefBlacklistAcknowledged, NULL);
843 842
844 if (is_blacklisted) { 843 if (is_blacklisted) {
845 UpdateExtensionPref(extension_id, 844 UpdateExtensionPref(extension_id, kPrefBlacklist, new base::Value(true));
846 kPrefBlacklist,
847 new base::FundamentalValue(true));
848 } else { 845 } else {
849 UpdateExtensionPref(extension_id, kPrefBlacklist, NULL); 846 UpdateExtensionPref(extension_id, kPrefBlacklist, NULL);
850 const base::DictionaryValue* dict = GetExtensionPref(extension_id); 847 const base::DictionaryValue* dict = GetExtensionPref(extension_id);
851 if (dict && dict->empty()) 848 if (dict && dict->empty())
852 DeleteExtensionPrefs(extension_id); 849 DeleteExtensionPrefs(extension_id);
853 } 850 }
854 } 851 }
855 852
856 bool ExtensionPrefs::IsExtensionBlacklisted(const std::string& id) const { 853 bool ExtensionPrefs::IsExtensionBlacklisted(const std::string& id) const {
857 const base::DictionaryValue* ext_prefs = GetExtensionPref(id); 854 const base::DictionaryValue* ext_prefs = GetExtensionPref(id);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 bool ExtensionPrefs::GetActiveBit(const std::string& extension_id) const { 939 bool ExtensionPrefs::GetActiveBit(const std::string& extension_id) const {
943 const base::DictionaryValue* dictionary = GetExtensionPref(extension_id); 940 const base::DictionaryValue* dictionary = GetExtensionPref(extension_id);
944 bool result = false; 941 bool result = false;
945 if (dictionary && dictionary->GetBoolean(kActiveBit, &result)) 942 if (dictionary && dictionary->GetBoolean(kActiveBit, &result))
946 return result; 943 return result;
947 return false; 944 return false;
948 } 945 }
949 946
950 void ExtensionPrefs::SetActiveBit(const std::string& extension_id, 947 void ExtensionPrefs::SetActiveBit(const std::string& extension_id,
951 bool active) { 948 bool active) {
952 UpdateExtensionPref(extension_id, kActiveBit, 949 UpdateExtensionPref(extension_id, kActiveBit, new base::Value(active));
953 new base::FundamentalValue(active));
954 } 950 }
955 951
956 std::unique_ptr<const PermissionSet> ExtensionPrefs::GetGrantedPermissions( 952 std::unique_ptr<const PermissionSet> ExtensionPrefs::GetGrantedPermissions(
957 const std::string& extension_id) const { 953 const std::string& extension_id) const {
958 CHECK(crx_file::id_util::IdIsValid(extension_id)); 954 CHECK(crx_file::id_util::IdIsValid(extension_id));
959 return ReadPrefAsPermissionSet(extension_id, kPrefGrantedPermissions); 955 return ReadPrefAsPermissionSet(extension_id, kPrefGrantedPermissions);
960 } 956 }
961 957
962 void ExtensionPrefs::AddGrantedPermissions(const std::string& extension_id, 958 void ExtensionPrefs::AddGrantedPermissions(const std::string& extension_id,
963 const PermissionSet& permissions) { 959 const PermissionSet& permissions) {
(...skipping 29 matching lines...) Expand all
993 } 989 }
994 990
995 void ExtensionPrefs::SetActivePermissions(const std::string& extension_id, 991 void ExtensionPrefs::SetActivePermissions(const std::string& extension_id,
996 const PermissionSet& permissions) { 992 const PermissionSet& permissions) {
997 SetExtensionPrefPermissionSet( 993 SetExtensionPrefPermissionSet(
998 extension_id, kPrefActivePermissions, permissions); 994 extension_id, kPrefActivePermissions, permissions);
999 } 995 }
1000 996
1001 void ExtensionPrefs::SetExtensionRunning(const std::string& extension_id, 997 void ExtensionPrefs::SetExtensionRunning(const std::string& extension_id,
1002 bool is_running) { 998 bool is_running) {
1003 base::Value* value = new base::FundamentalValue(is_running); 999 base::Value* value = new base::Value(is_running);
1004 UpdateExtensionPref(extension_id, kPrefRunning, value); 1000 UpdateExtensionPref(extension_id, kPrefRunning, value);
1005 } 1001 }
1006 1002
1007 bool ExtensionPrefs::IsExtensionRunning(const std::string& extension_id) const { 1003 bool ExtensionPrefs::IsExtensionRunning(const std::string& extension_id) const {
1008 const base::DictionaryValue* extension = GetExtensionPref(extension_id); 1004 const base::DictionaryValue* extension = GetExtensionPref(extension_id);
1009 if (!extension) 1005 if (!extension)
1010 return false; 1006 return false;
1011 bool running = false; 1007 bool running = false;
1012 extension->GetBoolean(kPrefRunning, &running); 1008 extension->GetBoolean(kPrefRunning, &running);
1013 return running; 1009 return running;
1014 } 1010 }
1015 1011
1016 void ExtensionPrefs::SetIsActive(const std::string& extension_id, 1012 void ExtensionPrefs::SetIsActive(const std::string& extension_id,
1017 bool is_active) { 1013 bool is_active) {
1018 base::Value* value = new base::FundamentalValue(is_active); 1014 base::Value* value = new base::Value(is_active);
1019 UpdateExtensionPref(extension_id, kIsActive, value); 1015 UpdateExtensionPref(extension_id, kIsActive, value);
1020 } 1016 }
1021 1017
1022 bool ExtensionPrefs::IsActive(const std::string& extension_id) const { 1018 bool ExtensionPrefs::IsActive(const std::string& extension_id) const {
1023 const base::DictionaryValue* extension = GetExtensionPref(extension_id); 1019 const base::DictionaryValue* extension = GetExtensionPref(extension_id);
1024 if (!extension) 1020 if (!extension)
1025 return false; 1021 return false;
1026 bool is_active = false; 1022 bool is_active = false;
1027 extension->GetBoolean(kIsActive, &is_active); 1023 extension->GetBoolean(kIsActive, &is_active);
1028 return is_active; 1024 return is_active;
1029 } 1025 }
1030 1026
1031 bool ExtensionPrefs::IsIncognitoEnabled(const std::string& extension_id) const { 1027 bool ExtensionPrefs::IsIncognitoEnabled(const std::string& extension_id) const {
1032 return ReadPrefAsBooleanAndReturn(extension_id, kPrefIncognitoEnabled); 1028 return ReadPrefAsBooleanAndReturn(extension_id, kPrefIncognitoEnabled);
1033 } 1029 }
1034 1030
1035 void ExtensionPrefs::SetIsIncognitoEnabled(const std::string& extension_id, 1031 void ExtensionPrefs::SetIsIncognitoEnabled(const std::string& extension_id,
1036 bool enabled) { 1032 bool enabled) {
1037 UpdateExtensionPref(extension_id, kPrefIncognitoEnabled, 1033 UpdateExtensionPref(extension_id, kPrefIncognitoEnabled,
1038 new base::FundamentalValue(enabled)); 1034 new base::Value(enabled));
1039 extension_pref_value_map_->SetExtensionIncognitoState(extension_id, enabled); 1035 extension_pref_value_map_->SetExtensionIncognitoState(extension_id, enabled);
1040 } 1036 }
1041 1037
1042 bool ExtensionPrefs::AllowFileAccess(const std::string& extension_id) const { 1038 bool ExtensionPrefs::AllowFileAccess(const std::string& extension_id) const {
1043 return ReadPrefAsBooleanAndReturn(extension_id, kPrefAllowFileAccess); 1039 return ReadPrefAsBooleanAndReturn(extension_id, kPrefAllowFileAccess);
1044 } 1040 }
1045 1041
1046 void ExtensionPrefs::SetAllowFileAccess(const std::string& extension_id, 1042 void ExtensionPrefs::SetAllowFileAccess(const std::string& extension_id,
1047 bool allow) { 1043 bool allow) {
1048 UpdateExtensionPref(extension_id, kPrefAllowFileAccess, 1044 UpdateExtensionPref(extension_id, kPrefAllowFileAccess,
1049 new base::FundamentalValue(allow)); 1045 new base::Value(allow));
1050 } 1046 }
1051 1047
1052 bool ExtensionPrefs::HasAllowFileAccessSetting( 1048 bool ExtensionPrefs::HasAllowFileAccessSetting(
1053 const std::string& extension_id) const { 1049 const std::string& extension_id) const {
1054 const base::DictionaryValue* ext = GetExtensionPref(extension_id); 1050 const base::DictionaryValue* ext = GetExtensionPref(extension_id);
1055 return ext && ext->HasKey(kPrefAllowFileAccess); 1051 return ext && ext->HasKey(kPrefAllowFileAccess);
1056 } 1052 }
1057 1053
1058 bool ExtensionPrefs::DoesExtensionHaveState( 1054 bool ExtensionPrefs::DoesExtensionHaveState(
1059 const std::string& id, Extension::State check_state) const { 1055 const std::string& id, Extension::State check_state) const {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 void ExtensionPrefs::OnExtensionUninstalled(const std::string& extension_id, 1109 void ExtensionPrefs::OnExtensionUninstalled(const std::string& extension_id,
1114 const Manifest::Location& location, 1110 const Manifest::Location& location,
1115 bool external_uninstall) { 1111 bool external_uninstall) {
1116 app_sorting()->ClearOrdinals(extension_id); 1112 app_sorting()->ClearOrdinals(extension_id);
1117 1113
1118 // For external extensions, we save a preference reminding ourself not to try 1114 // For external extensions, we save a preference reminding ourself not to try
1119 // and install the extension anymore (except when |external_uninstall| is 1115 // and install the extension anymore (except when |external_uninstall| is
1120 // true, which signifies that the registry key was deleted or the pref file 1116 // true, which signifies that the registry key was deleted or the pref file
1121 // no longer lists the extension). 1117 // no longer lists the extension).
1122 if (!external_uninstall && Manifest::IsExternalLocation(location)) { 1118 if (!external_uninstall && Manifest::IsExternalLocation(location)) {
1123 UpdateExtensionPref(extension_id, kPrefState, 1119 UpdateExtensionPref(
1124 new base::FundamentalValue( 1120 extension_id, kPrefState,
1125 Extension::EXTERNAL_EXTENSION_UNINSTALLED)); 1121 new base::Value(Extension::EXTERNAL_EXTENSION_UNINSTALLED));
1126 extension_pref_value_map_->SetExtensionState(extension_id, false); 1122 extension_pref_value_map_->SetExtensionState(extension_id, false);
1127 for (auto& observer : observer_list_) 1123 for (auto& observer : observer_list_)
1128 observer.OnExtensionStateChanged(extension_id, false); 1124 observer.OnExtensionStateChanged(extension_id, false);
1129 } else { 1125 } else {
1130 DeleteExtensionPrefs(extension_id); 1126 DeleteExtensionPrefs(extension_id);
1131 } 1127 }
1132 } 1128 }
1133 1129
1134 void ExtensionPrefs::SetExtensionEnabled(const std::string& extension_id) { 1130 void ExtensionPrefs::SetExtensionEnabled(const std::string& extension_id) {
1135 UpdateExtensionPref(extension_id, kPrefState, 1131 UpdateExtensionPref(extension_id, kPrefState,
1136 new base::FundamentalValue(Extension::ENABLED)); 1132 new base::Value(Extension::ENABLED));
1137 extension_pref_value_map_->SetExtensionState(extension_id, true); 1133 extension_pref_value_map_->SetExtensionState(extension_id, true);
1138 UpdateExtensionPref(extension_id, kPrefDisableReasons, nullptr); 1134 UpdateExtensionPref(extension_id, kPrefDisableReasons, nullptr);
1139 for (auto& observer : observer_list_) 1135 for (auto& observer : observer_list_)
1140 observer.OnExtensionStateChanged(extension_id, true); 1136 observer.OnExtensionStateChanged(extension_id, true);
1141 } 1137 }
1142 1138
1143 void ExtensionPrefs::SetExtensionDisabled(const std::string& extension_id, 1139 void ExtensionPrefs::SetExtensionDisabled(const std::string& extension_id,
1144 int disable_reasons) { 1140 int disable_reasons) {
1145 if (!IsExternalExtensionUninstalled(extension_id)) { 1141 if (!IsExternalExtensionUninstalled(extension_id)) {
1146 UpdateExtensionPref(extension_id, kPrefState, 1142 UpdateExtensionPref(extension_id, kPrefState,
1147 new base::FundamentalValue(Extension::DISABLED)); 1143 new base::Value(Extension::DISABLED));
1148 extension_pref_value_map_->SetExtensionState(extension_id, false); 1144 extension_pref_value_map_->SetExtensionState(extension_id, false);
1149 } 1145 }
1150 UpdateExtensionPref(extension_id, kPrefDisableReasons, 1146 UpdateExtensionPref(extension_id, kPrefDisableReasons,
1151 new base::FundamentalValue(disable_reasons)); 1147 new base::Value(disable_reasons));
1152 for (auto& observer : observer_list_) 1148 for (auto& observer : observer_list_)
1153 observer.OnExtensionStateChanged(extension_id, false); 1149 observer.OnExtensionStateChanged(extension_id, false);
1154 } 1150 }
1155 1151
1156 void ExtensionPrefs::SetExtensionBlacklistState(const std::string& extension_id, 1152 void ExtensionPrefs::SetExtensionBlacklistState(const std::string& extension_id,
1157 BlacklistState state) { 1153 BlacklistState state) {
1158 SetExtensionBlacklisted(extension_id, state == BLACKLISTED_MALWARE); 1154 SetExtensionBlacklisted(extension_id, state == BLACKLISTED_MALWARE);
1159 UpdateExtensionPref(extension_id, kPrefBlacklistState, 1155 UpdateExtensionPref(extension_id, kPrefBlacklistState,
1160 new base::FundamentalValue(state)); 1156 new base::Value(state));
1161 } 1157 }
1162 1158
1163 BlacklistState ExtensionPrefs::GetExtensionBlacklistState( 1159 BlacklistState ExtensionPrefs::GetExtensionBlacklistState(
1164 const std::string& extension_id) const { 1160 const std::string& extension_id) const {
1165 if (IsExtensionBlacklisted(extension_id)) 1161 if (IsExtensionBlacklisted(extension_id))
1166 return BLACKLISTED_MALWARE; 1162 return BLACKLISTED_MALWARE;
1167 const base::DictionaryValue* ext_prefs = GetExtensionPref(extension_id); 1163 const base::DictionaryValue* ext_prefs = GetExtensionPref(extension_id);
1168 int int_value = 0; 1164 int int_value = 0;
1169 if (ext_prefs && ext_prefs->GetInteger(kPrefBlacklistState, &int_value)) 1165 if (ext_prefs && ext_prefs->GetInteger(kPrefBlacklistState, &int_value))
1170 return static_cast<BlacklistState>(int_value); 1166 return static_cast<BlacklistState>(int_value);
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 1431
1436 return extensions_info; 1432 return extensions_info;
1437 } 1433 }
1438 1434
1439 bool ExtensionPrefs::WasAppDraggedByUser( 1435 bool ExtensionPrefs::WasAppDraggedByUser(
1440 const std::string& extension_id) const { 1436 const std::string& extension_id) const {
1441 return ReadPrefAsBooleanAndReturn(extension_id, kPrefUserDraggedApp); 1437 return ReadPrefAsBooleanAndReturn(extension_id, kPrefUserDraggedApp);
1442 } 1438 }
1443 1439
1444 void ExtensionPrefs::SetAppDraggedByUser(const std::string& extension_id) { 1440 void ExtensionPrefs::SetAppDraggedByUser(const std::string& extension_id) {
1445 UpdateExtensionPref(extension_id, kPrefUserDraggedApp, 1441 UpdateExtensionPref(extension_id, kPrefUserDraggedApp, new base::Value(true));
1446 new base::FundamentalValue(true));
1447 } 1442 }
1448 1443
1449 bool ExtensionPrefs::IsFromWebStore( 1444 bool ExtensionPrefs::IsFromWebStore(
1450 const std::string& extension_id) const { 1445 const std::string& extension_id) const {
1451 const base::DictionaryValue* dictionary = GetExtensionPref(extension_id); 1446 const base::DictionaryValue* dictionary = GetExtensionPref(extension_id);
1452 bool result = false; 1447 bool result = false;
1453 if (dictionary && dictionary->GetBoolean(kPrefFromWebStore, &result)) 1448 if (dictionary && dictionary->GetBoolean(kPrefFromWebStore, &result))
1454 return result; 1449 return result;
1455 return false; 1450 return false;
1456 } 1451 }
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 prefs_->SetInteger(kCorruptedDisableCount, count + 1); 1714 prefs_->SetInteger(kCorruptedDisableCount, count + 1);
1720 } 1715 }
1721 1716
1722 bool ExtensionPrefs::NeedsSync(const std::string& extension_id) const { 1717 bool ExtensionPrefs::NeedsSync(const std::string& extension_id) const {
1723 return ReadPrefAsBooleanAndReturn(extension_id, kPrefNeedsSync); 1718 return ReadPrefAsBooleanAndReturn(extension_id, kPrefNeedsSync);
1724 } 1719 }
1725 1720
1726 void ExtensionPrefs::SetNeedsSync(const std::string& extension_id, 1721 void ExtensionPrefs::SetNeedsSync(const std::string& extension_id,
1727 bool needs_sync) { 1722 bool needs_sync) {
1728 UpdateExtensionPref(extension_id, kPrefNeedsSync, 1723 UpdateExtensionPref(extension_id, kPrefNeedsSync,
1729 needs_sync ? new base::FundamentalValue(true) : nullptr); 1724 needs_sync ? new base::Value(true) : nullptr);
1730 } 1725 }
1731 1726
1732 ExtensionPrefs::ExtensionPrefs( 1727 ExtensionPrefs::ExtensionPrefs(
1733 content::BrowserContext* browser_context, 1728 content::BrowserContext* browser_context,
1734 PrefService* prefs, 1729 PrefService* prefs,
1735 const base::FilePath& root_dir, 1730 const base::FilePath& root_dir,
1736 ExtensionPrefValueMap* extension_pref_value_map, 1731 ExtensionPrefValueMap* extension_pref_value_map,
1737 std::unique_ptr<TimeProvider> time_provider, 1732 std::unique_ptr<TimeProvider> time_provider,
1738 bool extensions_disabled, 1733 bool extensions_disabled,
1739 const std::vector<ExtensionPrefsObserver*>& early_observers) 1734 const std::vector<ExtensionPrefsObserver*>& early_observers)
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1836 } 1831 }
1837 } 1832 }
1838 1833
1839 void ExtensionPrefs::PopulateExtensionInfoPrefs( 1834 void ExtensionPrefs::PopulateExtensionInfoPrefs(
1840 const Extension* extension, 1835 const Extension* extension,
1841 const base::Time install_time, 1836 const base::Time install_time,
1842 Extension::State initial_state, 1837 Extension::State initial_state,
1843 int install_flags, 1838 int install_flags,
1844 const std::string& install_parameter, 1839 const std::string& install_parameter,
1845 base::DictionaryValue* extension_dict) const { 1840 base::DictionaryValue* extension_dict) const {
1846 extension_dict->Set(kPrefState, new base::FundamentalValue(initial_state)); 1841 extension_dict->Set(kPrefState, new base::Value(initial_state));
1847 extension_dict->Set(kPrefLocation, 1842 extension_dict->Set(kPrefLocation, new base::Value(extension->location()));
1848 new base::FundamentalValue(extension->location()));
1849 extension_dict->Set(kPrefCreationFlags, 1843 extension_dict->Set(kPrefCreationFlags,
1850 new base::FundamentalValue(extension->creation_flags())); 1844 new base::Value(extension->creation_flags()));
1851 extension_dict->Set(kPrefFromWebStore, 1845 extension_dict->Set(kPrefFromWebStore,
1852 new base::FundamentalValue(extension->from_webstore())); 1846 new base::Value(extension->from_webstore()));
1853 extension_dict->Set(kPrefFromBookmark, 1847 extension_dict->Set(kPrefFromBookmark,
1854 new base::FundamentalValue(extension->from_bookmark())); 1848 new base::Value(extension->from_bookmark()));
1855 extension_dict->Set( 1849 extension_dict->Set(kPrefWasInstalledByDefault,
1856 kPrefWasInstalledByDefault, 1850 new base::Value(extension->was_installed_by_default()));
1857 new base::FundamentalValue(extension->was_installed_by_default())); 1851 extension_dict->Set(kPrefWasInstalledByOem,
1858 extension_dict->Set( 1852 new base::Value(extension->was_installed_by_oem()));
1859 kPrefWasInstalledByOem,
1860 new base::FundamentalValue(extension->was_installed_by_oem()));
1861 extension_dict->Set(kPrefInstallTime, 1853 extension_dict->Set(kPrefInstallTime,
1862 new base::StringValue( 1854 new base::StringValue(
1863 base::Int64ToString(install_time.ToInternalValue()))); 1855 base::Int64ToString(install_time.ToInternalValue())));
1864 if (install_flags & kInstallFlagIsBlacklistedForMalware) 1856 if (install_flags & kInstallFlagIsBlacklistedForMalware)
1865 extension_dict->Set(kPrefBlacklist, new base::FundamentalValue(true)); 1857 extension_dict->Set(kPrefBlacklist, new base::Value(true));
1866 1858
1867 base::FilePath::StringType path = MakePathRelative(install_directory_, 1859 base::FilePath::StringType path = MakePathRelative(install_directory_,
1868 extension->path()); 1860 extension->path());
1869 extension_dict->Set(kPrefPath, new base::StringValue(path)); 1861 extension_dict->Set(kPrefPath, new base::StringValue(path));
1870 if (!install_parameter.empty()) { 1862 if (!install_parameter.empty()) {
1871 extension_dict->Set(kPrefInstallParam, 1863 extension_dict->Set(kPrefInstallParam,
1872 new base::StringValue(install_parameter)); 1864 new base::StringValue(install_parameter));
1873 } 1865 }
1874 // We store prefs about LOAD extensions, but don't cache their manifest 1866 // We store prefs about LOAD extensions, but don't cache their manifest
1875 // since it may change on disk. 1867 // since it may change on disk.
1876 if (!Manifest::IsUnpackedLocation(extension->location())) { 1868 if (!Manifest::IsUnpackedLocation(extension->location())) {
1877 extension_dict->Set(kPrefManifest, 1869 extension_dict->Set(kPrefManifest,
1878 extension->manifest()->value()->DeepCopy()); 1870 extension->manifest()->value()->DeepCopy());
1879 } 1871 }
1880 1872
1881 // Only writes kPrefDoNotSync when it is not the default. 1873 // Only writes kPrefDoNotSync when it is not the default.
1882 if (install_flags & kInstallFlagDoNotSync) 1874 if (install_flags & kInstallFlagDoNotSync)
1883 extension_dict->Set(kPrefDoNotSync, new base::FundamentalValue(true)); 1875 extension_dict->Set(kPrefDoNotSync, new base::Value(true));
1884 else 1876 else
1885 extension_dict->Remove(kPrefDoNotSync, NULL); 1877 extension_dict->Remove(kPrefDoNotSync, NULL);
1886 } 1878 }
1887 1879
1888 void ExtensionPrefs::InitExtensionControlledPrefs( 1880 void ExtensionPrefs::InitExtensionControlledPrefs(
1889 ExtensionPrefValueMap* value_map) { 1881 ExtensionPrefValueMap* value_map) {
1890 TRACE_EVENT0("browser,startup", 1882 TRACE_EVENT0("browser,startup",
1891 "ExtensionPrefs::InitExtensionControlledPrefs") 1883 "ExtensionPrefs::InitExtensionControlledPrefs")
1892 SCOPED_UMA_HISTOGRAM_TIMER("Extensions.InitExtensionControlledPrefsTime"); 1884 SCOPED_UMA_HISTOGRAM_TIMER("Extensions.InitExtensionControlledPrefsTime");
1893 1885
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1975 bool is_incognito_enabled = IsIncognitoEnabled(extension_id); 1967 bool is_incognito_enabled = IsIncognitoEnabled(extension_id);
1976 1968
1977 extension_pref_value_map_->RegisterExtension( 1969 extension_pref_value_map_->RegisterExtension(
1978 extension_id, install_time, is_enabled, is_incognito_enabled); 1970 extension_id, install_time, is_enabled, is_incognito_enabled);
1979 1971
1980 for (auto& observer : observer_list_) 1972 for (auto& observer : observer_list_)
1981 observer.OnExtensionRegistered(extension_id, install_time, is_enabled); 1973 observer.OnExtensionRegistered(extension_id, install_time, is_enabled);
1982 } 1974 }
1983 1975
1984 } // namespace extensions 1976 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/usb/usb_api.cc ('k') | extensions/browser/value_store/value_store_frontend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698