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 b425effaabb20e233e746460caa5b25d62f65766..455ce42b71cd8d7a71e7d96a6f1d6b19919db8b4 100644 |
--- a/chrome/browser/extensions/api/tabs/tabs_event_router.cc |
+++ b/chrome/browser/extensions/api/tabs/tabs_event_router.cc |
@@ -5,8 +5,10 @@ |
#include "chrome/browser/extensions/api/tabs/tabs_event_router.h" |
#include <stddef.h> |
+ |
#include <utility> |
+#include "base/memory/ptr_util.h" |
#include "base/values.h" |
#include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
#include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" |
@@ -41,17 +43,17 @@ bool WillDispatchTabUpdatedEvent( |
const Extension* extension, |
Event* event, |
const base::DictionaryValue* listener_filter) { |
- scoped_ptr<api::tabs::Tab> tab_object = |
+ std::unique_ptr<api::tabs::Tab> tab_object = |
ExtensionTabUtil::CreateTabObject(contents, extension); |
base::DictionaryValue* tab_value = tab_object->ToValue().release(); |
- scoped_ptr<base::DictionaryValue> changed_properties( |
+ 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, make_scoped_ptr(value->DeepCopy())); |
+ changed_properties->Set(property, base::WrapUnique(value->DeepCopy())); |
} |
event->event_args->Set(1, changed_properties.release()); |
@@ -155,7 +157,7 @@ void TabsEventRouter::RegisterForTabNotifications(WebContents* contents) { |
int tab_id = ExtensionTabUtil::GetTabId(contents); |
DCHECK(tab_entries_.find(tab_id) == tab_entries_.end()); |
- tab_entries_[tab_id] = make_scoped_ptr(new TabEntry(this, contents)); |
+ tab_entries_[tab_id] = base::WrapUnique(new TabEntry(this, contents)); |
} |
void TabsEventRouter::UnregisterForTabNotifications(WebContents* contents) { |
@@ -199,8 +201,8 @@ void TabsEventRouter::TabCreatedAt(WebContents* contents, |
int index, |
bool active) { |
Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); |
- scoped_ptr<base::ListValue> args(new base::ListValue); |
- scoped_ptr<Event> event(new Event( |
+ std::unique_ptr<base::ListValue> args(new base::ListValue); |
+ std::unique_ptr<Event> event(new Event( |
events::TABS_ON_CREATED, tabs::OnCreated::kEventName, std::move(args))); |
event->restrict_to_browser_context = profile; |
event->user_gesture = EventRouter::USER_GESTURE_NOT_ENABLED; |
@@ -225,7 +227,7 @@ void TabsEventRouter::TabInsertedAt(WebContents* contents, |
} |
int tab_id = ExtensionTabUtil::GetTabId(contents); |
- scoped_ptr<base::ListValue> args(new base::ListValue); |
+ std::unique_ptr<base::ListValue> args(new base::ListValue); |
args->Append(new FundamentalValue(tab_id)); |
base::DictionaryValue* object_args = new base::DictionaryValue(); |
@@ -247,7 +249,7 @@ void TabsEventRouter::TabDetachedAt(WebContents* contents, int index) { |
return; |
} |
- scoped_ptr<base::ListValue> args(new base::ListValue); |
+ std::unique_ptr<base::ListValue> args(new base::ListValue); |
args->Append( |
new FundamentalValue(ExtensionTabUtil::GetTabId(contents))); |
@@ -269,7 +271,7 @@ void TabsEventRouter::TabClosingAt(TabStripModel* tab_strip_model, |
int index) { |
int tab_id = ExtensionTabUtil::GetTabId(contents); |
- scoped_ptr<base::ListValue> args(new base::ListValue); |
+ std::unique_ptr<base::ListValue> args(new base::ListValue); |
args->Append(new FundamentalValue(tab_id)); |
base::DictionaryValue* object_args = new base::DictionaryValue(); |
@@ -290,7 +292,7 @@ void TabsEventRouter::ActiveTabChanged(WebContents* old_contents, |
WebContents* new_contents, |
int index, |
int reason) { |
- scoped_ptr<base::ListValue> args(new base::ListValue); |
+ std::unique_ptr<base::ListValue> args(new base::ListValue); |
int tab_id = ExtensionTabUtil::GetTabId(new_contents); |
args->Append(new FundamentalValue(tab_id)); |
@@ -310,10 +312,10 @@ void TabsEventRouter::ActiveTabChanged(WebContents* old_contents, |
: EventRouter::USER_GESTURE_NOT_ENABLED; |
DispatchEvent(profile, events::TABS_ON_SELECTION_CHANGED, |
tabs::OnSelectionChanged::kEventName, |
- scoped_ptr<base::ListValue>(args->DeepCopy()), gesture); |
+ std::unique_ptr<base::ListValue>(args->DeepCopy()), gesture); |
DispatchEvent(profile, events::TABS_ON_ACTIVE_CHANGED, |
tabs::OnActiveChanged::kEventName, |
- scoped_ptr<base::ListValue>(args->DeepCopy()), gesture); |
+ std::unique_ptr<base::ListValue>(args->DeepCopy()), gesture); |
// The onActivated event takes one argument: {windowId, tabId}. |
args->Remove(0, NULL); |
@@ -328,7 +330,7 @@ void TabsEventRouter::TabSelectionChanged( |
const ui::ListSelectionModel& old_model) { |
ui::ListSelectionModel::SelectedIndices new_selection = |
tab_strip_model->selection_model().selected_indices(); |
- scoped_ptr<base::ListValue> all_tabs(new base::ListValue); |
+ std::unique_ptr<base::ListValue> all_tabs(new base::ListValue); |
for (size_t i = 0; i < new_selection.size(); ++i) { |
int index = new_selection[i]; |
@@ -339,8 +341,8 @@ void TabsEventRouter::TabSelectionChanged( |
all_tabs->Append(new FundamentalValue(tab_id)); |
} |
- scoped_ptr<base::ListValue> args(new base::ListValue); |
- scoped_ptr<base::DictionaryValue> select_info(new base::DictionaryValue); |
+ std::unique_ptr<base::ListValue> args(new base::ListValue); |
+ std::unique_ptr<base::DictionaryValue> select_info(new base::DictionaryValue); |
select_info->Set( |
tabs_constants::kWindowIdKey, |
@@ -354,7 +356,7 @@ void TabsEventRouter::TabSelectionChanged( |
Profile* profile = tab_strip_model->profile(); |
DispatchEvent(profile, events::TABS_ON_HIGHLIGHT_CHANGED, |
tabs::OnHighlightChanged::kEventName, |
- scoped_ptr<base::ListValue>(args->DeepCopy()), |
+ std::unique_ptr<base::ListValue>(args->DeepCopy()), |
EventRouter::USER_GESTURE_UNKNOWN); |
DispatchEvent(profile, events::TABS_ON_HIGHLIGHTED, |
tabs::OnHighlighted::kEventName, std::move(args), |
@@ -364,7 +366,7 @@ void TabsEventRouter::TabSelectionChanged( |
void TabsEventRouter::TabMoved(WebContents* contents, |
int from_index, |
int to_index) { |
- scoped_ptr<base::ListValue> args(new base::ListValue); |
+ std::unique_ptr<base::ListValue> args(new base::ListValue); |
args->Append( |
new FundamentalValue(ExtensionTabUtil::GetTabId(contents))); |
@@ -414,13 +416,13 @@ void TabsEventRouter::DispatchEvent( |
Profile* profile, |
events::HistogramValue histogram_value, |
const std::string& event_name, |
- scoped_ptr<base::ListValue> args, |
+ std::unique_ptr<base::ListValue> args, |
EventRouter::UserGestureState user_gesture) { |
EventRouter* event_router = EventRouter::Get(profile); |
if (!profile_->IsSameProfile(profile) || !event_router) |
return; |
- scoped_ptr<Event> event( |
+ std::unique_ptr<Event> event( |
new Event(histogram_value, event_name, std::move(args))); |
event->restrict_to_browser_context = profile; |
event->user_gesture = user_gesture; |
@@ -435,7 +437,7 @@ void TabsEventRouter::DispatchTabUpdatedEvent( |
// The state of the tab (as seen from the extension point of view) has |
// changed. Send a notification to the extension. |
- scoped_ptr<base::ListValue> args_base(new base::ListValue); |
+ std::unique_ptr<base::ListValue> args_base(new base::ListValue); |
// First arg: The id of the tab that changed. |
args_base->AppendInteger(ExtensionTabUtil::GetTabId(contents)); |
@@ -448,9 +450,9 @@ void TabsEventRouter::DispatchTabUpdatedEvent( |
// WillDispatchTabUpdatedEvent. |
Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); |
- scoped_ptr<Event> event(new Event(events::TABS_ON_UPDATED, |
- tabs::OnUpdated::kEventName, |
- std::move(args_base))); |
+ std::unique_ptr<Event> event(new Event(events::TABS_ON_UPDATED, |
+ tabs::OnUpdated::kEventName, |
+ std::move(args_base))); |
event->restrict_to_browser_context = profile; |
event->user_gesture = EventRouter::USER_GESTURE_NOT_ENABLED; |
event->will_dispatch_callback = |
@@ -481,7 +483,7 @@ void TabsEventRouter::TabReplacedAt(TabStripModel* tab_strip_model, |
// WebContents being swapped. |
const int new_tab_id = ExtensionTabUtil::GetTabId(new_contents); |
const int old_tab_id = ExtensionTabUtil::GetTabId(old_contents); |
- scoped_ptr<base::ListValue> args(new base::ListValue); |
+ std::unique_ptr<base::ListValue> args(new base::ListValue); |
args->Append(new FundamentalValue(new_tab_id)); |
args->Append(new FundamentalValue(old_tab_id)); |