Commit d77ab323 authored by Connie Wan's avatar Connie Wan Committed by Commit Bot

Clean up more Tab Group references

Similar to crrev.com/c/1975035

Change-Id: I3a124fee1dc82932301a8bcf16b6a0b5628ee61c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2003356
Auto-Submit: Connie Wan <connily@chromium.org>
Reviewed-by: default avatarCharlene Yan <cyan@chromium.org>
Commit-Queue: Charlene Yan <cyan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732457}
parent 7022f1cd
...@@ -1015,7 +1015,7 @@ tab_groups::TabGroupId TabStripModel::AddToNewGroup( ...@@ -1015,7 +1015,7 @@ tab_groups::TabGroupId TabStripModel::AddToNewGroup(
} }
void TabStripModel::AddToExistingGroup(const std::vector<int>& indices, void TabStripModel::AddToExistingGroup(const std::vector<int>& indices,
tab_groups::TabGroupId group) { const tab_groups::TabGroupId& group) {
ReentrancyCheck reentrancy_check(&reentrancy_guard_); ReentrancyCheck reentrancy_check(&reentrancy_guard_);
AddToExistingGroupImpl(indices, group); AddToExistingGroupImpl(indices, group);
...@@ -1023,14 +1023,14 @@ void TabStripModel::AddToExistingGroup(const std::vector<int>& indices, ...@@ -1023,14 +1023,14 @@ void TabStripModel::AddToExistingGroup(const std::vector<int>& indices,
void TabStripModel::MoveTabsAndSetGroup(const std::vector<int>& indices, void TabStripModel::MoveTabsAndSetGroup(const std::vector<int>& indices,
int destination_index, int destination_index,
tab_groups::TabGroupId group) { const tab_groups::TabGroupId& group) {
ReentrancyCheck reentrancy_check(&reentrancy_guard_); ReentrancyCheck reentrancy_check(&reentrancy_guard_);
MoveTabsAndSetGroupImpl(indices, destination_index, group); MoveTabsAndSetGroupImpl(indices, destination_index, group);
} }
void TabStripModel::AddToGroupForRestore(const std::vector<int>& indices, void TabStripModel::AddToGroupForRestore(const std::vector<int>& indices,
tab_groups::TabGroupId group) { const tab_groups::TabGroupId& group) {
ReentrancyCheck reentrancy_check(&reentrancy_guard_); ReentrancyCheck reentrancy_check(&reentrancy_guard_);
const bool group_exists = group_model_->ContainsTabGroup(group); const bool group_exists = group_model_->ContainsTabGroup(group);
...@@ -1319,7 +1319,7 @@ void TabStripModel::ExecuteContextMenuCommand(int context_index, ...@@ -1319,7 +1319,7 @@ void TabStripModel::ExecuteContextMenuCommand(int context_index,
void TabStripModel::ExecuteAddToExistingGroupCommand( void TabStripModel::ExecuteAddToExistingGroupCommand(
int context_index, int context_index,
tab_groups::TabGroupId group) { const tab_groups::TabGroupId& group) {
base::RecordAction(UserMetricsAction("TabContextMenu_AddToExistingGroup")); base::RecordAction(UserMetricsAction("TabContextMenu_AddToExistingGroup"));
AddToExistingGroup(GetIndicesForCommand(context_index), group); AddToExistingGroup(GetIndicesForCommand(context_index), group);
...@@ -1759,7 +1759,7 @@ void TabStripModel::MoveSelectedTabsToImpl(int index, ...@@ -1759,7 +1759,7 @@ void TabStripModel::MoveSelectedTabsToImpl(int index,
} }
void TabStripModel::AddToNewGroupImpl(const std::vector<int>& indices, void TabStripModel::AddToNewGroupImpl(const std::vector<int>& indices,
tab_groups::TabGroupId new_group) { const tab_groups::TabGroupId& new_group) {
DCHECK(!std::any_of( DCHECK(!std::any_of(
contents_data_.cbegin(), contents_data_.cend(), contents_data_.cbegin(), contents_data_.cend(),
[new_group](const auto& datum) { return datum->group() == new_group; })); [new_group](const auto& datum) { return datum->group() == new_group; }));
...@@ -1787,8 +1787,9 @@ void TabStripModel::AddToNewGroupImpl(const std::vector<int>& indices, ...@@ -1787,8 +1787,9 @@ void TabStripModel::AddToNewGroupImpl(const std::vector<int>& indices,
MoveTabsAndSetGroupImpl(new_indices, destination_index, new_group); MoveTabsAndSetGroupImpl(new_indices, destination_index, new_group);
} }
void TabStripModel::AddToExistingGroupImpl(const std::vector<int>& indices, void TabStripModel::AddToExistingGroupImpl(
tab_groups::TabGroupId group) { const std::vector<int>& indices,
const tab_groups::TabGroupId& group) {
// Do nothing if the "existing" group can't be found. This would only happen // Do nothing if the "existing" group can't be found. This would only happen
// if the existing group is closed programmatically while the user is // if the existing group is closed programmatically while the user is
// interacting with the UI - e.g. if a group close operation is started by an // interacting with the UI - e.g. if a group close operation is started by an
...@@ -1888,7 +1889,7 @@ base::Optional<tab_groups::TabGroupId> TabStripModel::UngroupTab(int index) { ...@@ -1888,7 +1889,7 @@ base::Optional<tab_groups::TabGroupId> TabStripModel::UngroupTab(int index) {
return group; return group;
} }
void TabStripModel::GroupTab(int index, tab_groups::TabGroupId group) { void TabStripModel::GroupTab(int index, const tab_groups::TabGroupId& group) {
// Check for an old group first, so that any groups that are changed can be // Check for an old group first, so that any groups that are changed can be
// notified appropriately. // notified appropriately.
base::Optional<tab_groups::TabGroupId> old_group = GetTabGroupForTab(index); base::Optional<tab_groups::TabGroupId> old_group = GetTabGroupForTab(index);
......
...@@ -417,20 +417,20 @@ class TabStripModel : public TabGroupController { ...@@ -417,20 +417,20 @@ class TabStripModel : public TabGroupController {
// be sorted in ascending order. This feature is in development and gated // be sorted in ascending order. This feature is in development and gated
// behind a feature flag (see https://crbug.com/915956). // behind a feature flag (see https://crbug.com/915956).
void AddToExistingGroup(const std::vector<int>& indices, void AddToExistingGroup(const std::vector<int>& indices,
tab_groups::TabGroupId group); const tab_groups::TabGroupId& group);
// Moves the set of tabs indicated by |indices| to precede the tab at index // Moves the set of tabs indicated by |indices| to precede the tab at index
// |destination_index|, maintaining their order and the order of tabs not // |destination_index|, maintaining their order and the order of tabs not
// being moved, and adds them to the tab group |group|. // being moved, and adds them to the tab group |group|.
void MoveTabsAndSetGroup(const std::vector<int>& indices, void MoveTabsAndSetGroup(const std::vector<int>& indices,
int destination_index, int destination_index,
tab_groups::TabGroupId group); const tab_groups::TabGroupId& group);
// Similar to AddToExistingGroup(), but creates a group with id |group| if it // Similar to AddToExistingGroup(), but creates a group with id |group| if it
// doesn't exist. This is only intended to be called from session restore // doesn't exist. This is only intended to be called from session restore
// code. // code.
void AddToGroupForRestore(const std::vector<int>& indices, void AddToGroupForRestore(const std::vector<int>& indices,
tab_groups::TabGroupId group); const tab_groups::TabGroupId& group);
// Updates the tab group of the tab at |index|. If |group| is nullopt, the tab // Updates the tab group of the tab at |index|. If |group| is nullopt, the tab
// will be removed from the current group. If |group| does not exist, it will // will be removed from the current group. If |group| does not exist, it will
...@@ -486,7 +486,7 @@ class TabStripModel : public TabGroupController { ...@@ -486,7 +486,7 @@ class TabStripModel : public TabGroupController {
// Adds the tab at |context_index| to the given tab group |group|. If // Adds the tab at |context_index| to the given tab group |group|. If
// |context_index| is selected the command applies to all selected tabs. // |context_index| is selected the command applies to all selected tabs.
void ExecuteAddToExistingGroupCommand(int context_index, void ExecuteAddToExistingGroupCommand(int context_index,
tab_groups::TabGroupId group); const tab_groups::TabGroupId& group);
// Returns true if 'CommandToggleSiteMuted' will mute. |index| is the // Returns true if 'CommandToggleSiteMuted' will mute. |index| is the
// index supplied to |ExecuteContextMenuCommand|. // index supplied to |ExecuteContextMenuCommand|.
...@@ -650,12 +650,12 @@ class TabStripModel : public TabGroupController { ...@@ -650,12 +650,12 @@ class TabStripModel : public TabGroupController {
// Adds tabs to newly-allocated group id |new_group|. This group must be new // Adds tabs to newly-allocated group id |new_group|. This group must be new
// and have no tabs in it. // and have no tabs in it.
void AddToNewGroupImpl(const std::vector<int>& indices, void AddToNewGroupImpl(const std::vector<int>& indices,
tab_groups::TabGroupId new_group); const tab_groups::TabGroupId& new_group);
// Adds tabs to existing group |group|. This group must have been initialized // Adds tabs to existing group |group|. This group must have been initialized
// by a previous call to |AddToNewGroupImpl()|. // by a previous call to |AddToNewGroupImpl()|.
void AddToExistingGroupImpl(const std::vector<int>& indices, void AddToExistingGroupImpl(const std::vector<int>& indices,
tab_groups::TabGroupId group); const tab_groups::TabGroupId& group);
// Implementation of MoveTabsAndSetGroupImpl. Moves the set of tabs in // Implementation of MoveTabsAndSetGroupImpl. Moves the set of tabs in
// |indices| to the |destination_index| and updates the tabs to the // |indices| to the |destination_index| and updates the tabs to the
...@@ -676,7 +676,7 @@ class TabStripModel : public TabGroupController { ...@@ -676,7 +676,7 @@ class TabStripModel : public TabGroupController {
base::Optional<tab_groups::TabGroupId> UngroupTab(int index); base::Optional<tab_groups::TabGroupId> UngroupTab(int index);
// Helper function for MoveAndSetGroup. Adds the tab at |index| to |group|. // Helper function for MoveAndSetGroup. Adds the tab at |index| to |group|.
void GroupTab(int index, tab_groups::TabGroupId group); void GroupTab(int index, const tab_groups::TabGroupId& group);
// TabGroupController: // TabGroupController:
void CreateTabGroup(const tab_groups::TabGroupId& group) override; void CreateTabGroup(const tab_groups::TabGroupId& group) override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment