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

Side by Side Diff: ios/web_view/shell/shell_view_controller.m

Issue 2736243003: Add ios_web_view_shell_egtests target and accessibility labels to shell. (Closed)
Patch Set: Created 3 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/web_view/shell/shell_view_controller.h" 5 #import "ios/web_view/shell/shell_view_controller.h"
6 6
7 #import <MobileCoreServices/MobileCoreServices.h> 7 #import <MobileCoreServices/MobileCoreServices.h>
8 8
9 #import "ios/web_view/public/cwv.h" 9 #import "ios/web_view/public/cwv.h"
10 #import "ios/web_view/public/cwv_html_element.h" 10 #import "ios/web_view/public/cwv_html_element.h"
11 #import "ios/web_view/public/cwv_web_view.h" 11 #import "ios/web_view/public/cwv_web_view.h"
12 #import "ios/web_view/shell/translate_controller.h" 12 #import "ios/web_view/shell/translate_controller.h"
13 13
14 #if !defined(__has_feature) || !__has_feature(objc_arc) 14 #if !defined(__has_feature) || !__has_feature(objc_arc)
15 #error "This file requires ARC support." 15 #error "This file requires ARC support."
16 #endif 16 #endif
17 17
18 // Externed accessibility identifier. 18 // Externed accessibility identifier.
19 NSString* const kWebViewShellBackButtonAccessibilityLabel = @"Back";
20 NSString* const kWebViewShellForwardButtonAccessibilityLabel = @"Forward";
21 NSString* const kWebViewShellAddressFieldAccessibilityLabel = @"Address field";
19 NSString* const kWebViewShellJavaScriptDialogTextFieldAccessibiltyIdentifier = 22 NSString* const kWebViewShellJavaScriptDialogTextFieldAccessibiltyIdentifier =
20 @"WebViewShellJavaScriptDialogTextFieldAccessibiltyIdentifier"; 23 @"WebViewShellJavaScriptDialogTextFieldAccessibiltyIdentifier";
21 24
22 @interface ShellViewController ()<CWVNavigationDelegate, 25 @interface ShellViewController ()<CWVNavigationDelegate,
23 CWVUIDelegate, 26 CWVUIDelegate,
24 UITextFieldDelegate> 27 UITextFieldDelegate>
25 // Container for |webView|. 28 // Container for |webView|.
26 @property(nonatomic, strong) UIView* containerView; 29 @property(nonatomic, strong) UIView* containerView;
27 // Text field used for navigating to URLs. 30 // Text field used for navigating to URLs.
28 @property(nonatomic, strong) UITextField* field; 31 @property(nonatomic, strong) UITextField* field;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 kButtonCount * kButtonSize - 10, 84 kButtonCount * kButtonSize - 10,
82 31)]; 85 31)];
83 [_field setDelegate:self]; 86 [_field setDelegate:self];
84 [_field setBackground:[[UIImage imageNamed:@"textfield_background"] 87 [_field setBackground:[[UIImage imageNamed:@"textfield_background"]
85 resizableImageWithCapInsets:UIEdgeInsetsMake( 88 resizableImageWithCapInsets:UIEdgeInsetsMake(
86 12, 12, 12, 12)]]; 89 12, 12, 12, 12)]];
87 [_field setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; 90 [_field setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
88 [_field setKeyboardType:UIKeyboardTypeWebSearch]; 91 [_field setKeyboardType:UIKeyboardTypeWebSearch];
89 [_field setAutocorrectionType:UITextAutocorrectionTypeNo]; 92 [_field setAutocorrectionType:UITextAutocorrectionTypeNo];
90 [_field setClearButtonMode:UITextFieldViewModeWhileEditing]; 93 [_field setClearButtonMode:UITextFieldViewModeWhileEditing];
94 [_field setAccessibilityLabel:kWebViewShellAddressFieldAccessibilityLabel];
91 95
92 // Set up the toolbar buttons. 96 // Set up the toolbar buttons.
93 // Back. 97 // Back.
94 UIButton* back = [UIButton buttonWithType:UIButtonTypeCustom]; 98 UIButton* back = [UIButton buttonWithType:UIButtonTypeCustom];
95 [back setImage:[UIImage imageNamed:@"toolbar_back"] 99 [back setImage:[UIImage imageNamed:@"toolbar_back"]
96 forState:UIControlStateNormal]; 100 forState:UIControlStateNormal];
97 [back setFrame:CGRectMake(0, 0, kButtonSize, kButtonSize)]; 101 [back setFrame:CGRectMake(0, 0, kButtonSize, kButtonSize)];
98 UIEdgeInsets insets = UIEdgeInsetsMake(5, 5, 4, 4); 102 UIEdgeInsets insets = UIEdgeInsetsMake(5, 5, 4, 4);
99 [back setImageEdgeInsets:insets]; 103 [back setImageEdgeInsets:insets];
100 [back setAutoresizingMask:UIViewAutoresizingFlexibleRightMargin]; 104 [back setAutoresizingMask:UIViewAutoresizingFlexibleRightMargin];
101 [back addTarget:self 105 [back addTarget:self
102 action:@selector(back) 106 action:@selector(back)
103 forControlEvents:UIControlEventTouchUpInside]; 107 forControlEvents:UIControlEventTouchUpInside];
108 [back setAccessibilityLabel:kWebViewShellBackButtonAccessibilityLabel];
104 109
105 // Forward. 110 // Forward.
106 UIButton* forward = [UIButton buttonWithType:UIButtonTypeCustom]; 111 UIButton* forward = [UIButton buttonWithType:UIButtonTypeCustom];
107 [forward setImage:[UIImage imageNamed:@"toolbar_forward"] 112 [forward setImage:[UIImage imageNamed:@"toolbar_forward"]
108 forState:UIControlStateNormal]; 113 forState:UIControlStateNormal];
109 [forward setFrame:CGRectMake(kButtonSize, 0, kButtonSize, kButtonSize)]; 114 [forward setFrame:CGRectMake(kButtonSize, 0, kButtonSize, kButtonSize)];
110 [forward setImageEdgeInsets:insets]; 115 [forward setImageEdgeInsets:insets];
111 [forward setAutoresizingMask:UIViewAutoresizingFlexibleRightMargin]; 116 [forward setAutoresizingMask:UIViewAutoresizingFlexibleRightMargin];
112 [forward addTarget:self 117 [forward addTarget:self
113 action:@selector(forward) 118 action:@selector(forward)
114 forControlEvents:UIControlEventTouchUpInside]; 119 forControlEvents:UIControlEventTouchUpInside];
120 [forward setAccessibilityLabel:kWebViewShellForwardButtonAccessibilityLabel];
115 121
116 // Stop. 122 // Stop.
117 UIButton* stop = [UIButton buttonWithType:UIButtonTypeCustom]; 123 UIButton* stop = [UIButton buttonWithType:UIButtonTypeCustom];
118 [stop setImage:[UIImage imageNamed:@"toolbar_stop"] 124 [stop setImage:[UIImage imageNamed:@"toolbar_stop"]
119 forState:UIControlStateNormal]; 125 forState:UIControlStateNormal];
120 [stop setFrame:CGRectMake(2 * kButtonSize, 0, kButtonSize, kButtonSize)]; 126 [stop setFrame:CGRectMake(2 * kButtonSize, 0, kButtonSize, kButtonSize)];
121 [stop setImageEdgeInsets:insets]; 127 [stop setImageEdgeInsets:insets];
122 [stop setAutoresizingMask:UIViewAutoresizingFlexibleRightMargin]; 128 [stop setAutoresizingMask:UIViewAutoresizingFlexibleRightMargin];
123 [stop addTarget:self 129 [stop addTarget:self
124 action:@selector(stopLoading) 130 action:@selector(stopLoading)
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 // TODO(crbug.com/679895): Add some visual indication that the page load has 332 // TODO(crbug.com/679895): Add some visual indication that the page load has
327 // finished. 333 // finished.
328 [self updateToolbar]; 334 [self updateToolbar];
329 } 335 }
330 336
331 - (void)webViewWebContentProcessDidTerminate:(CWVWebView*)webView { 337 - (void)webViewWebContentProcessDidTerminate:(CWVWebView*)webView {
332 NSLog(@"webViewWebContentProcessDidTerminate"); 338 NSLog(@"webViewWebContentProcessDidTerminate");
333 } 339 }
334 340
335 @end 341 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698