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

Unified Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 2065283002: Add heuristics to limit showing of new backspace UI bubble. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: 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
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.h ('k') | chrome/browser/ui/views/new_back_shortcut_bubble.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/frame/browser_view.cc
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 32f49a7d8e05b98945e1a8b05dbf64b67f2b9775..7b5ad82e11fb76fda31001810fb7bab2bcf75fe0 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -982,15 +982,16 @@ void BrowserView::UpdateExclusiveAccessExitBubbleContent(
return;
}
- // Hide the backspace shortcut bubble, to avoid overlapping.
- new_back_shortcut_bubble_.reset();
-
if (exclusive_access_bubble_) {
exclusive_access_bubble_->UpdateContent(url, bubble_type);
- } else {
- exclusive_access_bubble_.reset(
- new ExclusiveAccessBubbleViews(this, url, bubble_type));
+ return;
}
+
+ // Hide the backspace shortcut bubble, to avoid overlapping.
+ new_back_shortcut_bubble_.reset();
+
+ exclusive_access_bubble_.reset(
+ new ExclusiveAccessBubbleViews(this, url, bubble_type));
}
void BrowserView::OnExclusiveAccessUserInput() {
@@ -1014,14 +1015,39 @@ bool BrowserView::IsFullscreenBubbleVisible() const {
return exclusive_access_bubble_ != nullptr;
}
-void BrowserView::ShowNewBackShortcutBubble(bool forward) {
- // Hide the exclusive access bubble, to avoid overlapping.
- exclusive_access_bubble_.reset();
+void BrowserView::MaybeShowNewBackShortcutBubble(bool forward) {
+ if (!new_back_shortcut_bubble_ || !new_back_shortcut_bubble_->IsVisible()) {
+ // Show the bubble at most five times.
+ PrefService* prefs = browser_->profile()->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.
+ exclusive_access_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 BrowserView::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 BrowserView::RestoreFocus() {
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.h ('k') | chrome/browser/ui/views/new_back_shortcut_bubble.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698