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

Side by Side Diff: chrome/browser/ui/views/new_back_shortcut_bubble.cc

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 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/location.h" 9 #include "base/location.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 15 matching lines...) Expand all
26 namespace { 26 namespace {
27 27
28 const int kPopupTopPx = 45; 28 const int kPopupTopPx = 45;
29 const int kSlideInDurationMs = 350; 29 const int kSlideInDurationMs = 350;
30 const int kSlideOutDurationMs = 700; 30 const int kSlideOutDurationMs = 700;
31 const int kShowDurationMs = 3800; 31 const int kShowDurationMs = 3800;
32 32
33 } 33 }
34 34
35 NewBackShortcutBubble::NewBackShortcutBubble( 35 NewBackShortcutBubble::NewBackShortcutBubble(
36 ExclusiveAccessBubbleViewsContext* context, 36 ExclusiveAccessBubbleViewsContext* context)
37 bool forward)
38 : bubble_view_context_(context), 37 : bubble_view_context_(context),
39 animation_(new gfx::SlideAnimation(this)), 38 animation_(new gfx::SlideAnimation(this)),
40 view_(new SubtleNotificationView(nullptr)), 39 view_(new SubtleNotificationView(nullptr)),
41 popup_(SubtleNotificationView::CreatePopupWidget( 40 popup_(SubtleNotificationView::CreatePopupWidget(
42 bubble_view_context_->GetBubbleParentView(), 41 bubble_view_context_->GetBubbleParentView(),
43 view_, 42 view_,
44 false)) { 43 false)) {
45 UpdateContent(forward);
46 } 44 }
47 45
48 NewBackShortcutBubble::~NewBackShortcutBubble() { 46 NewBackShortcutBubble::~NewBackShortcutBubble() {
49 // We might need to delete the widget asynchronously. See rationale in 47 // We might need to delete the widget asynchronously. See rationale in
50 // ~ExclusiveAccessBubbleViews. 48 // ~ExclusiveAccessBubbleViews.
51 popup_->Close(); 49 popup_->Close();
52 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, popup_); 50 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, popup_);
53 } 51 }
54 52
53 bool NewBackShortcutBubble::IsVisible() const {
54 return popup_->IsVisible();
55 }
56
55 void NewBackShortcutBubble::UpdateContent(bool forward) { 57 void NewBackShortcutBubble::UpdateContent(bool forward) {
56 // Note: The key names are parameters so that we can vary by operating system 58 // Note: The key names are parameters so that we can vary by operating system
57 // or change the direction of the arrow as necessary (see 59 // or change the direction of the arrow as necessary (see
58 // https://crbug.com/612685). 60 // https://crbug.com/612685).
59 61
60 #if defined(OS_MACOSX) 62 #if defined(OS_MACOSX)
61 // U+2318 = PLACE OF INTEREST SIGN (Mac Command symbol). 63 // U+2318 = PLACE OF INTEREST SIGN (Mac Command symbol).
62 base::string16 accelerator = base::WideToUTF16(L"\x2318"); 64 base::string16 accelerator = base::WideToUTF16(L"\x2318");
63 #else 65 #else
64 base::string16 accelerator = l10n_util::GetStringUTF16(IDS_APP_ALT_KEY); 66 base::string16 accelerator = l10n_util::GetStringUTF16(IDS_APP_ALT_KEY);
(...skipping 13 matching lines...) Expand all
78 // Show the bubble. 80 // Show the bubble.
79 animation_->SetSlideDuration(kSlideInDurationMs); 81 animation_->SetSlideDuration(kSlideInDurationMs);
80 animation_->Show(); 82 animation_->Show();
81 83
82 // Wait a few seconds before hiding. 84 // Wait a few seconds before hiding.
83 hide_timeout_.Start(FROM_HERE, 85 hide_timeout_.Start(FROM_HERE,
84 base::TimeDelta::FromMilliseconds(kShowDurationMs), this, 86 base::TimeDelta::FromMilliseconds(kShowDurationMs), this,
85 &NewBackShortcutBubble::OnTimerElapsed); 87 &NewBackShortcutBubble::OnTimerElapsed);
86 } 88 }
87 89
90 void NewBackShortcutBubble::Hide() {
91 hide_timeout_.Stop();
92 OnTimerElapsed();
93 }
94
88 void NewBackShortcutBubble::AnimationProgressed( 95 void NewBackShortcutBubble::AnimationProgressed(
89 const gfx::Animation* animation) { 96 const gfx::Animation* animation) {
90 float opacity = static_cast<float>(animation_->CurrentValueBetween(0.0, 1.0)); 97 float opacity = static_cast<float>(animation_->CurrentValueBetween(0.0, 1.0));
91 if (opacity == 0) { 98 if (opacity == 0) {
92 popup_->Hide(); 99 popup_->Hide();
93 } else { 100 } else {
94 if (!popup_->IsVisible()) 101 if (!popup_->IsVisible())
95 popup_->Show(); 102 popup_->Show();
96 103
97 popup_->SetOpacity(opacity); 104 popup_->SetOpacity(opacity);
(...skipping 13 matching lines...) Expand all
111 int desired_top = kPopupTopPx - view_->border()->GetInsets().top(); 118 int desired_top = kPopupTopPx - view_->border()->GetInsets().top();
112 int y = widget_bounds.y() + desired_top; 119 int y = widget_bounds.y() + desired_top;
113 return gfx::Rect(gfx::Point(x, y), size); 120 return gfx::Rect(gfx::Point(x, y), size);
114 } 121 }
115 122
116 void NewBackShortcutBubble::OnTimerElapsed() { 123 void NewBackShortcutBubble::OnTimerElapsed() {
117 // Hide the bubble. 124 // Hide the bubble.
118 animation_->SetSlideDuration(kSlideOutDurationMs); 125 animation_->SetSlideDuration(kSlideOutDurationMs);
119 animation_->Hide(); 126 animation_->Hide();
120 } 127 }
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