| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef IOS_WEB_VIEW_INTERNAL_WEB_VIEW_JAVA_SCRIPT_DIALOG_PRESENTER_H_ |
| 6 #define IOS_WEB_VIEW_INTERNAL_WEB_VIEW_JAVA_SCRIPT_DIALOG_PRESENTER_H_ |
| 7 |
| 8 #import "base/ios/weak_nsobject.h" |
| 9 #import "ios/web/public/java_script_dialog_presenter.h" |
| 10 |
| 11 @class CWVWebView; |
| 12 @protocol CWVUIDelegate; |
| 13 |
| 14 namespace ios_web_view { |
| 15 |
| 16 // WebView implementation of JavaScriptDialogPresenter. Passes JavaScript alert |
| 17 // handling to |ui_delegate_|. |
| 18 class WebViewJavaScriptDialogPresenter : public web::JavaScriptDialogPresenter { |
| 19 public: |
| 20 WebViewJavaScriptDialogPresenter(CWVWebView* web_view, |
| 21 id<CWVUIDelegate> ui_delegate); |
| 22 ~WebViewJavaScriptDialogPresenter(); |
| 23 |
| 24 void SetUIDelegate(id<CWVUIDelegate> ui_delegate); |
| 25 |
| 26 // web::JavaScriptDialogPresenter overrides: |
| 27 void RunJavaScriptDialog(web::WebState* web_state, |
| 28 const GURL& origin_url, |
| 29 web::JavaScriptDialogType dialog_type, |
| 30 NSString* message_text, |
| 31 NSString* default_prompt_text, |
| 32 const web::DialogClosedCallback& callback) override; |
| 33 void CancelDialogs(web::WebState* web_state) override; |
| 34 |
| 35 private: |
| 36 // Displays JavaScript alert. |
| 37 void HandleJavaScriptAlert(const GURL& origin_url, |
| 38 NSString* message_text, |
| 39 const web::DialogClosedCallback& callback); |
| 40 |
| 41 // Displays JavaScript confirm dialog. |
| 42 void HandleJavaScriptConfirmDialog(const GURL& origin_url, |
| 43 NSString* message_text, |
| 44 const web::DialogClosedCallback& callback); |
| 45 |
| 46 // Displays JavaScript text prompt. |
| 47 void HandleJavaScriptTextPrompt(const GURL& origin_url, |
| 48 NSString* message_text, |
| 49 NSString* default_prompt_text, |
| 50 const web::DialogClosedCallback& callback); |
| 51 |
| 52 // The underlying delegate handling the dialog UI. |
| 53 base::WeakNSProtocol<id<CWVUIDelegate>> ui_delegate_; |
| 54 // The web view which originated the dialogs. |
| 55 base::WeakNSObject<CWVWebView> web_view_; |
| 56 |
| 57 DISALLOW_COPY_AND_ASSIGN(WebViewJavaScriptDialogPresenter); |
| 58 }; |
| 59 |
| 60 } // namespace ios_web_view |
| 61 |
| 62 #endif // IOS_WEB_VIEW_INTERNAL_WEB_VIEW_JAVA_SCRIPT_DIALOG_PRESENTER_H_ |
| OLD | NEW |