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

Side by Side Diff: chrome/browser/ui/views/new_back_shortcut_bubble.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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/new_back_shortcut_bubble.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/ui/views/new_back_shortcut_bubble.h" 5 #include "chrome/browser/ui/views/new_back_shortcut_bubble.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 13 matching lines...) Expand all
24 namespace { 24 namespace {
25 25
26 const int kPopupTopPx = 45; 26 const int kPopupTopPx = 45;
27 const int kSlideInDurationMs = 350; 27 const int kSlideInDurationMs = 350;
28 const int kSlideOutDurationMs = 700; 28 const int kSlideOutDurationMs = 700;
29 const int kShowDurationMs = 3800; 29 const int kShowDurationMs = 3800;
30 30
31 } 31 }
32 32
33 NewBackShortcutBubble::NewBackShortcutBubble( 33 NewBackShortcutBubble::NewBackShortcutBubble(
34 ExclusiveAccessBubbleViewsContext* context, 34 ExclusiveAccessBubbleViewsContext* context)
35 bool forward)
36 : bubble_view_context_(context), 35 : bubble_view_context_(context),
37 animation_(new gfx::SlideAnimation(this)), 36 animation_(new gfx::SlideAnimation(this)),
38 view_(new SubtleNotificationView(nullptr)), 37 view_(new SubtleNotificationView(nullptr)),
39 popup_(SubtleNotificationView::CreatePopupWidget( 38 popup_(SubtleNotificationView::CreatePopupWidget(
40 bubble_view_context_->GetBubbleParentView(), 39 bubble_view_context_->GetBubbleParentView(),
41 view_, 40 view_,
42 false)) { 41 false)) {
43 UpdateContent(forward);
44 } 42 }
45 43
46 NewBackShortcutBubble::~NewBackShortcutBubble() { 44 NewBackShortcutBubble::~NewBackShortcutBubble() {
47 // We might need to delete the widget asynchronously. See rationale in 45 // We might need to delete the widget asynchronously. See rationale in
48 // ~ExclusiveAccessBubbleViews. 46 // ~ExclusiveAccessBubbleViews.
49 popup_->Close(); 47 popup_->Close();
50 base::MessageLoop::current()->DeleteSoon(FROM_HERE, popup_); 48 base::MessageLoop::current()->DeleteSoon(FROM_HERE, popup_);
51 } 49 }
52 50
51 bool NewBackShortcutBubble::IsVisible() const {
52 return popup_->IsVisible();
53 }
54
53 void NewBackShortcutBubble::UpdateContent(bool forward) { 55 void NewBackShortcutBubble::UpdateContent(bool forward) {
54 // Note: The key names are parameters so that we can vary by operating system 56 // Note: The key names are parameters so that we can vary by operating system
55 // or change the direction of the arrow as necessary (see 57 // or change the direction of the arrow as necessary (see
56 // https://crbug.com/612685). 58 // https://crbug.com/612685).
57 59
58 #if defined(OS_MACOSX) 60 #if defined(OS_MACOSX)
59 // U+2318 = PLACE OF INTEREST SIGN (Mac Command symbol). 61 // U+2318 = PLACE OF INTEREST SIGN (Mac Command symbol).
60 base::string16 accelerator = base::WideToUTF16(L"\x2318"); 62 base::string16 accelerator = base::WideToUTF16(L"\x2318");
61 #else 63 #else
62 base::string16 accelerator = l10n_util::GetStringUTF16(IDS_APP_ALT_KEY); 64 base::string16 accelerator = l10n_util::GetStringUTF16(IDS_APP_ALT_KEY);
(...skipping 13 matching lines...) Expand all
76 // Show the bubble. 78 // Show the bubble.
77 animation_->SetSlideDuration(kSlideInDurationMs); 79 animation_->SetSlideDuration(kSlideInDurationMs);
78 animation_->Show(); 80 animation_->Show();
79 81
80 // Wait a few seconds before hiding. 82 // Wait a few seconds before hiding.
81 hide_timeout_.Start(FROM_HERE, 83 hide_timeout_.Start(FROM_HERE,
82 base::TimeDelta::FromMilliseconds(kShowDurationMs), this, 84 base::TimeDelta::FromMilliseconds(kShowDurationMs), this,
83 &NewBackShortcutBubble::OnTimerElapsed); 85 &NewBackShortcutBubble::OnTimerElapsed);
84 } 86 }
85 87
88 void NewBackShortcutBubble::Hide() {
89 hide_timeout_.Stop();
90 OnTimerElapsed();
91 }
92
86 void NewBackShortcutBubble::AnimationProgressed( 93 void NewBackShortcutBubble::AnimationProgressed(
87 const gfx::Animation* animation) { 94 const gfx::Animation* animation) {
88 int opacity = animation_->CurrentValueBetween(0, 255); 95 int opacity = animation_->CurrentValueBetween(0, 255);
89 if (opacity == 0) { 96 if (opacity == 0) {
90 popup_->Hide(); 97 popup_->Hide();
91 } else { 98 } else {
92 if (!popup_->IsVisible()) 99 if (!popup_->IsVisible())
93 popup_->Show(); 100 popup_->Show();
94 101
95 popup_->SetOpacity(opacity); 102 popup_->SetOpacity(opacity);
(...skipping 13 matching lines...) Expand all
109 int desired_top = kPopupTopPx - view_->border()->GetInsets().top(); 116 int desired_top = kPopupTopPx - view_->border()->GetInsets().top();
110 int y = widget_bounds.y() + desired_top; 117 int y = widget_bounds.y() + desired_top;
111 return gfx::Rect(gfx::Point(x, y), size); 118 return gfx::Rect(gfx::Point(x, y), size);
112 } 119 }
113 120
114 void NewBackShortcutBubble::OnTimerElapsed() { 121 void NewBackShortcutBubble::OnTimerElapsed() {
115 // Hide the bubble. 122 // Hide the bubble.
116 animation_->SetSlideDuration(kSlideOutDurationMs); 123 animation_->SetSlideDuration(kSlideOutDurationMs);
117 animation_->Hide(); 124 animation_->Hide();
118 } 125 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/new_back_shortcut_bubble.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698