Commit 758c0efd authored by Charlene Yan's avatar Charlene Yan Committed by Commit Bot

Allow TabStripModel::GetTabGroupForTab to be called for any index.

Index can be out of bounds when attaching to a new tabstrip.

Bug: 915956
Change-Id: Id921c4232f7e081b7d821f6722ff2ba7994ade76
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1670125
Commit-Queue: Charlene Yan <cyan@chromium.org>
Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#671507}
parent ddef784f
...@@ -781,7 +781,7 @@ const TabGroupData* TabStripModel::GetDataForGroup(TabGroupId group) const { ...@@ -781,7 +781,7 @@ const TabGroupData* TabStripModel::GetDataForGroup(TabGroupId group) const {
} }
base::Optional<TabGroupId> TabStripModel::GetTabGroupForTab(int index) const { base::Optional<TabGroupId> TabStripModel::GetTabGroupForTab(int index) const {
return (index == kNoTab) ? base::nullopt : contents_data_[index]->group(); return ContainsIndex(index) ? contents_data_[index]->group() : base::nullopt;
} }
std::vector<TabGroupId> TabStripModel::ListTabGroups() const { std::vector<TabGroupId> TabStripModel::ListTabGroups() const {
......
...@@ -319,9 +319,10 @@ class TabStripModel { ...@@ -319,9 +319,10 @@ class TabStripModel {
// Returns true if the tab at |index| is blocked by a tab modal dialog. // Returns true if the tab at |index| is blocked by a tab modal dialog.
bool IsTabBlocked(int index) const; bool IsTabBlocked(int index) const;
// Returns the group that contains the tab at |index|, or nullopt if it is not // Returns the group that contains the tab at |index|, or nullopt if the tab
// grouped. This feature is in development and gated behind a feature flag // index is invalid or not grouped.
// (see https://crbug.com/915956). // This feature is in development and gated behind a feature flag (see
// https://crbug.com/915956).
base::Optional<TabGroupId> GetTabGroupForTab(int index) const; base::Optional<TabGroupId> GetTabGroupForTab(int index) const;
// Returns the TabGroupData instance for the given |group|. // Returns the TabGroupData instance for the given |group|.
......
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