summaryrefslogtreecommitdiffstats
path: root/chromium/chrome/browser/extensions/api/tabs/tabs_event_router.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-10-26 13:57:00 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-11-02 11:31:01 +0000
commit1943b3c2a1dcee36c233724fc4ee7613d71b9cf6 (patch)
tree8c1b5f12357025c197da5427ae02cfdc2f3570d6 /chromium/chrome/browser/extensions/api/tabs/tabs_event_router.cc
parent21ba0c5d4bf8fba15dddd97cd693bad2358b77fd (diff)
BASELINE: Update Chromium to 94.0.4606.111
Change-Id: I924781584def20fc800bedf6ff41fdb96c438193 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/chrome/browser/extensions/api/tabs/tabs_event_router.cc')
-rw-r--r--chromium/chrome/browser/extensions/api/tabs/tabs_event_router.cc64
1 files changed, 27 insertions, 37 deletions
diff --git a/chromium/chrome/browser/extensions/api/tabs/tabs_event_router.cc b/chromium/chrome/browser/extensions/api/tabs/tabs_event_router.cc
index 82d38a893a0..25cd387e94c 100644
--- a/chromium/chrome/browser/extensions/api/tabs/tabs_event_router.cc
+++ b/chromium/chrome/browser/extensions/api/tabs/tabs_event_router.cc
@@ -62,8 +62,7 @@ bool WillDispatchTabUpdatedEvent(
const base::Value* value = nullptr;
for (const auto& property : changed_property_names) {
if (tab_value->Get(property, &value))
- changed_properties->Set(property,
- std::make_unique<base::Value>(value->Clone()));
+ changed_properties->SetKey(property, value->Clone());
}
event->event_args->Set(1, std::move(changed_properties));
@@ -78,7 +77,7 @@ bool WillDispatchTabCreatedEvent(WebContents* contents,
const Extension* extension,
Event* event,
const base::DictionaryValue* listener_filter) {
- event->event_args->Clear();
+ event->event_args->ClearList();
ExtensionTabUtil::ScrubTabBehavior scrub_tab_behavior =
ExtensionTabUtil::GetScrubTabBehavior(extension, target_context,
contents);
@@ -205,7 +204,8 @@ void TabsEventRouter::OnTabStripModelChanged(
}
case TabStripModelChange::kRemoved: {
for (const auto& contents : change.GetRemove()->contents) {
- if (contents.will_be_deleted) {
+ if (contents.remove_reason ==
+ TabStripModelChange::RemoveReason::kDeleted) {
DispatchTabClosingAt(tab_strip_model, contents.contents,
contents.index);
}
@@ -351,11 +351,9 @@ void TabsEventRouter::DispatchTabInsertedAt(TabStripModel* tab_strip_model,
std::unique_ptr<base::DictionaryValue> object_args(
new base::DictionaryValue());
- object_args->Set(
- tabs_constants::kNewWindowIdKey,
- std::make_unique<Value>(ExtensionTabUtil::GetWindowIdOfTab(contents)));
- object_args->Set(tabs_constants::kNewPositionKey,
- std::make_unique<Value>(index));
+ object_args->SetKey(tabs_constants::kNewWindowIdKey,
+ Value(ExtensionTabUtil::GetWindowIdOfTab(contents)));
+ object_args->SetKey(tabs_constants::kNewPositionKey, Value(index));
args->Append(std::move(object_args));
Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
@@ -401,11 +399,9 @@ void TabsEventRouter::DispatchTabDetachedAt(WebContents* contents,
std::unique_ptr<base::DictionaryValue> object_args(
new base::DictionaryValue());
- object_args->Set(
- tabs_constants::kOldWindowIdKey,
- std::make_unique<Value>(ExtensionTabUtil::GetWindowIdOfTab(contents)));
- object_args->Set(tabs_constants::kOldPositionKey,
- std::make_unique<Value>(index));
+ object_args->SetKey(tabs_constants::kOldWindowIdKey,
+ Value(ExtensionTabUtil::GetWindowIdOfTab(contents)));
+ object_args->SetKey(tabs_constants::kOldPositionKey, Value(index));
args->Append(std::move(object_args));
Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
@@ -422,9 +418,8 @@ void TabsEventRouter::DispatchActiveTabChanged(WebContents* old_contents,
args->AppendInteger(tab_id);
auto object_args = std::make_unique<base::DictionaryValue>();
- object_args->Set(tabs_constants::kWindowIdKey,
- std::make_unique<Value>(
- ExtensionTabUtil::GetWindowIdOfTab(new_contents)));
+ object_args->SetKey(tabs_constants::kWindowIdKey,
+ Value(ExtensionTabUtil::GetWindowIdOfTab(new_contents)));
args->Append(object_args->CreateDeepCopy());
// The onActivated event replaced onActiveChanged and onSelectionChanged. The
@@ -441,7 +436,7 @@ void TabsEventRouter::DispatchActiveTabChanged(WebContents* old_contents,
// The onActivated event takes one argument: {windowId, tabId}.
auto on_activated_args = std::make_unique<base::ListValue>();
- object_args->Set(tabs_constants::kTabIdKey, std::make_unique<Value>(tab_id));
+ object_args->SetKey(tabs_constants::kTabIdKey, Value(tab_id));
on_activated_args->Append(std::move(object_args));
DispatchEvent(
profile, events::TABS_ON_ACTIVATED, api::tabs::OnActivated::kEventName,
@@ -453,33 +448,31 @@ void TabsEventRouter::DispatchTabSelectionChanged(
const ui::ListSelectionModel& old_model) {
ui::ListSelectionModel::SelectedIndices new_selection =
tab_strip_model->selection_model().selected_indices();
- std::unique_ptr<base::ListValue> all_tabs(new base::ListValue);
+ base::ListValue all_tabs;
for (int index : new_selection) {
WebContents* contents = tab_strip_model->GetWebContentsAt(index);
if (!contents)
break;
int tab_id = ExtensionTabUtil::GetTabId(contents);
- all_tabs->AppendInteger(tab_id);
+ all_tabs.AppendInteger(tab_id);
}
std::unique_ptr<base::ListValue> args(new base::ListValue);
std::unique_ptr<base::DictionaryValue> select_info(new base::DictionaryValue);
- select_info->Set(
+ select_info->SetKey(
tabs_constants::kWindowIdKey,
- std::make_unique<Value>(
- ExtensionTabUtil::GetWindowIdOfTabStripModel(tab_strip_model)));
+ Value(ExtensionTabUtil::GetWindowIdOfTabStripModel(tab_strip_model)));
- select_info->Set(tabs_constants::kTabIdsKey, std::move(all_tabs));
+ select_info->SetKey(tabs_constants::kTabIdsKey, std::move(all_tabs));
args->Append(std::move(select_info));
// The onHighlighted event replaced onHighlightChanged.
Profile* profile = tab_strip_model->profile();
DispatchEvent(profile, events::TABS_ON_HIGHLIGHT_CHANGED,
api::tabs::OnHighlightChanged::kEventName,
- std::unique_ptr<base::ListValue>(args->DeepCopy()),
- EventRouter::USER_GESTURE_UNKNOWN);
+ args->CreateDeepCopy(), EventRouter::USER_GESTURE_UNKNOWN);
DispatchEvent(profile, events::TABS_ON_HIGHLIGHTED,
api::tabs::OnHighlighted::kEventName, std::move(args),
EventRouter::USER_GESTURE_UNKNOWN);
@@ -493,13 +486,10 @@ void TabsEventRouter::DispatchTabMoved(WebContents* contents,
std::unique_ptr<base::DictionaryValue> object_args(
new base::DictionaryValue());
- object_args->Set(
- tabs_constants::kWindowIdKey,
- std::make_unique<Value>(ExtensionTabUtil::GetWindowIdOfTab(contents)));
- object_args->Set(tabs_constants::kFromIndexKey,
- std::make_unique<Value>(from_index));
- object_args->Set(tabs_constants::kToIndexKey,
- std::make_unique<Value>(to_index));
+ object_args->SetKey(tabs_constants::kWindowIdKey,
+ Value(ExtensionTabUtil::GetWindowIdOfTab(contents)));
+ object_args->SetKey(tabs_constants::kFromIndexKey, Value(from_index));
+ object_args->SetKey(tabs_constants::kToIndexKey, Value(to_index));
args->Append(std::move(object_args));
Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
@@ -583,7 +573,7 @@ void TabsEventRouter::DispatchEvent(
return;
auto event = std::make_unique<Event>(histogram_value, event_name,
- args->TakeList(), profile);
+ std::move(*args).TakeList(), profile);
event->user_gesture = user_gesture;
event_router->BroadcastEvent(std::move(event));
}
@@ -609,9 +599,9 @@ void TabsEventRouter::DispatchTabUpdatedEvent(
// WillDispatchTabUpdatedEvent.
Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
- auto event = std::make_unique<Event>(events::TABS_ON_UPDATED,
- api::tabs::OnUpdated::kEventName,
- args_base->TakeList(), profile);
+ auto event = std::make_unique<Event>(
+ events::TABS_ON_UPDATED, api::tabs::OnUpdated::kEventName,
+ std::move(*args_base).TakeList(), profile);
event->user_gesture = EventRouter::USER_GESTURE_NOT_ENABLED;
event->will_dispatch_callback =
base::BindRepeating(&WillDispatchTabUpdatedEvent, contents,