Index: chrome/browser/extensions/extension_management_unittest.cc |
diff --git a/chrome/browser/extensions/extension_management_unittest.cc b/chrome/browser/extensions/extension_management_unittest.cc |
index 30aa6a132945a359b65fe40ff7072a3242e76671..a5a65c8c32ba697ee210f042c757afe540ffa18a 100644 |
--- a/chrome/browser/extensions/extension_management_unittest.cc |
+++ b/chrome/browser/extensions/extension_management_unittest.cc |
@@ -101,11 +101,13 @@ class ExtensionManagementServiceTest : public testing::Test { |
new ExtensionManagement(pref_service_.get(), false)); |
} |
- void SetPref(bool managed, const char* path, base::Value* value) { |
+ void SetPref(bool managed, |
+ const char* path, |
+ std::unique_ptr<base::Value> value) { |
if (managed) |
- pref_service_->SetManagedPref(path, value); |
+ pref_service_->SetManagedPref(path, std::move(value)); |
else |
- pref_service_->SetUserPref(path, value); |
+ pref_service_->SetUserPref(path, std::move(value)); |
} |
void RemovePref(bool managed, const char* path) { |
@@ -156,7 +158,7 @@ class ExtensionManagementServiceTest : public testing::Test { |
base::JSONParserOptions::JSON_ALLOW_TRAILING_COMMAS, NULL, &error_msg); |
ASSERT_TRUE(parsed && parsed->IsType(base::Value::Type::DICTIONARY)) |
<< error_msg; |
- SetPref(true, pref_names::kExtensionManagement, parsed.release()); |
+ SetPref(true, pref_names::kExtensionManagement, std::move(parsed)); |
} |
// Wrapper of ExtensionManagement::GetInstallationMode, |id| and |
@@ -270,7 +272,7 @@ bool ExtensionAdminPolicyTest::BlacklistedByDefault( |
const base::ListValue* blacklist) { |
SetUpPolicyProvider(); |
if (blacklist) |
- SetPref(true, pref_names::kInstallDenyList, blacklist->DeepCopy()); |
+ SetPref(true, pref_names::kInstallDenyList, blacklist->CreateDeepCopy()); |
return extension_management_->BlacklistedByDefault(); |
} |
@@ -283,13 +285,13 @@ bool ExtensionAdminPolicyTest::UserMayLoad( |
base::string16* error) { |
SetUpPolicyProvider(); |
if (blacklist) |
- SetPref(true, pref_names::kInstallDenyList, blacklist->DeepCopy()); |
+ SetPref(true, pref_names::kInstallDenyList, blacklist->CreateDeepCopy()); |
if (whitelist) |
- SetPref(true, pref_names::kInstallAllowList, whitelist->DeepCopy()); |
+ SetPref(true, pref_names::kInstallAllowList, whitelist->CreateDeepCopy()); |
if (forcelist) |
- SetPref(true, pref_names::kInstallForceList, forcelist->DeepCopy()); |
+ SetPref(true, pref_names::kInstallForceList, forcelist->CreateDeepCopy()); |
if (allowed_types) |
- SetPref(true, pref_names::kAllowedTypes, allowed_types->DeepCopy()); |
+ SetPref(true, pref_names::kAllowedTypes, allowed_types->CreateDeepCopy()); |
return provider_->UserMayLoad(extension, error); |
} |
@@ -311,8 +313,8 @@ TEST_F(ExtensionManagementServiceTest, LegacyInstallSources) { |
base::ListValue allowed_sites_pref; |
allowed_sites_pref.AppendString("https://www.example.com/foo"); |
allowed_sites_pref.AppendString("https://corp.mycompany.com/*"); |
- SetPref( |
- true, pref_names::kAllowedInstallSites, allowed_sites_pref.DeepCopy()); |
+ SetPref(true, pref_names::kAllowedInstallSites, |
+ allowed_sites_pref.CreateDeepCopy()); |
const URLPatternSet& allowed_sites = ReadGlobalSettings()->install_sources; |
ASSERT_TRUE(ReadGlobalSettings()->has_restricted_install_sources); |
EXPECT_FALSE(allowed_sites.is_empty()); |
@@ -331,7 +333,7 @@ TEST_F(ExtensionManagementServiceTest, LegacyAllowedTypes) { |
allowed_types_pref.AppendInteger(Manifest::TYPE_THEME); |
allowed_types_pref.AppendInteger(Manifest::TYPE_USER_SCRIPT); |
- SetPref(true, pref_names::kAllowedTypes, allowed_types_pref.DeepCopy()); |
+ SetPref(true, pref_names::kAllowedTypes, allowed_types_pref.CreateDeepCopy()); |
const std::vector<Manifest::Type>& allowed_types = |
ReadGlobalSettings()->allowed_types; |
ASSERT_TRUE(ReadGlobalSettings()->has_restricted_allowed_types); |
@@ -353,7 +355,8 @@ TEST_F(ExtensionManagementServiceTest, LegacyInstallBlacklist) { |
base::ListValue denied_list_pref; |
denied_list_pref.AppendString(kTargetExtension); |
- SetPref(true, pref_names::kInstallDenyList, denied_list_pref.DeepCopy()); |
+ SetPref(true, pref_names::kInstallDenyList, |
+ denied_list_pref.CreateDeepCopy()); |
EXPECT_EQ(GetInstallationModeById(kTargetExtension), |
ExtensionManagement::INSTALLATION_BLOCKED); |
EXPECT_EQ(GetInstallationModeById(kNonExistingExtension), |
@@ -368,8 +371,10 @@ TEST_F(ExtensionManagementServiceTest, LegacyInstallWhitelist) { |
base::ListValue allowed_list_pref; |
allowed_list_pref.AppendString(kTargetExtension); |
- SetPref(true, pref_names::kInstallDenyList, denied_list_pref.DeepCopy()); |
- SetPref(true, pref_names::kInstallAllowList, allowed_list_pref.DeepCopy()); |
+ SetPref(true, pref_names::kInstallDenyList, |
+ denied_list_pref.CreateDeepCopy()); |
+ SetPref(true, pref_names::kInstallAllowList, |
+ allowed_list_pref.CreateDeepCopy()); |
EXPECT_EQ(GetInstallationModeById(kTargetExtension), |
ExtensionManagement::INSTALLATION_ALLOWED); |
EXPECT_EQ(GetInstallationModeById(kNonExistingExtension), |
@@ -377,7 +382,8 @@ TEST_F(ExtensionManagementServiceTest, LegacyInstallWhitelist) { |
// Verify that install whitelist preference set by user is ignored. |
RemovePref(true, pref_names::kInstallAllowList); |
- SetPref(false, pref_names::kInstallAllowList, allowed_list_pref.DeepCopy()); |
+ SetPref(false, pref_names::kInstallAllowList, |
+ allowed_list_pref.CreateDeepCopy()); |
EXPECT_EQ(GetInstallationModeById(kTargetExtension), |
ExtensionManagement::INSTALLATION_BLOCKED); |
} |
@@ -389,7 +395,8 @@ TEST_F(ExtensionManagementServiceTest, LegacyInstallForcelist) { |
ExternalPolicyLoader::AddExtension( |
&forced_list_pref, kTargetExtension, kExampleUpdateUrl); |
- SetPref(true, pref_names::kInstallForceList, forced_list_pref.DeepCopy()); |
+ SetPref(true, pref_names::kInstallForceList, |
+ forced_list_pref.CreateDeepCopy()); |
EXPECT_EQ(GetInstallationModeById(kTargetExtension), |
ExtensionManagement::INSTALLATION_FORCED); |
CheckAutomaticallyInstalledUpdateUrl(kTargetExtension, kExampleUpdateUrl); |
@@ -398,7 +405,8 @@ TEST_F(ExtensionManagementServiceTest, LegacyInstallForcelist) { |
// Verify that install forcelist preference set by user is ignored. |
RemovePref(true, pref_names::kInstallForceList); |
- SetPref(false, pref_names::kInstallForceList, forced_list_pref.DeepCopy()); |
+ SetPref(false, pref_names::kInstallForceList, |
+ forced_list_pref.CreateDeepCopy()); |
EXPECT_EQ(GetInstallationModeById(kTargetExtension), |
ExtensionManagement::INSTALLATION_ALLOWED); |
} |
@@ -547,8 +555,8 @@ TEST_F(ExtensionManagementServiceTest, NewInstallSources) { |
// Set the legacy preference, and verifies that it works. |
base::ListValue allowed_sites_pref; |
allowed_sites_pref.AppendString("https://www.example.com/foo"); |
- SetPref( |
- true, pref_names::kAllowedInstallSites, allowed_sites_pref.DeepCopy()); |
+ SetPref(true, pref_names::kAllowedInstallSites, |
+ allowed_sites_pref.CreateDeepCopy()); |
EXPECT_TRUE(ReadGlobalSettings()->has_restricted_install_sources); |
EXPECT_TRUE(ReadGlobalSettings()->install_sources.MatchesURL( |
GURL("https://www.example.com/foo"))); |
@@ -579,7 +587,7 @@ TEST_F(ExtensionManagementServiceTest, NewAllowedTypes) { |
// Set the legacy preference, and verifies that it works. |
base::ListValue allowed_types_pref; |
allowed_types_pref.AppendInteger(Manifest::TYPE_USER_SCRIPT); |
- SetPref(true, pref_names::kAllowedTypes, allowed_types_pref.DeepCopy()); |
+ SetPref(true, pref_names::kAllowedTypes, allowed_types_pref.CreateDeepCopy()); |
EXPECT_TRUE(ReadGlobalSettings()->has_restricted_allowed_types); |
EXPECT_EQ(ReadGlobalSettings()->allowed_types.size(), 1u); |
EXPECT_EQ(ReadGlobalSettings()->allowed_types[0], Manifest::TYPE_USER_SCRIPT); |
@@ -623,11 +631,13 @@ TEST_F(ExtensionManagementServiceTest, NewInstallBlacklist) { |
base::ListValue denied_list_pref; |
denied_list_pref.AppendString("*"); |
denied_list_pref.AppendString(kTargetExtension2); |
- SetPref(true, pref_names::kInstallDenyList, denied_list_pref.DeepCopy()); |
+ SetPref(true, pref_names::kInstallDenyList, |
+ denied_list_pref.CreateDeepCopy()); |
base::ListValue allowed_list_pref; |
allowed_list_pref.AppendString(kTargetExtension); |
- SetPref(true, pref_names::kInstallAllowList, allowed_list_pref.DeepCopy()); |
+ SetPref(true, pref_names::kInstallAllowList, |
+ allowed_list_pref.CreateDeepCopy()); |
// Verifies that the new one have higher priority over the legacy ones. |
EXPECT_FALSE(extension_management_->BlacklistedByDefault()); |
@@ -658,11 +668,13 @@ TEST_F(ExtensionManagementServiceTest, NewInstallWhitelist) { |
// Set legacy preference. |
base::ListValue denied_list_pref; |
denied_list_pref.AppendString(kTargetExtension); |
- SetPref(true, pref_names::kInstallDenyList, denied_list_pref.DeepCopy()); |
+ SetPref(true, pref_names::kInstallDenyList, |
+ denied_list_pref.CreateDeepCopy()); |
base::ListValue allowed_list_pref; |
allowed_list_pref.AppendString(kTargetExtension2); |
- SetPref(true, pref_names::kInstallAllowList, allowed_list_pref.DeepCopy()); |
+ SetPref(true, pref_names::kInstallAllowList, |
+ allowed_list_pref.CreateDeepCopy()); |
// Verifies that the new one have higher priority over the legacy ones. |
EXPECT_TRUE(extension_management_->BlacklistedByDefault()); |
@@ -681,7 +693,8 @@ TEST_F(ExtensionManagementServiceTest, NewInstallForcelist) { |
// legacy ones. |
base::ListValue denied_list_pref; |
denied_list_pref.AppendString(kTargetExtension); |
- SetPref(true, pref_names::kInstallDenyList, denied_list_pref.DeepCopy()); |
+ SetPref(true, pref_names::kInstallDenyList, |
+ denied_list_pref.CreateDeepCopy()); |
// Set the new dictionary preference. |
{ |