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
3 // found in the LICENSE file.
5 #ifndef IOS_WEB_PUBLIC_WEB_STATE_CRW_WEB_USER_INTERFACE_DELEGATE_H_
6 #define IOS_WEB_PUBLIC_WEB_STATE_CRW_WEB_USER_INTERFACE_DELEGATE_H_
8 #include <Foundation/Foundation.h>
10 @
class CRWWebController
;
13 @protocol CRWWebUserInterfaceDelegate
<NSObject
>
16 // The JavaScript panel selectors below are only called by the web controller
17 // for builds with WKWebView enabled.
19 // Displays a JavaScript alert with an OK button, showing the provided message.
20 // |completionHandler| is called afer the OK button on the alert is tapped. If
21 // this selector isn't implemented, the completion handler provided by the web
22 // view will be called without any UI displayed.
23 - (void)webController
:(CRWWebController
*)webController
24 runJavaScriptAlertPanelWithMessage
:(NSString
*)message
25 requestURL
:(const GURL
&)requestURL
26 completionHandler
:(void (^)(void))completionHandler
;
28 // Displays a JavaScript confirm alert with an OK and Cancel button, showing the
29 // provided message. |completionHandler| is called after a button is pressed,
30 // with |isConfirmed| indicating whether OK was pressed. If this selector isn't
31 // implemented, the competion handler provided by the web view will be called
32 // with |isConfirmed| = NO.
33 - (void)webController
:(CRWWebController
*)webController
34 runJavaScriptConfirmPanelWithMessage
:(NSString
*)message
35 requestURL
:(const GURL
&)requestURL
37 (void (^)(BOOL isConfirmed
))completionHandler
;
39 // Displays a JavaScript input alert with an OK and Cancel button, showing the
40 // provided message and placeholder text. |completionHandler| is called after a
41 // button is pressed. If the OK button is pressed, |input| contains the user
42 // text. If the cancel but is pressed, |input| will be nil. If this selector
43 // isn't implemented, the completion handler provided by the web view will be
44 // called with |input| = nil.
45 - (void)webController
:(CRWWebController
*)webController
46 runJavaScriptTextInputPanelWithPrompt
:(NSString
*)message
47 placeholderText
:(NSString
*)placeholderText
48 requestURL
:(const GURL
&)requestURL
50 (void (^)(NSString
* input
))completionHandler
;
52 // Displays a context menu for DOM element. |point| and |view| represent the
53 // location and UIView where the context menu was triggered by a user gesture.
54 // |menuInfo| keys are defined in crw_context_menu_provider.h.
55 // TODO(eugenebut): create DOMElement class (tag + attributes) and pass
56 // it and referrer as separate arguments instead of |menuInfo|.
57 - (void)webController
:(CRWWebController
*)webController
58 runContextMenu
:(NSDictionary
*)menuInfo
59 atPoint
:(CGPoint
)point
64 #endif // IOS_WEB_PUBLIC_WEB_STATE_CRW_WEB_USER_INTERFACE_DELEGATE_H_