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

Side by Side Diff: ios/chrome/browser/ui/key_commands_provider.mm

Issue 2970553002: [ios] Remove IDC_CLOSE_TAB
Patch Set: Add comment for chrome_test_util.h" 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 unified diff | Download patch
OLDNEW
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 #import "ios/chrome/browser/ui/key_commands_provider.h" 5 #import "ios/chrome/browser/ui/key_commands_provider.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "components/strings/grit/components_strings.h" 8 #include "components/strings/grit/components_strings.h"
9 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" 9 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h"
10 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" 10 #include "ios/chrome/browser/ui/commands/ios_command_ids.h"
11 #import "ios/chrome/browser/ui/keyboard/UIKeyCommand+Chrome.h" 11 #import "ios/chrome/browser/ui/keyboard/UIKeyCommand+Chrome.h"
12 #include "ios/chrome/browser/ui/rtl_geometry.h" 12 #include "ios/chrome/browser/ui/rtl_geometry.h"
13 #include "ios/chrome/grit/ios_strings.h" 13 #include "ios/chrome/grit/ios_strings.h"
14 #include "ui/base/l10n/l10n_util_mac.h" 14 #include "ui/base/l10n/l10n_util_mac.h"
15 15
16 #if !defined(__has_feature) || !__has_feature(objc_arc) 16 #if !defined(__has_feature) || !__has_feature(objc_arc)
17 #error "This file requires ARC support." 17 #error "This file requires ARC support."
18 #endif 18 #endif
19 19
20 @implementation KeyCommandsProvider 20 @implementation KeyCommandsProvider
21 21
22 - (NSArray*)keyCommandsForConsumer:(id<KeyCommandsPlumbing>)consumer 22 - (NSArray*)keyCommandsForConsumer:(id<KeyCommandsPlumbing>)consumer
23 browserCommandDispatcher:(id<BrowserCommands>)dispatcher
23 editingText:(BOOL)editingText { 24 editingText:(BOOL)editingText {
24 __weak id<KeyCommandsPlumbing> weakConsumer = consumer; 25 __weak id<KeyCommandsPlumbing> weakConsumer = consumer;
26 __weak id<BrowserCommands> weakDispatcher = dispatcher;
25 27
26 // Block to execute a command from the |tag|. 28 // Block to execute a command from the |tag|.
27 void (^execute)(NSInteger) = ^(NSInteger tag) { 29 void (^execute)(NSInteger) = ^(NSInteger tag) {
28 [weakConsumer 30 [weakConsumer
29 chromeExecuteCommand:[GenericChromeCommand commandWithTag:tag]]; 31 chromeExecuteCommand:[GenericChromeCommand commandWithTag:tag]];
30 }; 32 };
31 33
32 // Block to have the tab model open the tab at |index|, if there is one. 34 // Block to have the tab model open the tab at |index|, if there is one.
33 void (^focusTab)(NSUInteger) = ^(NSUInteger index) { 35 void (^focusTab)(NSUInteger) = ^(NSUInteger index) {
34 [weakConsumer focusTabAtIndex:index]; 36 [weakConsumer focusTabAtIndex:index];
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 title:l10n_util::GetNSStringWithFixup( 100 title:l10n_util::GetNSStringWithFixup(
99 IDS_IOS_KEYBOARD_OPEN_LOCATION) 101 IDS_IOS_KEYBOARD_OPEN_LOCATION)
100 action:^{ 102 action:^{
101 [weakConsumer focusOmnibox]; 103 [weakConsumer focusOmnibox];
102 }], 104 }],
103 [UIKeyCommand cr_keyCommandWithInput:@"w" 105 [UIKeyCommand cr_keyCommandWithInput:@"w"
104 modifierFlags:UIKeyModifierCommand 106 modifierFlags:UIKeyModifierCommand
105 title:l10n_util::GetNSStringWithFixup( 107 title:l10n_util::GetNSStringWithFixup(
106 IDS_IOS_TOOLS_MENU_CLOSE_TAB) 108 IDS_IOS_TOOLS_MENU_CLOSE_TAB)
107 action:^{ 109 action:^{
108 execute(IDC_CLOSE_TAB); 110 [weakDispatcher closeCurrentTab];
109 }], 111 }],
110 [UIKeyCommand 112 [UIKeyCommand
111 cr_keyCommandWithInput:@"d" 113 cr_keyCommandWithInput:@"d"
112 modifierFlags:UIKeyModifierCommand 114 modifierFlags:UIKeyModifierCommand
113 title:l10n_util::GetNSStringWithFixup( 115 title:l10n_util::GetNSStringWithFixup(
114 IDS_IOS_KEYBOARD_BOOKMARK_THIS_PAGE) 116 IDS_IOS_KEYBOARD_BOOKMARK_THIS_PAGE)
115 action:^{ 117 action:^{
116 execute(IDC_BOOKMARK_PAGE); 118 execute(IDC_BOOKMARK_PAGE);
117 }], 119 }],
118 [UIKeyCommand cr_keyCommandWithInput:@"f" 120 [UIKeyCommand cr_keyCommandWithInput:@"f"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 action:^{ 317 action:^{
316 [weakConsumer focusNextTab]; 318 [weakConsumer focusNextTab];
317 }], 319 }],
318 ]]; 320 ]];
319 } 321 }
320 322
321 return keyCommands; 323 return keyCommands;
322 } 324 }
323 325
324 @end 326 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/key_commands_provider.h ('k') | ios/chrome/browser/ui/key_commands_provider_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698