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

Side by Side Diff: ios/chrome/browser/ui/dialogs/dialog_presenter.h

Issue 2588713002: Upstream Chrome on iOS source code [4/11]. (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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_CHROME_BROWSER_UI_DIALOGS_DIALOG_PRESENTER_H_
6 #define IOS_CHROME_BROWSER_UI_DIALOGS_DIALOG_PRESENTER_H_
7
8 #import <UIKit/UIKit.h>
9
10 #import "base/ios/block_types.h"
11
12 @protocol DialogPresenterDelegate;
13 class GURL;
14 @class AlertCoordinator;
15
16 // Accessibility identifier added to the text field of JavaScript prompts.
17 extern NSString* const kJavaScriptDialogTextFieldAccessibiltyIdentifier;
18
19 namespace web {
20 class WebState;
21 }
22
23 // Handles the queued display of modal dialogs.
24 @interface DialogPresenter : NSObject
25
26 // Whether the DialogPresenter should attempt to show dialogs. When |active| is
27 // NO, dialogs will be queued and displayed when the DialogPresenter is
28 // activated.
29 @property(nonatomic, assign, getter=isActive) BOOL active;
30
31 // Dialogs will be presented from |viewController|.
32 - (instancetype)initWithDelegate:(id<DialogPresenterDelegate>)delegate
33 presentingViewController:(UIViewController*)viewController
34 NS_DESIGNATED_INITIALIZER;
35 - (instancetype)init NS_UNAVAILABLE;
36
37 // Methods to show JavaScriptDialogs of each JavaScriptAlertType. If a dialog
38 // is already being presented, these functions will enqueue a new dialog to be
39 // shown when the visible dialog is dismissed. |context| will be retained until
40 // its associated dialog is dismissed or |-cancelDialogForContext:| is called.
41 - (void)runJavaScriptAlertPanelWithMessage:(NSString*)message
42 requestURL:(const GURL&)requestURL
43 webState:(web::WebState*)webState
44 completionHandler:(void (^)(void))completionHandler;
45 - (void)runJavaScriptConfirmPanelWithMessage:(NSString*)message
46 requestURL:(const GURL&)requestURL
47 webState:(web::WebState*)webState
48 completionHandler:
49 (void (^)(BOOL isConfirmed))completionHandler;
50 - (void)runJavaScriptTextInputPanelWithPrompt:(NSString*)message
51 defaultText:(NSString*)defaultText
52 requestURL:(const GURL&)requestURL
53 webState:(web::WebState*)webState
54 completionHandler:
55 (void (^)(NSString* input))completionHandler;
56
57 // Displays an HTTP authentication dialog, which has 2 text fields
58 // (username and password), Login and Cancel button. If Login was tapped,
59 // |completionHandler| is called with valid strings which represent username
60 // and password inputs. If cancel is tapped then |completionHandler| is
61 // called with nil |user| and nil |password|. Username will be pre-populated
62 // from provided |credential|.
63 - (void)runAuthDialogForProtectionSpace:(NSURLProtectionSpace*)protectionSpace
64 proposedCredential:(NSURLCredential*)credential
65 webState:(web::WebState*)webState
66 completionHandler:
67 (void (^)(NSString* user, NSString* password))handler;
68
69 // Cancels the display of the dialog associated with |context|.
70 - (void)cancelDialogForWebState:(web::WebState*)webState;
71
72 // Dismisses the currently presented dialog and cancels all queued dialogs.
73 - (void)cancelAllDialogs;
74
75 // Tries to present an alert if needed and possible. Called by the view
76 // controller which will present the alert to notify that it has dismissed a
77 // view controller.
78 - (void)tryToPresent;
79
80 // Create an title for the alert base on the URL.
81 + (NSString*)localizedTitleForJavaScriptAlertFromPage:(const GURL&)pageURL;
82
83 @end
84
85 @interface DialogPresenter (ExposedForTesting)
86 // The dialog currently being shown.
87 @property(nonatomic, readonly) AlertCoordinator* presentedDialogCoordinator;
88
89 // Called when a button in |dialog| is tapped.
90 - (void)buttonWasTappedForCoordinator:(AlertCoordinator*)coordinator;
91
92 @end
93
94 // Delegate protocol for DialogPresenter.
95 @protocol DialogPresenterDelegate<NSObject>
96
97 // Called by |presenter| before showing the queued modal dialog associated with
98 // |context|.
99 - (void)dialogPresenter:(DialogPresenter*)presenter
100 willShowDialogForWebState:(web::WebState*)webState;
101
102 // Whether the delegate is presenting another View Controller.
103 @property(nonatomic, assign) BOOL presenting;
104
105 @end
106
107 #endif // IOS_CHROME_BROWSER_UI_DIALOGS_DIALOG_PRESENTER_H_
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/contextual_search/window_gesture_observer.mm ('k') | ios/chrome/browser/ui/dialogs/dialog_presenter.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698