chore: use std::make_unique/base::MakeRefCounted when possible (#29510)

This commit is contained in:
David Sanders 2021-06-07 19:00:05 -07:00 committed by GitHub
parent a4decffe9a
commit 79cb5144ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 106 additions and 101 deletions

View file

@ -91,8 +91,7 @@ std::unique_ptr<base::DictionaryValue> BuildTargetDescriptor(
int routing_id,
ui::AXMode accessibility_mode,
base::ProcessHandle handle = base::kNullProcessHandle) {
std::unique_ptr<base::DictionaryValue> target_data(
new base::DictionaryValue());
auto target_data = std::make_unique<base::DictionaryValue>();
target_data->SetInteger(kProcessIdField, process_id);
target_data->SetInteger(kRoutingIdField, routing_id);
target_data->SetString(kUrlField, url.spec());
@ -135,8 +134,7 @@ std::unique_ptr<base::DictionaryValue> BuildTargetDescriptor(
std::unique_ptr<base::DictionaryValue> BuildTargetDescriptor(
electron::NativeWindow* window) {
std::unique_ptr<base::DictionaryValue> target_data(
new base::DictionaryValue());
auto target_data = std::make_unique<base::DictionaryValue>();
target_data->SetInteger(kSessionIdField, window->window_id());
target_data->SetString(kNameField, window->GetTitle());
target_data->SetString(kTypeField, kBrowser);
@ -259,7 +257,7 @@ void HandleAccessibilityRequestCallback(
// Always dump the Accessibility tree.
data.SetString(kInternal, kOn);
std::unique_ptr<base::ListValue> rvh_list(new base::ListValue());
auto rvh_list = std::make_unique<base::ListValue>();
std::unique_ptr<content::RenderWidgetHostIterator> widgets(
content::RenderWidgetHost::GetRenderWidgetHosts());
@ -293,7 +291,7 @@ void HandleAccessibilityRequestCallback(
data.Set(kPagesField, std::move(rvh_list));
std::unique_ptr<base::ListValue> window_list(new base::ListValue());
auto window_list = std::make_unique<base::ListValue>();
for (auto* window : electron::WindowList::GetWindows()) {
window_list->Append(BuildTargetDescriptor(window));
}
@ -383,7 +381,7 @@ void ElectronAccessibilityUIMessageHandler::RequestNativeUITree(
}
// No browser with the specified |id| was found.
std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue());
auto result = std::make_unique<base::DictionaryValue>();
result->SetInteger(kSessionIdField, window_id);
result->SetString(kTypeField, kBrowser);
result->SetString(kErrorField, "Window no longer exists.");