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

Unified Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 2777063003: Stop passing raw pointers to base::Value API in c/b/chromeos and c/b/extensions (Closed)
Patch Set: Just rebased Created 3 years, 8 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_service_unittest.cc
diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc
index b2445f309b50479391746ee7aa9517945fda1d96..9080413e0f1e201d38ac40906926a3394be1623e 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -37,6 +37,7 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
+#include "base/values.h"
#include "base/version.h"
#include "build/build_config.h"
#include "chrome/browser/after_startup_task_utils.h"
@@ -622,7 +623,7 @@ class ExtensionServiceTest
void SetPref(const std::string& extension_id,
const std::string& pref_path,
- base::Value* value,
+ std::unique_ptr<base::Value> value,
const std::string& msg) {
DictionaryPrefUpdate update(profile()->GetPrefs(), "extensions.settings");
base::DictionaryValue* dict = update.Get();
@@ -630,7 +631,7 @@ class ExtensionServiceTest
base::DictionaryValue* pref = NULL;
ASSERT_TRUE(dict->GetDictionary(extension_id, &pref)) << msg;
EXPECT_TRUE(pref != NULL) << msg;
- pref->Set(pref_path, value);
+ pref->Set(pref_path, std::move(value));
}
void SetPrefInteg(const std::string& extension_id,
@@ -643,7 +644,7 @@ class ExtensionServiceTest
msg += " = ";
msg += base::IntToString(value);
- SetPref(extension_id, pref_path, new base::Value(value), msg);
+ SetPref(extension_id, pref_path, base::MakeUnique<base::Value>(value), msg);
}
void SetPrefBool(const std::string& extension_id,
@@ -654,7 +655,7 @@ class ExtensionServiceTest
msg += " = ";
msg += (value ? "true" : "false");
- SetPref(extension_id, pref_path, new base::Value(value), msg);
+ SetPref(extension_id, pref_path, base::MakeUnique<base::Value>(value), msg);
}
void ClearPref(const std::string& extension_id,
@@ -677,12 +678,12 @@ class ExtensionServiceTest
std::string msg = " while setting: ";
msg += extension_id + " " + pref_path;
- base::ListValue* list_value = new base::ListValue();
+ auto list_value = base::MakeUnique<base::ListValue>();
for (std::set<std::string>::const_iterator iter = value.begin();
iter != value.end(); ++iter)
list_value->AppendString(*iter);
- SetPref(extension_id, pref_path, list_value, msg);
+ SetPref(extension_id, pref_path, std::move(list_value), msg);
}
void InitPluginService() {
@@ -1714,7 +1715,7 @@ TEST_F(ExtensionServiceTest, GrantedAPIAndHostPermissions) {
// the extension's granted api permissions preference. (This simulates
// updating the browser to a version which recognizes a new API permission).
SetPref(extension_id, "granted_permissions.api",
- new base::ListValue(), "granted_permissions.api");
+ base::MakeUnique<base::ListValue>(), "granted_permissions.api");
service()->ReloadExtensionsForTest();
EXPECT_EQ(1u, registry()->disabled_extensions().size());
@@ -1750,10 +1751,10 @@ TEST_F(ExtensionServiceTest, GrantedAPIAndHostPermissions) {
host_permissions.insert("https://*.google.com/*");
host_permissions.insert("http://*.google.com.hk/*");
- base::ListValue* api_permissions = new base::ListValue();
+ auto api_permissions = base::MakeUnique<base::ListValue>();
api_permissions->AppendString("tabs");
- SetPref(extension_id, "granted_permissions.api",
- api_permissions, "granted_permissions.api");
+ SetPref(extension_id, "granted_permissions.api", std::move(api_permissions),
+ "granted_permissions.api");
SetPrefStringSet(
extension_id, "granted_permissions.scriptable_host", host_permissions);

Powered by Google App Engine
This is Rietveld 408576698