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

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

Issue 2323993004: Remove use of deprecated base::ListValue::Append(Value*) overload in extensions. (Closed)
Patch Set: Less explosions Created 4 years, 3 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/menu_manager.cc
diff --git a/chrome/browser/extensions/menu_manager.cc b/chrome/browser/extensions/menu_manager.cc
index 993622c0df24bd1e2f736965642e086e33dbb82e..25b10b5045b3c529f693201b793769d62de4c428 100644
--- a/chrome/browser/extensions/menu_manager.cc
+++ b/chrome/browser/extensions/menu_manager.cc
@@ -5,11 +5,13 @@
#include "chrome/browser/extensions/menu_manager.h"
#include <algorithm>
+#include <memory>
#include <tuple>
#include <utility>
#include "base/json/json_writer.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -93,7 +95,7 @@ std::unique_ptr<base::Value> MenuItemsToValue(const MenuItem::List& items) {
std::unique_ptr<base::ListValue> list(new base::ListValue());
for (size_t i = 0; i < items.size(); ++i)
list->Append(items[i]->ToValue());
- return std::unique_ptr<base::Value>(list.release());
+ return std::move(list);
}
bool GetStringList(const base::DictionaryValue& dict,
@@ -638,10 +640,11 @@ void MenuManager::ExecuteCommand(content::BrowserContext* context,
std::unique_ptr<base::ListValue> args(new base::ListValue());
- base::DictionaryValue* properties = new base::DictionaryValue();
- SetIdKeyValue(properties, "menuItemId", item->id());
+ std::unique_ptr<base::DictionaryValue> properties(
+ new base::DictionaryValue());
+ SetIdKeyValue(properties.get(), "menuItemId", item->id());
if (item->parent_id())
- SetIdKeyValue(properties, "parentMenuItemId", *item->parent_id());
+ SetIdKeyValue(properties.get(), "parentMenuItemId", *item->parent_id());
switch (params.media_type) {
case blink::WebContextMenuData::MediaTypeImage:
@@ -656,10 +659,10 @@ void MenuManager::ExecuteCommand(content::BrowserContext* context,
default: {} // Do nothing.
}
- AddURLProperty(properties, "linkUrl", params.unfiltered_link_url);
- AddURLProperty(properties, "srcUrl", params.src_url);
- AddURLProperty(properties, "pageUrl", params.page_url);
- AddURLProperty(properties, "frameUrl", params.frame_url);
+ AddURLProperty(properties.get(), "linkUrl", params.unfiltered_link_url);
+ AddURLProperty(properties.get(), "srcUrl", params.src_url);
+ AddURLProperty(properties.get(), "pageUrl", params.page_url);
+ AddURLProperty(properties.get(), "frameUrl", params.frame_url);
if (params.selection_text.length() > 0)
properties->SetString("selectionText", params.selection_text);
@@ -674,7 +677,7 @@ void MenuManager::ExecuteCommand(content::BrowserContext* context,
webview_guest->view_instance_id());
}
- args->Append(properties);
+ args->Append(std::move(properties));
// Add the tab info to the argument list.
// No tab info in a platform app.
@@ -687,7 +690,7 @@ void MenuManager::ExecuteCommand(content::BrowserContext* context,
args->Append(ExtensionTabUtil::CreateTabObject(web_contents)->ToValue());
} else {
- args->Append(new base::DictionaryValue());
+ args->Append(base::MakeUnique<base::DictionaryValue>());
}
}

Powered by Google App Engine
This is Rietveld 408576698