OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/tools_menu/tools_menu_view_tools_cell.h" | 5 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_tools_cell.h" |
6 | 6 |
7 #include "components/strings/grit/components_strings.h" | 7 #include "components/strings/grit/components_strings.h" |
8 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" | 8 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
9 #include "ios/chrome/browser/ui/rtl_geometry.h" | 9 #include "ios/chrome/browser/ui/rtl_geometry.h" |
10 #include "ios/chrome/browser/ui/toolbar/toolbar_resource_macros.h" | 10 #include "ios/chrome/browser/ui/toolbar/toolbar_resource_macros.h" |
11 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h" | 11 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h" |
12 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 12 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
13 #include "ios/chrome/grit/ios_strings.h" | 13 #include "ios/chrome/grit/ios_strings.h" |
14 | 14 |
15 // TODO(crbug.com/228521): Remove this once the new command/metric handling is | |
16 // implemented. This is a temporary workaround to allow metrics recording to | |
17 // distinguish the action. The value used is in the dynamic range (< | |
18 // IDC_MinimumLabelValue) to avoid collisions. | |
19 #define IDC_TEMP_EDIT_BOOKMARK 3900 | |
20 | |
21 #if !defined(__has_feature) || !__has_feature(objc_arc) | 15 #if !defined(__has_feature) || !__has_feature(objc_arc) |
22 #error "This file requires ARC support." | 16 #error "This file requires ARC support." |
23 #endif | 17 #endif |
24 | 18 |
25 @implementation ToolsMenuViewToolsCell | 19 @implementation ToolsMenuViewToolsCell |
26 | 20 |
27 @synthesize reloadButton = _reloadButton; | 21 @synthesize reloadButton = _reloadButton; |
28 @synthesize shareButton = _shareButton; | 22 @synthesize shareButton = _shareButton; |
29 @synthesize starButton = _starButton; | 23 @synthesize starButton = _starButton; |
30 @synthesize starredButton = _starredButton; | 24 @synthesize starredButton = _starredButton; |
(...skipping 15 matching lines...) Expand all Loading... |
46 | 40 |
47 return self; | 41 return self; |
48 } | 42 } |
49 | 43 |
50 - (void)commonInitialization { | 44 - (void)commonInitialization { |
51 [self setBackgroundColor:[UIColor whiteColor]]; | 45 [self setBackgroundColor:[UIColor whiteColor]]; |
52 [self setOpaque:YES]; | 46 [self setOpaque:YES]; |
53 | 47 |
54 int star[2][3] = TOOLBAR_IDR_TWO_STATE(STAR); | 48 int star[2][3] = TOOLBAR_IDR_TWO_STATE(STAR); |
55 _starButton = [self newButtonForImageIds:star | 49 _starButton = [self newButtonForImageIds:star |
56 commandID:IDC_BOOKMARK_PAGE | 50 commandID:TOOLS_BOOKMARK_ITEM |
57 accessibilityLabelID:IDS_BOOKMARK_ADD_EDITOR_TITLE | 51 accessibilityLabelID:IDS_BOOKMARK_ADD_EDITOR_TITLE |
58 automationName:@"Add Bookmark"]; | 52 automationName:@"Add Bookmark"]; |
59 | 53 |
60 int star_pressed[2][3] = TOOLBAR_IDR_ONE_STATE(STAR_PRESSED); | 54 int star_pressed[2][3] = TOOLBAR_IDR_ONE_STATE(STAR_PRESSED); |
61 _starredButton = [self newButtonForImageIds:star_pressed | 55 _starredButton = [self newButtonForImageIds:star_pressed |
62 commandID:IDC_TEMP_EDIT_BOOKMARK | 56 commandID:TOOLS_BOOKMARK_EDIT |
63 accessibilityLabelID:IDS_IOS_TOOLS_MENU_EDIT_BOOKMARK | 57 accessibilityLabelID:IDS_IOS_TOOLS_MENU_EDIT_BOOKMARK |
64 automationName:@"Edit Bookmark"]; | 58 automationName:@"Edit Bookmark"]; |
65 | 59 |
66 int reload[2][3] = TOOLBAR_IDR_TWO_STATE(RELOAD); | 60 int reload[2][3] = TOOLBAR_IDR_TWO_STATE(RELOAD); |
67 _reloadButton = [self newButtonForImageIds:reload | 61 _reloadButton = [self newButtonForImageIds:reload |
68 commandID:TOOLS_RELAOD_ITEM | 62 commandID:TOOLS_RELAOD_ITEM |
69 accessibilityLabelID:IDS_IOS_ACCNAME_RELOAD | 63 accessibilityLabelID:IDS_IOS_ACCNAME_RELOAD |
70 automationName:@"Reload" | 64 automationName:@"Reload" |
71 reverseForRTL:YES]; | 65 reverseForRTL:YES]; |
72 | 66 |
73 int stop[2][3] = TOOLBAR_IDR_TWO_STATE(STOP); | 67 int stop[2][3] = TOOLBAR_IDR_TWO_STATE(STOP); |
74 _stopButton = [self newButtonForImageIds:stop | 68 _stopButton = [self newButtonForImageIds:stop |
75 commandID:TOOLS_STOP_ITEM | 69 commandID:TOOLS_STOP_ITEM |
76 accessibilityLabelID:IDS_IOS_ACCNAME_STOP | 70 accessibilityLabelID:IDS_IOS_ACCNAME_STOP |
77 automationName:@"Stop"]; | 71 automationName:@"Stop"]; |
78 | 72 |
79 int share[2][3] = TOOLBAR_IDR_THREE_STATE(SHARE); | 73 int share[2][3] = TOOLBAR_IDR_THREE_STATE(SHARE); |
80 _shareButton = [self newButtonForImageIds:share | 74 _shareButton = [self newButtonForImageIds:share |
81 commandID:IDC_SHARE_PAGE | 75 commandID:TOOLS_SHARE_ITEM |
82 accessibilityLabelID:IDS_IOS_TOOLS_MENU_SHARE | 76 accessibilityLabelID:IDS_IOS_TOOLS_MENU_SHARE |
83 automationName:@"Stop"]; | 77 automationName:@"Stop"]; |
84 int tools[2][3] = TOOLBAR_IDR_ONE_STATE(TOOLS_PRESSED); | 78 int tools[2][3] = TOOLBAR_IDR_ONE_STATE(TOOLS_PRESSED); |
85 _toolsButton = | 79 _toolsButton = |
86 [self newButtonForImageIds:tools | 80 [self newButtonForImageIds:tools |
87 commandID:IDC_SHOW_TOOLS_MENU | 81 commandID:IDC_SHOW_TOOLS_MENU |
88 accessibilityLabelID:IDS_IOS_TOOLBAR_CLOSE_MENU | 82 accessibilityLabelID:IDS_IOS_TOOLBAR_CLOSE_MENU |
89 automationName:@"kToolbarToolsMenuButtonIdentifier"]; | 83 automationName:@"kToolbarToolsMenuButtonIdentifier"]; |
90 | 84 |
91 UIView* contentView = [self contentView]; | 85 UIView* contentView = [self contentView]; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 if (_reloadButton) | 189 if (_reloadButton) |
196 [allButtons addObject:_reloadButton]; | 190 [allButtons addObject:_reloadButton]; |
197 | 191 |
198 if (_stopButton) | 192 if (_stopButton) |
199 [allButtons addObject:_stopButton]; | 193 [allButtons addObject:_stopButton]; |
200 | 194 |
201 return allButtons; | 195 return allButtons; |
202 } | 196 } |
203 | 197 |
204 @end | 198 @end |
OLD | NEW |