Remove use of deprecated base::ListValue::Append(Value*) overload in extensions.
BUG=581865
Review-Url: https://codereview.chromium.org/2323993004
Cr-Commit-Position: refs/heads/master@{#418568}
diff --git a/extensions/browser/api/networking_private/networking_private_linux.cc b/extensions/browser/api/networking_private/networking_private_linux.cc
index 207a08ed5..2b8ccd7 100644
--- a/extensions/browser/api/networking_private/networking_private_linux.cc
+++ b/extensions/browser/api/networking_private/networking_private_linux.cc
@@ -83,7 +83,7 @@
std::unique_ptr<base::ListValue> network_list(new base::ListValue);
for (const auto& network : network_map) {
- network_list->Append(network.second->DeepCopy());
+ network_list->Append(network.second->CreateDeepCopy());
}
return network_list;
diff --git a/extensions/browser/api/printer_provider/printer_provider_apitest.cc b/extensions/browser/api/printer_provider/printer_provider_apitest.cc
index 3ffb443..d0b8cb40 100644
--- a/extensions/browser/api/printer_provider/printer_provider_apitest.cc
+++ b/extensions/browser/api/printer_provider/printer_provider_apitest.cc
@@ -48,7 +48,7 @@
EXPECT_TRUE(printers.GetDictionary(i, &printer))
<< "Found invalid printer value at index " << i << ": " << printers;
if (printer)
- printers_out->Append(printer->DeepCopy());
+ printers_out->Append(printer->CreateDeepCopy());
}
if (done && !callback.is_null())
callback.Run();
diff --git a/extensions/browser/api/runtime/runtime_api.cc b/extensions/browser/api/runtime/runtime_api.cc
index b8f4f31..559d5b6 100644
--- a/extensions/browser/api/runtime/runtime_api.cc
+++ b/extensions/browser/api/runtime/runtime_api.cc
@@ -518,8 +518,7 @@
return;
std::unique_ptr<base::ListValue> event_args(new base::ListValue());
- base::DictionaryValue* info = new base::DictionaryValue();
- event_args->Append(info);
+ std::unique_ptr<base::DictionaryValue> info(new base::DictionaryValue());
if (old_version.IsValid()) {
info->SetString(kInstallReason, kInstallReasonUpdate);
info->SetString(kInstallPreviousVersion, old_version.GetString());
@@ -528,6 +527,7 @@
} else {
info->SetString(kInstallReason, kInstallReasonInstall);
}
+ event_args->Append(std::move(info));
EventRouter* event_router = EventRouter::Get(context);
DCHECK(event_router);
std::unique_ptr<Event> event(new Event(events::RUNTIME_ON_INSTALLED,
@@ -546,11 +546,12 @@
i != dependents->end();
i++) {
std::unique_ptr<base::ListValue> sm_event_args(new base::ListValue());
- base::DictionaryValue* sm_info = new base::DictionaryValue();
- sm_event_args->Append(sm_info);
+ std::unique_ptr<base::DictionaryValue> sm_info(
+ new base::DictionaryValue());
sm_info->SetString(kInstallReason, kInstallReasonSharedModuleUpdate);
sm_info->SetString(kInstallPreviousVersion, old_version.GetString());
sm_info->SetString(kInstallId, extension_id);
+ sm_event_args->Append(std::move(sm_info));
std::unique_ptr<Event> sm_event(new Event(
events::RUNTIME_ON_INSTALLED, runtime::OnInstalled::kEventName,
std::move(sm_event_args)));
@@ -571,7 +572,7 @@
return;
std::unique_ptr<base::ListValue> args(new base::ListValue);
- args->Append(manifest->DeepCopy());
+ args->Append(manifest->CreateDeepCopy());
EventRouter* event_router = EventRouter::Get(context);
DCHECK(event_router);
std::unique_ptr<Event> event(new Event(events::RUNTIME_ON_UPDATE_AVAILABLE,
diff --git a/extensions/browser/api/web_request/web_request_api_helpers.cc b/extensions/browser/api/web_request/web_request_api_helpers.cc
index a4895d7..097d3a3 100644
--- a/extensions/browser/api/web_request/web_request_api_helpers.cc
+++ b/extensions/browser/api/web_request/web_request_api_helpers.cc
@@ -1275,10 +1275,11 @@
}
// Converts the |name|, |value| pair of a http header to a HttpHeaders
-// dictionary. Ownership is passed to the caller.
-base::DictionaryValue* CreateHeaderDictionary(
- const std::string& name, const std::string& value) {
- base::DictionaryValue* header = new base::DictionaryValue();
+// dictionary.
+std::unique_ptr<base::DictionaryValue> CreateHeaderDictionary(
+ const std::string& name,
+ const std::string& value) {
+ std::unique_ptr<base::DictionaryValue> header(new base::DictionaryValue());
header->SetString(keys::kHeaderNameKey, name);
if (base::IsStringUTF8(value)) {
header->SetString(keys::kHeaderValueKey, value);
diff --git a/extensions/browser/api/web_request/web_request_api_helpers.h b/extensions/browser/api/web_request/web_request_api_helpers.h
index 450f3cae..a46ec37 100644
--- a/extensions/browser/api/web_request/web_request_api_helpers.h
+++ b/extensions/browser/api/web_request/web_request_api_helpers.h
@@ -342,9 +342,10 @@
void SendExtensionWebRequestStatusToHost(content::RenderProcessHost* host);
// Converts the |name|, |value| pair of a http header to a HttpHeaders
-// dictionary. Ownership is passed to the caller.
-base::DictionaryValue* CreateHeaderDictionary(
- const std::string& name, const std::string& value);
+// dictionary.
+std::unique_ptr<base::DictionaryValue> CreateHeaderDictionary(
+ const std::string& name,
+ const std::string& value);
// Returns whether |type| is a ResourceType that is handled by the web request
// API.
diff --git a/extensions/browser/app_window/app_window_contents.cc b/extensions/browser/app_window/app_window_contents.cc
index 3cb0cb8..0d5f033 100644
--- a/extensions/browser/app_window/app_window_contents.cc
+++ b/extensions/browser/app_window/app_window_contents.cc
@@ -4,6 +4,7 @@
#include "extensions/browser/app_window/app_window_contents.h"
+#include <memory>
#include <string>
#include <utility>
@@ -65,9 +66,10 @@
void AppWindowContentsImpl::NativeWindowChanged(
NativeAppWindow* native_app_window) {
base::ListValue args;
- base::DictionaryValue* dictionary = new base::DictionaryValue();
- args.Append(dictionary);
- host_->GetSerializedState(dictionary);
+ std::unique_ptr<base::DictionaryValue> dictionary(
+ new base::DictionaryValue());
+ host_->GetSerializedState(dictionary.get());
+ args.Append(std::move(dictionary));
content::RenderFrameHost* rfh = web_contents_->GetMainFrame();
rfh->Send(new ExtensionMsg_MessageInvoke(
diff --git a/extensions/browser/computed_hashes.cc b/extensions/browser/computed_hashes.cc
index bf0cf98..0758506 100644
--- a/extensions/browser/computed_hashes.cc
+++ b/extensions/browser/computed_hashes.cc
@@ -4,6 +4,9 @@
#include "extensions/browser/computed_hashes.h"
+#include <memory>
+#include <utility>
+
#include "base/base64.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
@@ -133,13 +136,13 @@
void ComputedHashes::Writer::AddHashes(const base::FilePath& relative_path,
int block_size,
const std::vector<std::string>& hashes) {
- base::DictionaryValue* dict = new base::DictionaryValue();
+ std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
base::ListValue* block_hashes = new base::ListValue();
- file_list_->Append(dict);
dict->SetString(kPathKey,
relative_path.NormalizePathSeparatorsTo('/').AsUTF8Unsafe());
dict->SetInteger(kBlockSizeKey, block_size);
dict->Set(kBlockHashesKey, block_hashes);
+ file_list_->Append(std::move(dict));
for (std::vector<std::string>::const_iterator i = hashes.begin();
i != hashes.end();
diff --git a/extensions/browser/event_router.cc b/extensions/browser/event_router.cc
index 24ac575..60bd11c2 100644
--- a/extensions/browser/event_router.cc
+++ b/extensions/browser/event_router.cc
@@ -414,7 +414,7 @@
filtered_events->SetWithoutPathExpansion(event_name, filter_list);
}
- filter_list->Append(filter->DeepCopy());
+ filter_list->Append(filter->CreateDeepCopy());
}
void EventRouter::RemoveFilterFromEvent(const std::string& event_name,