Chromium Code Reviews| 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..2aa18a54a4c704fdfad134006c5ab9c819b185cd 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,36 @@ 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()) { |
|
Peter Kasting
2016/06/07 08:04:23
I don't love the fact that this almost exactly dup
Matt Giuca
2016/06/08 01:29:03
Yeah I went through a similar thought process befo
|
| + PrefService* prefs = GetProfile()->GetPrefs(); |
| + int shown_count = prefs->GetInteger(prefs::kBackShortcutBubbleShownCount); |
| + constexpr int kMaxShownCount = 5; |
| + if (shown_count >= kMaxShownCount) |
| + return; |
| + |
| + 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, forward)); |
| + 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() { |