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/location.h" | 9 #include "base/location.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 } | 55 } |
56 | 56 |
57 void NewBackShortcutBubble::UpdateContent(bool forward) { | 57 void NewBackShortcutBubble::UpdateContent(bool forward) { |
58 // 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 |
59 // or change the direction of the arrow as necessary (see | 59 // or change the direction of the arrow as necessary (see |
60 // https://crbug.com/612685). | 60 // https://crbug.com/612685). |
61 | 61 |
62 #if defined(OS_MACOSX) | 62 #if defined(OS_MACOSX) |
63 // U+2318 = PLACE OF INTEREST SIGN (Mac Command symbol). | 63 // U+2318 = PLACE OF INTEREST SIGN (Mac Command symbol). |
64 base::string16 accelerator = base::WideToUTF16(L"\x2318"); | 64 base::string16 accelerator = base::WideToUTF16(L"\x2318"); |
| 65 base::string16 accessible_accelerator = |
| 66 l10n_util::GetStringUTF16(IDS_MAC_COMMAND_KEY_DESCRIPTION); |
65 #else | 67 #else |
66 base::string16 accelerator = l10n_util::GetStringUTF16(IDS_APP_ALT_KEY); | 68 base::string16 accelerator = l10n_util::GetStringUTF16(IDS_APP_ALT_KEY); |
| 69 base::string16 accessible_accelerator = accelerator; |
67 #endif | 70 #endif |
68 | 71 |
69 int message_id = forward ? IDS_PRESS_ALT_RIGHT_TO_GO_FORWARD | 72 int message_id = forward ? IDS_PRESS_ALT_RIGHT_TO_GO_FORWARD |
70 : IDS_PRESS_ALT_LEFT_TO_GO_BACK; | 73 : IDS_PRESS_ALT_LEFT_TO_GO_BACK; |
71 // U+2192 = RIGHTWARDS ARROW; U+2190 = LEFTWARDS ARROW. | 74 // U+2192 = RIGHTWARDS ARROW; U+2190 = LEFTWARDS ARROW. |
72 base::string16 arrow_key = base::WideToUTF16(forward ? L"\x2192" : L"\x2190"); | 75 base::string16 arrow_key = base::WideToUTF16(forward ? L"\x2192" : L"\x2190"); |
| 76 base::string16 accessible_arrow_key = |
| 77 forward ? l10n_util::GetStringUTF16(IDS_APP_RIGHT_ARROW_KEY) |
| 78 : l10n_util::GetStringUTF16(IDS_APP_LEFT_ARROW_KEY); |
| 79 view_->SetAccessibleName(l10n_util::GetStringFUTF16( |
| 80 message_id, accessible_accelerator, accessible_arrow_key)); |
73 view_->UpdateContent( | 81 view_->UpdateContent( |
74 l10n_util::GetStringFUTF16(message_id, accelerator, arrow_key), | 82 l10n_util::GetStringFUTF16(message_id, accelerator, arrow_key), |
75 base::string16()); | 83 base::string16()); |
76 | 84 |
77 view_->SetSize(GetPopupRect(true).size()); | 85 view_->SetSize(GetPopupRect(true).size()); |
78 popup_->SetBounds(GetPopupRect(false)); | 86 popup_->SetBounds(GetPopupRect(false)); |
79 | 87 |
80 // Show the bubble. | 88 // Show the bubble. |
81 animation_->SetSlideDuration(kSlideInDurationMs); | 89 animation_->SetSlideDuration(kSlideInDurationMs); |
82 animation_->Show(); | 90 animation_->Show(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 int desired_top = kPopupTopPx - view_->border()->GetInsets().top(); | 126 int desired_top = kPopupTopPx - view_->border()->GetInsets().top(); |
119 int y = widget_bounds.y() + desired_top; | 127 int y = widget_bounds.y() + desired_top; |
120 return gfx::Rect(gfx::Point(x, y), size); | 128 return gfx::Rect(gfx::Point(x, y), size); |
121 } | 129 } |
122 | 130 |
123 void NewBackShortcutBubble::OnTimerElapsed() { | 131 void NewBackShortcutBubble::OnTimerElapsed() { |
124 // Hide the bubble. | 132 // Hide the bubble. |
125 animation_->SetSlideDuration(kSlideOutDurationMs); | 133 animation_->SetSlideDuration(kSlideOutDurationMs); |
126 animation_->Hide(); | 134 animation_->Hide(); |
127 } | 135 } |
OLD | NEW |