Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.h" | 5 #import "chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.h" |
| 6 | 6 |
| 7 #include "chrome/browser/download/download_shelf.h" | 7 #include "chrome/browser/download/download_shelf.h" |
| 8 #include "chrome/browser/fullscreen.h" | 8 #include "chrome/browser/fullscreen.h" |
| 9 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
| 10 #include "chrome/browser/ui/cocoa/accelerators_cocoa.h" | 10 #include "chrome/browser/ui/cocoa/accelerators_cocoa.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 | 33 |
| 34 ExclusiveAccessController::~ExclusiveAccessController() {} | 34 ExclusiveAccessController::~ExclusiveAccessController() {} |
| 35 | 35 |
| 36 void ExclusiveAccessController::Show() { | 36 void ExclusiveAccessController::Show() { |
| 37 // Hide the backspace shortcut bubble, to avoid overlapping. | 37 // Hide the backspace shortcut bubble, to avoid overlapping. |
| 38 new_back_shortcut_bubble_.reset(); | 38 new_back_shortcut_bubble_.reset(); |
| 39 | 39 |
| 40 views_bubble_.reset(new ExclusiveAccessBubbleViews(this, url_, bubble_type_)); | 40 views_bubble_.reset(new ExclusiveAccessBubbleViews(this, url_, bubble_type_)); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void ExclusiveAccessController::ShowNewBackShortcutBubble(bool forward) { | 43 void ExclusiveAccessController::MaybeShowNewBackShortcutBubble(bool forward) { |
| 44 // Hide the exclusive access bubble, to avoid overlapping. | 44 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
| |
| 45 views_bubble_.reset(); | 45 PrefService* prefs = GetProfile()->GetPrefs(); |
| 46 int shown_count = prefs->GetInteger(prefs::kBackShortcutBubbleShownCount); | |
| 47 constexpr int kMaxShownCount = 5; | |
| 48 if (shown_count >= kMaxShownCount) | |
| 49 return; | |
| 46 | 50 |
| 51 const base::TimeTicks now = base::TimeTicks::Now(); | |
| 52 constexpr base::TimeDelta kRepeatWindow = base::TimeDelta::FromSeconds(3); | |
| 53 if (last_back_shortcut_press_time_.is_null() || | |
| 54 ((now - last_back_shortcut_press_time_) > kRepeatWindow)) { | |
| 55 last_back_shortcut_press_time_ = now; | |
| 56 return; | |
| 57 } | |
| 58 | |
| 59 // Hide the exclusive access bubble, to avoid overlapping. | |
| 60 views_bubble_.reset(); | |
| 61 | |
| 62 new_back_shortcut_bubble_.reset(new NewBackShortcutBubble(this, forward)); | |
| 63 prefs->SetInteger(prefs::kBackShortcutBubbleShownCount, shown_count + 1); | |
| 64 last_back_shortcut_press_time_ = base::TimeTicks(); | |
| 65 } | |
| 66 | |
| 67 new_back_shortcut_bubble_->UpdateContent(forward); | |
| 68 } | |
| 69 | |
| 70 void ExclusiveAccessController::HideNewBackShortcutBubble() { | |
| 47 if (new_back_shortcut_bubble_) | 71 if (new_back_shortcut_bubble_) |
| 48 new_back_shortcut_bubble_->UpdateContent(forward); | 72 new_back_shortcut_bubble_->Hide(); |
| 49 else | |
| 50 new_back_shortcut_bubble_.reset(new NewBackShortcutBubble(this, forward)); | |
| 51 } | 73 } |
| 52 | 74 |
| 53 void ExclusiveAccessController::Destroy() { | 75 void ExclusiveAccessController::Destroy() { |
| 54 views_bubble_.reset(); | 76 views_bubble_.reset(); |
| 55 url_ = GURL(); | 77 url_ = GURL(); |
| 56 bubble_type_ = EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE; | 78 bubble_type_ = EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE; |
| 57 } | 79 } |
| 58 | 80 |
| 59 void ExclusiveAccessController::Layout(CGFloat max_y) { | 81 void ExclusiveAccessController::Layout(CGFloat max_y) { |
| 60 if (views_bubble_) | 82 if (views_bubble_) |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 } | 202 } |
| 181 | 203 |
| 182 gfx::Rect ExclusiveAccessController::GetTopContainerBoundsInScreen() { | 204 gfx::Rect ExclusiveAccessController::GetTopContainerBoundsInScreen() { |
| 183 NOTREACHED(); // Only used for ImmersiveMode. | 205 NOTREACHED(); // Only used for ImmersiveMode. |
| 184 return gfx::Rect(); | 206 return gfx::Rect(); |
| 185 } | 207 } |
| 186 | 208 |
| 187 BrowserWindow* ExclusiveAccessController::GetBrowserWindow() const { | 209 BrowserWindow* ExclusiveAccessController::GetBrowserWindow() const { |
| 188 return [controller_ browserWindow]; | 210 return [controller_ browserWindow]; |
| 189 } | 211 } |
| OLD | NEW |