Skip to content

Commit

Permalink
Always show close button in IPH (even toasts)
Browse files Browse the repository at this point in the history
This solves issues with it not being obvius how to close bubbles in all
cases.

Note that the toast IPHs do go away on their own relatively quickly, so
this may be redundant.

Bug: 1201086
Change-Id: Ifbb75143503c3e444fa780eea7ef167bc17fcdff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3244145
Commit-Queue: Dana Fried <[email protected]>
Reviewed-by: Emily Shack <[email protected]>
Cr-Commit-Position: refs/heads/main@{#935132}
  • Loading branch information
Dana Fried authored and Chromium LUCI CQ committed Oct 26, 2021
1 parent 8bdf4de commit 6bc0a89
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ struct FeaturePromoBubbleParams {
// If true, |allow_focus| must be true for keyboard accessibility.
bool allow_snooze = false;

// Determines if this IPH has a close button which can dismiss it. This is
// intended to be true for tutorial use cases.
bool show_close_button = false;

// Changes the bubble timeout before and after hovering the bubble,
// respectively. If a timeout is not provided a default will be used. If
// |timeout_after_interaction| is 0, |timeout_no_interaction| is used in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,14 @@ bool FeaturePromoControllerViews::ShowPromoBubbleImpl(
std::swap(create_params.buttons[0], create_params.buttons[1]);
}

if (params.show_close_button) {
if (!params.allow_snooze) {
create_params.has_close_button = true;
create_params.dismiss_callback = base::BindRepeating(
&FeaturePromoControllerViews::OnUserDismiss,
weak_ptr_factory_.GetWeakPtr(), *current_iph_feature_);
// Feature isn't present for some critical promos.
if (current_iph_feature_) {
create_params.dismiss_callback = base::BindRepeating(
&FeaturePromoControllerViews::OnUserDismiss,
weak_ptr_factory_.GetWeakPtr(), *current_iph_feature_);
}
}

if (CheckScreenReaderPromptAvailable()) {
Expand Down Expand Up @@ -464,9 +467,7 @@ bool FeaturePromoControllerViews::ShowPromoBubbleImpl(
} else {
// No prompt for a bubble that starts focused and where the anchor view
// cannot receive focus, since neither the help bubble accelerator nor F6
// would do anything. However, in this case we require a close button of
// some variety.
DCHECK(params.allow_snooze || params.show_close_button);
// would do anything.
}
}
const bool had_screen_reader_promo =
Expand Down

0 comments on commit 6bc0a89

Please sign in to comment.