| Index: ios/web_view/shell/shell_view_controller.m
|
| diff --git a/ios/web_view/shell/shell_view_controller.m b/ios/web_view/shell/shell_view_controller.m
|
| index 89f19d98f5dc9c8ef589bcd1753751770befe42e..18a08c2f879316b1d6eac1f6663a9e28594d5064 100644
|
| --- a/ios/web_view/shell/shell_view_controller.m
|
| +++ b/ios/web_view/shell/shell_view_controller.m
|
| @@ -15,6 +15,10 @@
|
| #error "This file requires ARC support."
|
| #endif
|
|
|
| +// Externed accessibility identifier.
|
| +NSString* const kWebViewShellJavaScriptDialogTextFieldAccessibiltyIdentifier =
|
| + @"WebViewShellJavaScriptDialogTextFieldAccessibiltyIdentifier";
|
| +
|
| @interface ShellViewController ()<CWVUIDelegate,
|
| CWVWebViewDelegate,
|
| UITextFieldDelegate>
|
| @@ -216,6 +220,81 @@
|
| [self presentViewController:alert animated:YES completion:nil];
|
| }
|
|
|
| +- (void)webView:(CWVWebView*)webView
|
| + runJavaScriptAlertPanelWithMessage:(NSString*)message
|
| + pageURL:(NSURL*)URL
|
| + completionHandler:(void (^)(void))handler {
|
| + UIAlertController* alert =
|
| + [UIAlertController alertControllerWithTitle:nil
|
| + message:message
|
| + preferredStyle:UIAlertControllerStyleAlert];
|
| +
|
| + [alert addAction:[UIAlertAction actionWithTitle:@"Ok"
|
| + style:UIAlertActionStyleDefault
|
| + handler:^(UIAlertAction* action) {
|
| + handler();
|
| + }]];
|
| +
|
| + [self presentViewController:alert animated:YES completion:nil];
|
| +}
|
| +
|
| +- (void)webView:(CWVWebView*)webView
|
| + runJavaScriptConfirmPanelWithMessage:(NSString*)message
|
| + pageURL:(NSURL*)URL
|
| + completionHandler:(void (^)(BOOL))handler {
|
| + UIAlertController* alert =
|
| + [UIAlertController alertControllerWithTitle:nil
|
| + message:message
|
| + preferredStyle:UIAlertControllerStyleAlert];
|
| +
|
| + [alert addAction:[UIAlertAction actionWithTitle:@"Ok"
|
| + style:UIAlertActionStyleDefault
|
| + handler:^(UIAlertAction* action) {
|
| + handler(YES);
|
| + }]];
|
| + [alert addAction:[UIAlertAction actionWithTitle:@"Cancel"
|
| + style:UIAlertActionStyleCancel
|
| + handler:^(UIAlertAction* action) {
|
| + handler(NO);
|
| + }]];
|
| +
|
| + [self presentViewController:alert animated:YES completion:nil];
|
| +}
|
| +
|
| +- (void)webView:(CWVWebView*)webView
|
| + runJavaScriptTextInputPanelWithPrompt:(NSString*)prompt
|
| + defaultText:(NSString*)defaultText
|
| + pageURL:(NSURL*)URL
|
| + completionHandler:(void (^)(NSString*))handler {
|
| + UIAlertController* alert =
|
| + [UIAlertController alertControllerWithTitle:nil
|
| + message:prompt
|
| + preferredStyle:UIAlertControllerStyleAlert];
|
| +
|
| + [alert addTextFieldWithConfigurationHandler:^(UITextField* textField) {
|
| + textField.text = defaultText;
|
| + textField.accessibilityIdentifier =
|
| + kWebViewShellJavaScriptDialogTextFieldAccessibiltyIdentifier;
|
| + }];
|
| +
|
| + __weak UIAlertController* weakAlert = alert;
|
| + [alert addAction:[UIAlertAction
|
| + actionWithTitle:@"Ok"
|
| + style:UIAlertActionStyleDefault
|
| + handler:^(UIAlertAction* action) {
|
| + NSString* textInput =
|
| + weakAlert.textFields.firstObject.text;
|
| + handler(textInput);
|
| + }]];
|
| + [alert addAction:[UIAlertAction actionWithTitle:@"Cancel"
|
| + style:UIAlertActionStyleCancel
|
| + handler:^(UIAlertAction* action) {
|
| + handler(nil);
|
| + }]];
|
| +
|
| + [self presentViewController:alert animated:YES completion:nil];
|
| +}
|
| +
|
| #pragma mark CWVWebViewDelegate methods
|
|
|
| - (void)webView:(CWVWebView*)webView
|
|
|