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

Unified Diff: ios/clean/chrome/browser/ui/dialogs/java_script_dialogs/java_script_dialog_overlay_presenter.h

Issue 2928723002: [iOS Clean] Added JavaScript dialog support.
Patch Set: rebase & Mark's comments Created 3 years, 6 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/clean/chrome/browser/ui/dialogs/java_script_dialogs/java_script_dialog_overlay_presenter.h
diff --git a/ios/clean/chrome/browser/ui/dialogs/java_script_dialogs/java_script_dialog_overlay_presenter.h b/ios/clean/chrome/browser/ui/dialogs/java_script_dialogs/java_script_dialog_overlay_presenter.h
new file mode 100644
index 0000000000000000000000000000000000000000..bed68d631ca54ef80c8216d62e245f4ef44096d4
--- /dev/null
+++ b/ios/clean/chrome/browser/ui/dialogs/java_script_dialogs/java_script_dialog_overlay_presenter.h
@@ -0,0 +1,51 @@
+// 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_CLEAN_CHROME_BROWSER_UI_DIALOGS_JAVA_SCRIPT_WEB_JAVA_SCRIPT_DIALOG_PRESENTER_H_
+#define IOS_CLEAN_CHROME_BROWSER_UI_DIALOGS_JAVA_SCRIPT_WEB_JAVA_SCRIPT_DIALOG_PRESENTER_H_
+
+#import <Foundation/Foundation.h>
+
+#include "ios/web/public/java_script_dialog_presenter.h"
+#import "ios/web/public/web_state/web_state_user_data.h"
+
+class OverlayService;
+
+// A concrete subclass of web::JavaScriptDialogPresenter that is associated with
+// a WebState via its UserData. It uses OverlayService to present dialogs.
+class JavaScriptDialogOverlayPresenter
+ : public web::JavaScriptDialogPresenter,
+ public web::WebStateUserData<JavaScriptDialogOverlayPresenter> {
+ public:
+ // Factory method for a presenter that uses |overlay_service| to show dialogs.
+ static void CreateForWebState(web::WebState* web_state,
+ OverlayService* overlay_service);
+
+ ~JavaScriptDialogOverlayPresenter() override;
+
+ private:
+ friend class web::WebStateUserData<JavaScriptDialogOverlayPresenter>;
+ // The WebState with which this presenter is associated.
+ web::WebState* web_state_;
+ // The OverlayService to use for the dialogs.
+ OverlayService* overlay_service_;
+
+ // Private constructor. New instances should be created via
+ // CreateForWebState() and accessed via FromWebState().
+ explicit JavaScriptDialogOverlayPresenter(web::WebState* web_state,
+ OverlayService* overlay_service);
+
+ // JavaScriptDialogPresenter:
+ 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;
+
+ DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogOverlayPresenter);
+};
+
+#endif // IOS_CLEAN_CHROME_BROWSER_UI_DIALOGS_JAVA_SCRIPT_WEB_JAVA_SCRIPT_DIALOG_PRESENTER_H_

Powered by Google App Engine
This is Rietveld 408576698