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

Side by Side Diff: ios/clean/chrome/browser/ui/dialogs/java_script_dialogs/web_java_script_dialog_presenter.mm

Issue 2928723002: [iOS Clean] Added JavaScript dialog support.
Patch Set: rebased, subclassed DialogMediator 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 unified diff | Download patch
OLDNEW
(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 #import "ios/clean/chrome/browser/ui/dialogs/java_script_dialogs/web_java_script _dialog_presenter.h"
6
7 #import "ios/clean/chrome/browser/ui/dialogs/java_script_dialogs/java_script_dia log_coordinator.h"
8 #import "ios/clean/chrome/browser/ui/dialogs/java_script_dialogs/java_script_dia log_state.h"
9 #import "ios/clean/chrome/browser/ui/overlays/overlay_queue.h"
10
11 #if !defined(__has_feature) || !__has_feature(objc_arc)
12 #error "This file requires ARC support."
13 #endif
14
15 DEFINE_WEB_STATE_USER_DATA_KEY(WebJavaScriptDialogPresenter);
16
17 WebJavaScriptDialogPresenter::WebJavaScriptDialogPresenter(
18 web::WebState* web_state)
19 : web_state_(web_state) {
20 DCHECK(web_state);
21 }
22
23 WebJavaScriptDialogPresenter::~WebJavaScriptDialogPresenter() {}
24
25 void WebJavaScriptDialogPresenter::RunJavaScriptDialog(
26 web::WebState* web_state,
27 const GURL& origin_url,
28 web::JavaScriptDialogType dialog_type,
29 NSString* message_text,
30 NSString* default_prompt_text,
31 const web::DialogClosedCallback& callback) {
32 // This presenter should only attempt to present dialogs from its associated
33 // WebState.
34 DCHECK_EQ(web_state_, web_state);
35 // Create a new coordinator and add it to the overlay queue.
36 JavaScriptDialogState* state =
37 [JavaScriptDialogState stateWithWebState:web_state
38 type:dialog_type
39 originURL:origin_url
40 message:message_text
41 defaultPromptText:default_prompt_text
42 callback:callback];
43 JavaScriptDialogCoordinator* dialog_coordinator =
44 [[JavaScriptDialogCoordinator alloc] initWithState:state];
45 OverlayQueue::FromWebState(web_state_)->AddOverlay(dialog_coordinator);
46 }
47
48 void WebJavaScriptDialogPresenter::CancelDialogs(web::WebState* web_state) {
49 // This presenter should only attempt to block dialogs from its associated
50 // WebState.
51 DCHECK_EQ(web_state_, web_state);
52 OverlayQueue::FromWebState(web_state_)->CancelOverlays();
53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698