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

Unified Diff: chrome/browser/extensions/api/tabs/tabs_event_router.cc

Issue 2806283002: Revert of Stop passing raw pointers to base::Value API in c/b/chromeos and c/b/extensions (Closed)
Patch Set: 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/api/tabs/tabs_event_router.cc
diff --git a/chrome/browser/extensions/api/tabs/tabs_event_router.cc b/chrome/browser/extensions/api/tabs/tabs_event_router.cc
index bc76ad20066f8ae42db841fb7948f054e197d0a6..db5072037f749a371b421f6167a0f10c3355f0e8 100644
--- a/chrome/browser/extensions/api/tabs/tabs_event_router.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_event_router.cc
@@ -49,17 +49,18 @@
std::unique_ptr<api::tabs::Tab> tab_object =
ExtensionTabUtil::CreateTabObject(contents, extension);
- std::unique_ptr<base::DictionaryValue> tab_value = tab_object->ToValue();
-
- auto changed_properties = base::MakeUnique<base::DictionaryValue>();
+ base::DictionaryValue* tab_value = tab_object->ToValue().release();
+
+ std::unique_ptr<base::DictionaryValue> changed_properties(
+ new base::DictionaryValue);
const base::Value* value = nullptr;
for (const auto& property : changed_property_names) {
if (tab_value->Get(property, &value))
- changed_properties->Set(property, value->CreateDeepCopy());
- }
-
- event->event_args->Set(1, std::move(changed_properties));
- event->event_args->Set(2, std::move(tab_value));
+ changed_properties->Set(property, base::WrapUnique(value->DeepCopy()));
+ }
+
+ event->event_args->Set(1, changed_properties.release());
+ event->event_args->Set(2, tab_value);
return true;
}
@@ -235,11 +236,9 @@
std::unique_ptr<base::DictionaryValue> object_args(
new base::DictionaryValue());
- object_args->Set(
- tabs_constants::kNewWindowIdKey,
- base::MakeUnique<Value>(ExtensionTabUtil::GetWindowIdOfTab(contents)));
- object_args->Set(tabs_constants::kNewPositionKey,
- base::MakeUnique<Value>(index));
+ object_args->Set(tabs_constants::kNewWindowIdKey,
+ new Value(ExtensionTabUtil::GetWindowIdOfTab(contents)));
+ object_args->Set(tabs_constants::kNewPositionKey, new Value(index));
args->Append(std::move(object_args));
Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
@@ -258,11 +257,9 @@
std::unique_ptr<base::DictionaryValue> object_args(
new base::DictionaryValue());
- object_args->Set(
- tabs_constants::kOldWindowIdKey,
- base::MakeUnique<Value>(ExtensionTabUtil::GetWindowIdOfTab(contents)));
- object_args->Set(tabs_constants::kOldPositionKey,
- base::MakeUnique<Value>(index));
+ object_args->Set(tabs_constants::kOldWindowIdKey,
+ new Value(ExtensionTabUtil::GetWindowIdOfTab(contents)));
+ object_args->Set(tabs_constants::kOldPositionKey, new Value(index));
args->Append(std::move(object_args));
Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
@@ -303,8 +300,7 @@
auto object_args = base::MakeUnique<base::DictionaryValue>();
object_args->Set(tabs_constants::kWindowIdKey,
- base::MakeUnique<Value>(
- ExtensionTabUtil::GetWindowIdOfTab(new_contents)));
+ new Value(ExtensionTabUtil::GetWindowIdOfTab(new_contents)));
args->Append(object_args->CreateDeepCopy());
// The onActivated event replaced onActiveChanged and onSelectionChanged. The
@@ -323,7 +319,7 @@
// The onActivated event takes one argument: {windowId, tabId}.
auto on_activated_args = base::MakeUnique<base::ListValue>();
- object_args->Set(tabs_constants::kTabIdKey, base::MakeUnique<Value>(tab_id));
+ object_args->Set(tabs_constants::kTabIdKey, new Value(tab_id));
on_activated_args->Append(std::move(object_args));
DispatchEvent(profile, events::TABS_ON_ACTIVATED,
tabs::OnActivated::kEventName, std::move(on_activated_args),
@@ -351,8 +347,7 @@
select_info->Set(
tabs_constants::kWindowIdKey,
- base::MakeUnique<Value>(
- ExtensionTabUtil::GetWindowIdOfTabStripModel(tab_strip_model)));
+ new Value(ExtensionTabUtil::GetWindowIdOfTabStripModel(tab_strip_model)));
select_info->Set(tabs_constants::kTabIdsKey, all_tabs.release());
args->Append(std::move(select_info));
@@ -376,13 +371,10 @@
std::unique_ptr<base::DictionaryValue> object_args(
new base::DictionaryValue());
- object_args->Set(
- tabs_constants::kWindowIdKey,
- base::MakeUnique<Value>(ExtensionTabUtil::GetWindowIdOfTab(contents)));
- object_args->Set(tabs_constants::kFromIndexKey,
- base::MakeUnique<Value>(from_index));
- object_args->Set(tabs_constants::kToIndexKey,
- base::MakeUnique<Value>(to_index));
+ object_args->Set(tabs_constants::kWindowIdKey,
+ new Value(ExtensionTabUtil::GetWindowIdOfTab(contents)));
+ object_args->Set(tabs_constants::kFromIndexKey, new Value(from_index));
+ object_args->Set(tabs_constants::kToIndexKey, new Value(to_index));
args->Append(std::move(object_args));
Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());

Powered by Google App Engine
This is Rietveld 408576698