| 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 #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/location.h" |
| 10 #include "base/single_thread_task_runner.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "chrome/browser/ui/views/exclusive_access_bubble_views_context.h" | 13 #include "chrome/browser/ui/views/exclusive_access_bubble_views_context.h" |
| 12 #include "chrome/browser/ui/views/subtle_notification_view.h" | 14 #include "chrome/browser/ui/views/subtle_notification_view.h" |
| 13 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/gfx/animation/animation.h" | 17 #include "ui/gfx/animation/animation.h" |
| 16 #include "ui/gfx/animation/slide_animation.h" | 18 #include "ui/gfx/animation/slide_animation.h" |
| 17 #include "ui/gfx/geometry/rect.h" | 19 #include "ui/gfx/geometry/rect.h" |
| 18 #include "ui/gfx/geometry/size.h" | 20 #include "ui/gfx/geometry/size.h" |
| 19 #include "ui/strings/grit/ui_strings.h" | 21 #include "ui/strings/grit/ui_strings.h" |
| 20 #include "ui/views/border.h" | 22 #include "ui/views/border.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 40 bubble_view_context_->GetBubbleParentView(), | 42 bubble_view_context_->GetBubbleParentView(), |
| 41 view_, | 43 view_, |
| 42 false)) { | 44 false)) { |
| 43 UpdateContent(forward); | 45 UpdateContent(forward); |
| 44 } | 46 } |
| 45 | 47 |
| 46 NewBackShortcutBubble::~NewBackShortcutBubble() { | 48 NewBackShortcutBubble::~NewBackShortcutBubble() { |
| 47 // We might need to delete the widget asynchronously. See rationale in | 49 // We might need to delete the widget asynchronously. See rationale in |
| 48 // ~ExclusiveAccessBubbleViews. | 50 // ~ExclusiveAccessBubbleViews. |
| 49 popup_->Close(); | 51 popup_->Close(); |
| 50 base::MessageLoop::current()->DeleteSoon(FROM_HERE, popup_); | 52 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, popup_); |
| 51 } | 53 } |
| 52 | 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"); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 int desired_top = kPopupTopPx - view_->border()->GetInsets().top(); | 111 int desired_top = kPopupTopPx - view_->border()->GetInsets().top(); |
| 110 int y = widget_bounds.y() + desired_top; | 112 int y = widget_bounds.y() + desired_top; |
| 111 return gfx::Rect(gfx::Point(x, y), size); | 113 return gfx::Rect(gfx::Point(x, y), size); |
| 112 } | 114 } |
| 113 | 115 |
| 114 void NewBackShortcutBubble::OnTimerElapsed() { | 116 void NewBackShortcutBubble::OnTimerElapsed() { |
| 115 // Hide the bubble. | 117 // Hide the bubble. |
| 116 animation_->SetSlideDuration(kSlideOutDurationMs); | 118 animation_->SetSlideDuration(kSlideOutDurationMs); |
| 117 animation_->Hide(); | 119 animation_->Hide(); |
| 118 } | 120 } |
| OLD | NEW |