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

Unified Diff: ios/web_view/internal/web_view_java_script_dialog_presenter.h

Issue 2715343002: Add JavaScript prompts support to CWVUIDelegate. (Closed)
Patch Set: Respond to comments. Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: ios/web_view/internal/web_view_java_script_dialog_presenter.h
diff --git a/ios/web_view/internal/web_view_java_script_dialog_presenter.h b/ios/web_view/internal/web_view_java_script_dialog_presenter.h
new file mode 100644
index 0000000000000000000000000000000000000000..1bc856b6a7bb947a8dc931d722222f270320c2a8
--- /dev/null
+++ b/ios/web_view/internal/web_view_java_script_dialog_presenter.h
@@ -0,0 +1,62 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_WEB_VIEW_INTERNAL_WEB_VIEW_JAVA_SCRIPT_DIALOG_PRESENTER_H_
+#define IOS_WEB_VIEW_INTERNAL_WEB_VIEW_JAVA_SCRIPT_DIALOG_PRESENTER_H_
+
+#import "base/ios/weak_nsobject.h"
+#import "ios/web/public/java_script_dialog_presenter.h"
+
+@class CWVWebView;
+@protocol CWVUIDelegate;
+
+namespace ios_web_view {
+
+// WebView implementation of JavaScriptDialogPresenter. Passes JavaScript alert
+// handling to |ui_delegate_|.
+class WebViewJavaScriptDialogPresenter : public web::JavaScriptDialogPresenter {
+ public:
+ WebViewJavaScriptDialogPresenter(CWVWebView* web_view,
+ id<CWVUIDelegate> ui_delegate);
+ ~WebViewJavaScriptDialogPresenter();
+
+ void SetUIDelegate(id<CWVUIDelegate> ui_delegate);
+
+ // web::JavaScriptDialogPresenter overrides:
+ void RunJavaScriptDialog(web::WebState* web_state,
+ const GURL& origin_url,
+ web::JavaScriptDialogType dialog_type,
+ NSString* message_text,
+ NSString* default_prompt_text,
+ const web::DialogClosedCallback& callback) override;
+ void CancelDialogs(web::WebState* web_state) override;
+
+ private:
+ // Displays JavaScript alert.
+ void HandleJavaScriptAlert(const GURL& origin_url,
+ NSString* message_text,
+ const web::DialogClosedCallback& callback);
+
+ // Displays JavaScript confirm dialog.
+ void HandleJavaScriptConfirmDialog(const GURL& origin_url,
+ NSString* message_text,
+ const web::DialogClosedCallback& callback);
+
+ // Displays JavaScript text prompt.
+ void HandleJavaScriptTextPrompt(const GURL& origin_url,
+ NSString* message_text,
+ NSString* default_prompt_text,
+ const web::DialogClosedCallback& callback);
+
+ // The underlying delegate handling the dialog UI.
+ base::WeakNSProtocol<id<CWVUIDelegate>> ui_delegate_;
+ // The web view which originated the dialogs.
+ base::WeakNSObject<CWVWebView> web_view_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebViewJavaScriptDialogPresenter);
+};
+
+} // namespace ios_web_view
+
+#endif // IOS_WEB_VIEW_INTERNAL_WEB_VIEW_JAVA_SCRIPT_DIALOG_PRESENTER_H_
« no previous file with comments | « ios/web_view/internal/cwv_web_view.mm ('k') | ios/web_view/internal/web_view_java_script_dialog_presenter.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698