Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4065)

Unified Diff: chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.mm

Issue 2041293002: Add heuristics to limit showing of new backspace UI bubble. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.mm
diff --git a/chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.mm b/chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.mm
index d2a2bda041dd27d53fc3a7685886bed95f9ff156..de5236526e1ce23c52864efc47c79e1063630a03 100644
--- a/chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.mm
+++ b/chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.mm
@@ -40,14 +40,39 @@ void ExclusiveAccessController::Show() {
views_bubble_.reset(new ExclusiveAccessBubbleViews(this, url_, bubble_type_));
}
-void ExclusiveAccessController::ShowNewBackShortcutBubble(bool forward) {
- // Hide the exclusive access bubble, to avoid overlapping.
- views_bubble_.reset();
-
+void ExclusiveAccessController::MaybeShowNewBackShortcutBubble(bool forward) {
+ if (!new_back_shortcut_bubble_ || !new_back_shortcut_bubble_->IsVisible()) {
+ // Show the bubble at most five times.
+ PrefService* prefs = GetProfile()->GetPrefs();
+ int shown_count = prefs->GetInteger(prefs::kBackShortcutBubbleShownCount);
+ constexpr int kMaxShownCount = 5;
+ if (shown_count >= kMaxShownCount)
+ return;
+
+ // Only show the bubble when the user presses a shortcut twice within
+ // three seconds.
+ const base::TimeTicks now = base::TimeTicks::Now();
+ constexpr base::TimeDelta kRepeatWindow = base::TimeDelta::FromSeconds(3);
+ if (last_back_shortcut_press_time_.is_null() ||
+ ((now - last_back_shortcut_press_time_) > kRepeatWindow)) {
+ last_back_shortcut_press_time_ = now;
+ return;
+ }
+
+ // Hide the exclusive access bubble, to avoid overlapping.
+ views_bubble_.reset();
+
+ new_back_shortcut_bubble_.reset(new NewBackShortcutBubble(this));
+ prefs->SetInteger(prefs::kBackShortcutBubbleShownCount, shown_count + 1);
+ last_back_shortcut_press_time_ = base::TimeTicks();
+ }
+
+ new_back_shortcut_bubble_->UpdateContent(forward);
+}
+
+void ExclusiveAccessController::HideNewBackShortcutBubble() {
if (new_back_shortcut_bubble_)
- new_back_shortcut_bubble_->UpdateContent(forward);
- else
- new_back_shortcut_bubble_.reset(new NewBackShortcutBubble(this, forward));
+ new_back_shortcut_bubble_->Hide();
}
void ExclusiveAccessController::Destroy() {
« no previous file with comments | « chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.h ('k') | chrome/browser/ui/cocoa/browser_window_cocoa.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698