Commit 73c9146c authored by Charlene Yan's avatar Charlene Yan Committed by Commit Bot

[Tab Groups Collapse] Add user action metrics for collapsing/expanding.

Bug: 1018230
Change-Id: Ie015fdd3b162830f98a56b73bf6af19d2341b030
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2252844Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Reviewed-by: default avatarConnie Wan <connily@chromium.org>
Commit-Queue: Charlene Yan <cyan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#780459}
parent bad99edb
......@@ -348,9 +348,15 @@ void BrowserTabStripController::MoveGroup(const tab_groups::TabGroupId& group,
}
void BrowserTabStripController::ToggleTabGroupCollapsedState(
const tab_groups::TabGroupId group) {
const tab_groups::TabGroupId group,
bool record_user_action) {
const bool is_currently_collapsed = IsGroupCollapsed(group);
if (!is_currently_collapsed) {
if (is_currently_collapsed) {
if (record_user_action) {
base::RecordAction(
base::UserMetricsAction("TabGroups_TabGroupHeader_Expanded"));
}
} else {
if (model_->GetTabGroupForTab(GetActiveIndex()) == group) {
// If the active tab is in the group that is toggling to collapse, the
// active tab should switch to the next available tab. If there are no
......@@ -358,8 +364,10 @@ void BrowserTabStripController::ToggleTabGroupCollapsedState(
// toggle to collapse.
const base::Optional<int> next_active =
model_->GetNextExpandedActiveTab(GetActiveIndex(), group);
if (!next_active.has_value())
if (!next_active.has_value()) {
base::RecordAction(base::UserMetricsAction("TabGroups_CannotCollapse"));
return;
}
model_->ActivateTabAt(next_active.value(),
{TabStripModel::GestureType::kOther});
} else {
......@@ -369,6 +377,10 @@ void BrowserTabStripController::ToggleTabGroupCollapsedState(
model_->ActivateTabAt(GetActiveIndex(),
{TabStripModel::GestureType::kOther});
}
if (record_user_action) {
base::RecordAction(
base::UserMetricsAction("TabGroups_TabGroupHeader_Collapsed"));
}
}
std::vector<int> tabs_in_group = ListTabsInGroup(group);
......
......@@ -75,8 +75,8 @@ class BrowserTabStripController : public TabStripController,
void RemoveTabFromGroup(int model_index) override;
void MoveTab(int start_index, int final_index) override;
void MoveGroup(const tab_groups::TabGroupId& group, int final_index) override;
void ToggleTabGroupCollapsedState(
const tab_groups::TabGroupId group) override;
void ToggleTabGroupCollapsedState(const tab_groups::TabGroupId group,
bool record_user_action) override;
void ShowContextMenuForTab(Tab* tab,
const gfx::Point& p,
ui::MenuSourceType source_type) override;
......
......@@ -53,7 +53,8 @@ void FakeBaseTabStripController::MoveGroup(const tab_groups::TabGroupId& group,
int to_index) {}
void FakeBaseTabStripController::ToggleTabGroupCollapsedState(
const tab_groups::TabGroupId group) {
const tab_groups::TabGroupId group,
bool record_user_action) {
fake_group_data_ = tab_groups::TabGroupVisualData(
fake_group_data_.title(), fake_group_data_.color(),
!fake_group_data_.is_collapsed());
......
......@@ -48,8 +48,8 @@ class FakeBaseTabStripController : public TabStripController {
void CloseTab(int index) override;
void MoveTab(int from_index, int to_index) override;
void MoveGroup(const tab_groups::TabGroupId&, int to_index) override;
void ToggleTabGroupCollapsedState(
const tab_groups::TabGroupId group) override;
void ToggleTabGroupCollapsedState(const tab_groups::TabGroupId group,
bool record_user_action) override;
void ShowContextMenuForTab(Tab* tab,
const gfx::Point& p,
ui::MenuSourceType source_type) override;
......
......@@ -109,7 +109,8 @@ bool TabGroupHeader::OnKeyPressed(const ui::KeyEvent& event) {
if (base::FeatureList::IsEnabled(features::kTabGroupsCollapse)) {
// The collapse feature changes the behavior from showing the
// editor bubble to toggling the collapsed state of the group.
tab_strip_->controller()->ToggleTabGroupCollapsedState(group().value());
tab_strip_->controller()->ToggleTabGroupCollapsedState(group().value(),
true);
} else {
editor_bubble_tracker_.Opened(TabGroupEditorBubbleView::Show(
tab_strip_->controller()->GetBrowser(), group().value(), this));
......@@ -164,7 +165,8 @@ void TabGroupHeader::OnMouseReleased(const ui::MouseEvent& event) {
// The collapse feature changes the left click behavior from showing the
// editor bubble to toggling the collapsed state of the group.
if (event.IsLeftMouseButton() && !dragging())
tab_strip_->controller()->ToggleTabGroupCollapsedState(group().value());
tab_strip_->controller()->ToggleTabGroupCollapsedState(group().value(),
true);
} else if (!dragging() && !editor_bubble_tracker_.is_open()) {
// (TODO): Delete this else statement once collapse launches since
// ShowContextMenuForViewImpl() will handle spawning the bubble on right
......
......@@ -98,8 +98,10 @@ class TabStripController {
virtual void MoveGroup(const tab_groups::TabGroupId& group,
int final_index) = 0;
// Switches the collapsed state of a tab group.
virtual void ToggleTabGroupCollapsedState(
const tab_groups::TabGroupId group) = 0;
const tab_groups::TabGroupId group,
bool record_user_action = false) = 0;
// Shows a context menu for the tab at the specified point in screen coords.
virtual void ShowContextMenuForTab(Tab* tab,
......
......@@ -24025,6 +24025,15 @@ should be able to be added at any place in this file.
</description>
</action>
<action name="TabGroups_CannotCollapse">
<owner>cyan@chromium.org</owner>
<owner>chrome-desktop-ui-sea@google.com</owner>
<description>
User clicked on the tab group header of the last expanded tab group. This
user action means there are no more available tabs so the user saw a no-op.
</description>
</action>
<action name="TabGroups_SwitchGroupedTab">
<owner>connily@chromium.org</owner>
<owner>cyan@chromium.org</owner>
......@@ -24091,6 +24100,24 @@ should be able to be added at any place in this file.
</description>
</action>
<action name="TabGroups_TabGroupHeader_Collapsed">
<owner>cyan@chromium.org</owner>
<owner>chrome-desktop-ui-sea@google.com</owner>
<description>
User clicked on the tab group header of an expanded tab group to collapse
the group.
</description>
</action>
<action name="TabGroups_TabGroupHeader_Expanded">
<owner>cyan@chromium.org</owner>
<owner>chrome-desktop-ui-sea@google.com</owner>
<description>
User clicked on the tab group header of a collapsed tab group to expand the
group.
</description>
</action>
<action name="Tablet.WindowDrag.OpenedOverview">
<owner>minch@chromium.org</owner>
<description>
......
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