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

Unified Diff: ios/chrome/browser/ui/key_commands_provider.mm

Issue 2965943002: [ios] Remove IDC_BACK and IDC_FORWARD
Patch Set: Rebase, self review. Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/key_commands_provider.mm
diff --git a/ios/chrome/browser/ui/key_commands_provider.mm b/ios/chrome/browser/ui/key_commands_provider.mm
index 6473ddce21a4ef1ed26d65e2c8a4643c56f9f972..f303c71bd9048ad2199e3c244e42b9f45d96eb14 100644
--- a/ios/chrome/browser/ui/key_commands_provider.mm
+++ b/ios/chrome/browser/ui/key_commands_provider.mm
@@ -39,22 +39,36 @@
const BOOL hasTabs = [consumer tabsCount] > 0;
const BOOL useRTLLayout = UseRTLLayout();
- const NSInteger browseLeft = useRTLLayout ? IDC_FORWARD : IDC_BACK;
- const NSInteger browseRight = useRTLLayout ? IDC_BACK : IDC_FORWARD;
+
+ // Blocks for navigating forward/back.
+ void (^browseLeft)();
+ void (^browseRight)();
+ if (useRTLLayout) {
+ browseLeft = [^{
+ if ([weakConsumer canGoForward])
+ [weakDispatcher goForward];
+ } copy];
+ browseRight = [^{
+ if ([weakConsumer canGoBack])
+ [weakDispatcher goBack];
+ } copy];
+ } else {
+ browseLeft = [^{
+ if ([weakConsumer canGoBack])
+ [weakDispatcher goBack];
+ } copy];
+ browseRight = [^{
+ if ([weakConsumer canGoForward])
+ [weakDispatcher goForward];
+ } copy];
+ }
+
const int browseLeftDescriptionID = useRTLLayout
? IDS_IOS_KEYBOARD_HISTORY_FORWARD
: IDS_IOS_KEYBOARD_HISTORY_BACK;
const int browseRightDescriptionID = useRTLLayout
? IDS_IOS_KEYBOARD_HISTORY_BACK
: IDS_IOS_KEYBOARD_HISTORY_FORWARD;
- BOOL (^canBrowseLeft)() = ^() {
- return useRTLLayout ? [weakConsumer canGoForward]
- : [weakConsumer canGoBack];
- };
- BOOL (^canBrowseRight)() = ^() {
- return useRTLLayout ? [weakConsumer canGoBack]
- : [weakConsumer canGoForward];
- };
// Initialize the array of commands with an estimated capacity.
NSMutableArray* keyCommands = [NSMutableArray arrayWithCapacity:32];
@@ -155,18 +169,14 @@
title:l10n_util::GetNSStringWithFixup(
browseLeftDescriptionID)
action:^{
- if (canBrowseLeft()) {
- execute(browseLeft);
- }
+ browseLeft();
}],
[UIKeyCommand cr_keyCommandWithInput:UIKeyInputRightArrow
modifierFlags:UIKeyModifierCommand
title:l10n_util::GetNSStringWithFixup(
browseRightDescriptionID)
action:^{
- if (canBrowseRight()) {
- execute(browseRight);
- }
+ browseRight();
}],
]];
}
@@ -225,17 +235,13 @@
modifierFlags:UIKeyModifierCommand
title:nil
action:^{
- if (canBrowseLeft()) {
- execute(browseLeft);
- }
+ browseLeft();
}],
[UIKeyCommand cr_keyCommandWithInput:@"]"
modifierFlags:UIKeyModifierCommand
title:nil
action:^{
- if (canBrowseRight()) {
- execute(browseRight);
- }
+ browseRight();
}],
[UIKeyCommand cr_keyCommandWithInput:@"."
modifierFlags:UIKeyModifierCommand
« no previous file with comments | « ios/chrome/browser/ui/commands/ios_command_ids.h ('k') | ios/chrome/browser/ui/ntp/new_tab_page_toolbar_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698