Commit 00d3a368 authored by pkasting's avatar pkasting Committed by Commit bot

Use standardized accelerator-to-shortcut code for new backspace shortcut UI.

This changes the left and right arrow symbols into text (e.g. "left arrow"),
reducing ambiguity.  It also promotes cmd-[ over cmd-left on Mac.

BUG=637547
TEST=On a new profile, have a page in your "back" session history, then hit backspace twice while outside a textfield to trigger the "Use alt-left to go back" UI.  It should say "Left arrow" instead of "<-".

Review-Url: https://codereview.chromium.org/2540523003
Cr-Commit-Position: refs/heads/master@{#439747}
parent 08396cf1
......@@ -12857,11 +12857,11 @@ Tell us what happened exactly before you got the profile error message:
</message>
<!-- Backspace shortcut notification strings -->
<message name="IDS_PRESS_ALT_LEFT_TO_GO_BACK" desc="Text displayed in the bubble to explain the keyboard shortcut to go back to the previous web page in history. The accelerators are names of keyboard keys. Please surround the names of the keys (e.g. 'Alt' and '←') in pipe characters so they can be rendered correctly.">
Press |<ph name="ACCELERATOR1">$1<ex>Alt</ex></ph>|+|<ph name="ACCELERATOR2">$2<ex></ex></ph>| to go back
<message name="IDS_PRESS_SHORTCUT_TO_GO_BACK" desc="Text displayed in the bubble to explain the keyboard shortcut to go back to the previous web page in history. The shortcut names a keyboard key or key chord. Please surround the shortcut in pipe characters so it can be rendered correctly.">
Press |<ph name="SHORTCUT">$1<ex>Alt-Left</ex></ph>| to go back
</message>
<message name="IDS_PRESS_ALT_RIGHT_TO_GO_FORWARD" desc="Text displayed in the bubble to explain the keyboard shortcut to go forward to the next web page in history. The accelerators are names of keyboard keys. Please surround the names of the keys (e.g. 'Alt' and '→') in pipe characters so they can be rendered correctly.">
Press |<ph name="ACCELERATOR1">$1<ex>Alt</ex></ph>|+|<ph name="ACCELERATOR2">$2<ex></ex></ph>| to go forward
<message name="IDS_PRESS_SHORTCUT_TO_GO_FORWARD" desc="Text displayed in the bubble to explain the keyboard shortcut to go forward to the next web page in history. The accelerators are names of keyboard keys. The shortcut names a keyboard key or key chord. Please surround the shortcut in pipe characters so it can be rendered correctly.">
Press |<ph name="SHORTCUT">$1<ex>Alt-Right</ex></ph>| to go forward
</message>
<!-- Register Protocol Handler Strings -->
......
......@@ -10,6 +10,7 @@
#include "base/single_thread_task_runner.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/ui/views/exclusive_access_bubble_views_context.h"
#include "chrome/browser/ui/views/subtle_notification_view.h"
#include "chrome/grit/generated_resources.h"
......@@ -55,23 +56,16 @@ bool NewBackShortcutBubble::IsVisible() const {
}
void NewBackShortcutBubble::UpdateContent(bool forward) {
// Note: The key names are parameters so that we can vary by operating system
// or change the direction of the arrow as necessary (see
// https://crbug.com/612685).
#if defined(OS_MACOSX)
// U+2318 = PLACE OF INTEREST SIGN (Mac Command symbol).
base::string16 accelerator = base::WideToUTF16(L"\x2318");
#else
base::string16 accelerator = l10n_util::GetStringUTF16(IDS_APP_ALT_KEY);
#endif
int message_id = forward ? IDS_PRESS_ALT_RIGHT_TO_GO_FORWARD
: IDS_PRESS_ALT_LEFT_TO_GO_BACK;
// U+2192 = RIGHTWARDS ARROW; U+2190 = LEFTWARDS ARROW.
base::string16 arrow_key = base::WideToUTF16(forward ? L"\x2192" : L"\x2190");
const int command_id = forward ? IDC_FORWARD : IDC_BACK;
ui::Accelerator accelerator;
const bool got_accelerator =
bubble_view_context_->GetAcceleratorProvider()
->GetAcceleratorForCommandId(command_id, &accelerator);
DCHECK(got_accelerator);
const int message_id = forward ? IDS_PRESS_SHORTCUT_TO_GO_FORWARD
: IDS_PRESS_SHORTCUT_TO_GO_BACK;
view_->UpdateContent(
l10n_util::GetStringFUTF16(message_id, accelerator, arrow_key),
l10n_util::GetStringFUTF16(message_id, accelerator.GetShortcutText()),
base::string16());
view_->SetSize(GetPopupRect(true).size());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment