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

Side by Side Diff: ios/clean/chrome/browser/ui/toolbar/toolbar_button+factory.mm

Issue 2936773003: [ios clean] Toolbar accessibility and showcase egtests (Closed)
Patch Set: Rename A11y string Created 3 years, 6 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
« no previous file with comments | « ios/clean/chrome/browser/ui/toolbar/BUILD.gn ('k') | ios/showcase/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/clean/chrome/browser/ui/toolbar/toolbar_button+factory.h" 5 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_button+factory.h"
6 6
7 #include "components/strings/grit/components_strings.h"
7 #import "ios/chrome/browser/ui/rtl_geometry.h" 8 #import "ios/chrome/browser/ui/rtl_geometry.h"
8 #import "ios/chrome/browser/ui/uikit_ui_util.h" 9 #import "ios/chrome/browser/ui/uikit_ui_util.h"
10 #include "ios/chrome/grit/ios_strings.h"
9 #include "ios/chrome/grit/ios_theme_resources.h" 11 #include "ios/chrome/grit/ios_theme_resources.h"
12 #include "ui/base/l10n/l10n_util.h"
10 13
11 #if !defined(__has_feature) || !__has_feature(objc_arc) 14 #if !defined(__has_feature) || !__has_feature(objc_arc)
12 #error "This file requires ARC support." 15 #error "This file requires ARC support."
13 #endif 16 #endif
14 17
15 @implementation ToolbarButton (Factory) 18 @implementation ToolbarButton (Factory)
16 19
17 #pragma mark - ToolbarButton Setup 20 #pragma mark - ToolbarButton Setup
18 21
19 + (instancetype)backToolbarButton { 22 + (instancetype)backToolbarButton {
20 ToolbarButton* backButton = [self 23 ToolbarButton* backButton = [self
21 toolbarButtonWithImageForNormalState:NativeReversableImage( 24 toolbarButtonWithImageForNormalState:NativeReversableImage(
22 IDR_IOS_TOOLBAR_LIGHT_BACK, YES) 25 IDR_IOS_TOOLBAR_LIGHT_BACK, YES)
23 imageForHighlightedState: 26 imageForHighlightedState:
24 NativeReversableImage(IDR_IOS_TOOLBAR_LIGHT_BACK_PRESSED, 27 NativeReversableImage(IDR_IOS_TOOLBAR_LIGHT_BACK_PRESSED,
25 YES) 28 YES)
26 imageForDisabledState: 29 imageForDisabledState:
27 NativeReversableImage( 30 NativeReversableImage(
28 IDR_IOS_TOOLBAR_LIGHT_BACK_DISABLED, YES)]; 31 IDR_IOS_TOOLBAR_LIGHT_BACK_DISABLED, YES)];
32 backButton.accessibilityLabel = l10n_util::GetNSString(IDS_ACCNAME_BACK);
29 return backButton; 33 return backButton;
30 } 34 }
31 35
32 + (instancetype)forwardToolbarButton { 36 + (instancetype)forwardToolbarButton {
33 ToolbarButton* forwardButton = [self 37 ToolbarButton* forwardButton = [self
34 toolbarButtonWithImageForNormalState:NativeReversableImage( 38 toolbarButtonWithImageForNormalState:NativeReversableImage(
35 IDR_IOS_TOOLBAR_LIGHT_FORWARD, 39 IDR_IOS_TOOLBAR_LIGHT_FORWARD,
36 YES) 40 YES)
37 imageForHighlightedState: 41 imageForHighlightedState:
38 NativeReversableImage( 42 NativeReversableImage(
39 IDR_IOS_TOOLBAR_LIGHT_FORWARD_PRESSED, YES) 43 IDR_IOS_TOOLBAR_LIGHT_FORWARD_PRESSED, YES)
40 imageForDisabledState: 44 imageForDisabledState:
41 NativeReversableImage( 45 NativeReversableImage(
42 IDR_IOS_TOOLBAR_LIGHT_FORWARD_DISABLED, YES)]; 46 IDR_IOS_TOOLBAR_LIGHT_FORWARD_DISABLED, YES)];
47 forwardButton.accessibilityLabel =
48 l10n_util::GetNSString(IDS_ACCNAME_FORWARD);
43 return forwardButton; 49 return forwardButton;
44 } 50 }
45 51
46 + (instancetype)tabSwitcherStripToolbarButton { 52 + (instancetype)tabSwitcherStripToolbarButton {
47 ToolbarButton* tabSwitcherStripButton = [self 53 ToolbarButton* tabSwitcherStripButton = [self
48 toolbarButtonWithImageForNormalState:NativeImage( 54 toolbarButtonWithImageForNormalState:NativeImage(
49 IDR_IOS_TOOLBAR_LIGHT_OVERVIEW) 55 IDR_IOS_TOOLBAR_LIGHT_OVERVIEW)
50 imageForHighlightedState: 56 imageForHighlightedState:
51 NativeImage(IDR_IOS_TOOLBAR_LIGHT_OVERVIEW_PRESSED) 57 NativeImage(IDR_IOS_TOOLBAR_LIGHT_OVERVIEW_PRESSED)
52 imageForDisabledState: 58 imageForDisabledState:
53 NativeImage(IDR_IOS_TOOLBAR_LIGHT_OVERVIEW_DISABLED)]; 59 NativeImage(IDR_IOS_TOOLBAR_LIGHT_OVERVIEW_DISABLED)];
60 tabSwitcherStripButton.accessibilityLabel =
61 l10n_util::GetNSString(IDS_IOS_TOOLBAR_SHOW_TABS);
54 return tabSwitcherStripButton; 62 return tabSwitcherStripButton;
55 } 63 }
56 64
57 + (instancetype)tabSwitcherGridToolbarButton { 65 + (instancetype)tabSwitcherGridToolbarButton {
58 ToolbarButton* tabSwitcherGridButton = 66 ToolbarButton* tabSwitcherGridButton =
59 [self toolbarButtonWithImageForNormalState: 67 [self toolbarButtonWithImageForNormalState:
60 [UIImage imageNamed:@"tabswitcher_tab_switcher_button"] 68 [UIImage imageNamed:@"tabswitcher_tab_switcher_button"]
61 imageForHighlightedState:nil 69 imageForHighlightedState:nil
62 imageForDisabledState:nil]; 70 imageForDisabledState:nil];
71 tabSwitcherGridButton.accessibilityLabel =
72 l10n_util::GetNSString(IDS_IOS_TOOLBAR_SHOW_TAB_GRID);
63 return tabSwitcherGridButton; 73 return tabSwitcherGridButton;
64 } 74 }
65 75
66 + (instancetype)toolsMenuToolbarButton { 76 + (instancetype)toolsMenuToolbarButton {
67 ToolbarButton* toolsMenuButton = [self 77 ToolbarButton* toolsMenuButton = [self
68 toolbarButtonWithImageForNormalState:NativeImage( 78 toolbarButtonWithImageForNormalState:NativeImage(
69 IDR_IOS_TOOLBAR_LIGHT_TOOLS) 79 IDR_IOS_TOOLBAR_LIGHT_TOOLS)
70 imageForHighlightedState: 80 imageForHighlightedState:
71 NativeImage(IDR_IOS_TOOLBAR_LIGHT_TOOLS_PRESSED) 81 NativeImage(IDR_IOS_TOOLBAR_LIGHT_TOOLS_PRESSED)
72 imageForDisabledState:nil]; 82 imageForDisabledState:nil];
73 [toolsMenuButton setImageEdgeInsets:UIEdgeInsetsMakeDirected(0, -3, 0, 0)]; 83 [toolsMenuButton setImageEdgeInsets:UIEdgeInsetsMakeDirected(0, -3, 0, 0)];
84 toolsMenuButton.accessibilityLabel =
85 l10n_util::GetNSString(IDS_IOS_TOOLBAR_SETTINGS);
74 return toolsMenuButton; 86 return toolsMenuButton;
75 } 87 }
76 88
77 + (instancetype)shareToolbarButton { 89 + (instancetype)shareToolbarButton {
78 ToolbarButton* shareButton = [self 90 ToolbarButton* shareButton = [self
79 toolbarButtonWithImageForNormalState:NativeImage( 91 toolbarButtonWithImageForNormalState:NativeImage(
80 IDR_IOS_TOOLBAR_LIGHT_SHARE) 92 IDR_IOS_TOOLBAR_LIGHT_SHARE)
81 imageForHighlightedState: 93 imageForHighlightedState:
82 NativeImage(IDR_IOS_TOOLBAR_LIGHT_SHARE_PRESSED) 94 NativeImage(IDR_IOS_TOOLBAR_LIGHT_SHARE_PRESSED)
83 imageForDisabledState: 95 imageForDisabledState:
84 NativeImage(IDR_IOS_TOOLBAR_LIGHT_SHARE_DISABLED)]; 96 NativeImage(IDR_IOS_TOOLBAR_LIGHT_SHARE_DISABLED)];
97 shareButton.accessibilityLabel =
98 l10n_util::GetNSString(IDS_IOS_TOOLS_MENU_SHARE);
85 return shareButton; 99 return shareButton;
86 } 100 }
87 101
88 + (instancetype)reloadToolbarButton { 102 + (instancetype)reloadToolbarButton {
89 ToolbarButton* reloadButton = [self 103 ToolbarButton* reloadButton = [self
90 toolbarButtonWithImageForNormalState:NativeReversableImage( 104 toolbarButtonWithImageForNormalState:NativeReversableImage(
91 IDR_IOS_TOOLBAR_LIGHT_RELOAD, 105 IDR_IOS_TOOLBAR_LIGHT_RELOAD,
92 YES) 106 YES)
93 imageForHighlightedState: 107 imageForHighlightedState:
94 NativeReversableImage( 108 NativeReversableImage(
95 IDR_IOS_TOOLBAR_LIGHT_RELOAD_PRESSED, YES) 109 IDR_IOS_TOOLBAR_LIGHT_RELOAD_PRESSED, YES)
96 imageForDisabledState: 110 imageForDisabledState:
97 NativeReversableImage( 111 NativeReversableImage(
98 IDR_IOS_TOOLBAR_LIGHT_RELOAD_DISABLED, YES)]; 112 IDR_IOS_TOOLBAR_LIGHT_RELOAD_DISABLED, YES)];
113 reloadButton.accessibilityLabel =
114 l10n_util::GetNSString(IDS_IOS_ACCNAME_RELOAD);
99 return reloadButton; 115 return reloadButton;
100 } 116 }
101 117
102 + (instancetype)stopToolbarButton { 118 + (instancetype)stopToolbarButton {
103 ToolbarButton* stopButton = [self 119 ToolbarButton* stopButton = [self
104 toolbarButtonWithImageForNormalState:NativeImage( 120 toolbarButtonWithImageForNormalState:NativeImage(
105 IDR_IOS_TOOLBAR_LIGHT_STOP) 121 IDR_IOS_TOOLBAR_LIGHT_STOP)
106 imageForHighlightedState: 122 imageForHighlightedState:
107 NativeImage(IDR_IOS_TOOLBAR_LIGHT_STOP_PRESSED) 123 NativeImage(IDR_IOS_TOOLBAR_LIGHT_STOP_PRESSED)
108 imageForDisabledState: 124 imageForDisabledState:
109 NativeImage(IDR_IOS_TOOLBAR_LIGHT_STOP_DISABLED)]; 125 NativeImage(IDR_IOS_TOOLBAR_LIGHT_STOP_DISABLED)];
126 stopButton.accessibilityLabel = l10n_util::GetNSString(IDS_IOS_ACCNAME_STOP);
110 return stopButton; 127 return stopButton;
111 } 128 }
112 129
113 + (instancetype)starToolbarButton { 130 + (instancetype)starToolbarButton {
114 ToolbarButton* starButton = 131 ToolbarButton* starButton =
115 [self toolbarButtonWithImageForNormalState:NativeImage( 132 [self toolbarButtonWithImageForNormalState:NativeImage(
116 IDR_IOS_TOOLBAR_LIGHT_STAR) 133 IDR_IOS_TOOLBAR_LIGHT_STAR)
117 imageForHighlightedState: 134 imageForHighlightedState:
118 NativeImage(IDR_IOS_TOOLBAR_LIGHT_STAR_PRESSED) 135 NativeImage(IDR_IOS_TOOLBAR_LIGHT_STAR_PRESSED)
119 imageForDisabledState:nil]; 136 imageForDisabledState:nil];
137 starButton.accessibilityLabel = l10n_util::GetNSString(IDS_TOOLTIP_STAR);
120 return starButton; 138 return starButton;
121 } 139 }
122 140
123 @end 141 @end
OLDNEW
« no previous file with comments | « ios/clean/chrome/browser/ui/toolbar/BUILD.gn ('k') | ios/showcase/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698