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

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

Issue 2631733002: Avoid sending IDC_BACK/FORWARD when back/forward is not possible (Closed)
Patch Set: Rebased Created 3 years, 11 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
« no previous file with comments | « ios/chrome/browser/ui/key_commands_provider.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c254dbd0f14954efd3285c54a84ff9f222cc578b..6165af2e75b7e30ada3929e24b3c398353846f42 100644
--- a/ios/chrome/browser/ui/key_commands_provider.mm
+++ b/ios/chrome/browser/ui/key_commands_provider.mm
@@ -42,6 +42,14 @@
const int browseRightDescriptionID = useRTLLayout
? IDS_IOS_KEYBOARD_HISTORY_BACK
: IDS_IOS_KEYBOARD_HISTORY_FORWARD;
+ BOOL (^canBrowseLeft)() = [[^() {
+ return useRTLLayout ? [weakConsumer canGoForward]
+ : [weakConsumer canGoBack];
+ } copy] autorelease];
+ BOOL (^canBrowseRight)() = [[^() {
+ return useRTLLayout ? [weakConsumer canGoBack]
+ : [weakConsumer canGoForward];
+ } copy] autorelease];
// Initialize the array of commands with an estimated capacity.
NSMutableArray* keyCommands = [NSMutableArray arrayWithCapacity:32];
@@ -142,14 +150,18 @@
title:l10n_util::GetNSStringWithFixup(
browseLeftDescriptionID)
action:^{
- execute(browseLeft);
+ if (canBrowseLeft()) {
+ execute(browseLeft);
+ }
}],
[UIKeyCommand cr_keyCommandWithInput:UIKeyInputRightArrow
modifierFlags:UIKeyModifierCommand
title:l10n_util::GetNSStringWithFixup(
browseRightDescriptionID)
action:^{
- execute(browseRight);
+ if (canBrowseRight()) {
+ execute(browseRight);
+ }
}],
]];
}
@@ -208,13 +220,17 @@
modifierFlags:UIKeyModifierCommand
title:nil
action:^{
- execute(browseLeft);
+ if (canBrowseLeft()) {
+ execute(browseLeft);
+ }
}],
[UIKeyCommand cr_keyCommandWithInput:@"]"
modifierFlags:UIKeyModifierCommand
title:nil
action:^{
- execute(browseRight);
+ if (canBrowseRight()) {
+ execute(browseRight);
+ }
}],
[UIKeyCommand cr_keyCommandWithInput:@"."
modifierFlags:UIKeyModifierCommand
« no previous file with comments | « ios/chrome/browser/ui/key_commands_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698