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

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

Issue 2936643003: Allow cancelling the currently-presented dialog. (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/chrome/browser/ui/dialogs/dialog_presenter.h" 5 #import "ios/chrome/browser/ui/dialogs/dialog_presenter.h"
6 6
7 #include <deque> 7 #include <deque>
8 #include <map> 8 #include <map>
9 9
10 #import "base/ios/block_types.h" 10 #import "base/ios/block_types.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 addTextFieldWithConfigurationHandler:^(UITextField* textField) { 305 addTextFieldWithConfigurationHandler:^(UITextField* textField) {
306 textField.placeholder = l10n_util::GetNSString( 306 textField.placeholder = l10n_util::GetNSString(
307 IDS_IOS_HTTP_LOGIN_DIALOG_PASSWORD_PLACEHOLDER); 307 IDS_IOS_HTTP_LOGIN_DIALOG_PASSWORD_PLACEHOLDER);
308 textField.secureTextEntry = YES; 308 textField.secureTextEntry = YES;
309 }]; 309 }];
310 310
311 [self addDialogCoordinator:alertCoordinator forWebState:webState]; 311 [self addDialogCoordinator:alertCoordinator forWebState:webState];
312 } 312 }
313 313
314 - (void)cancelDialogForWebState:(web::WebState*)webState { 314 - (void)cancelDialogForWebState:(web::WebState*)webState {
315 DCHECK_NE(webState, self.presentedDialogWebState); 315 BOOL cancelingPresentedDialog = webState == self.presentedDialogWebState;
316 AlertCoordinator* dialogToCancel = _dialogCoordinatorsForWebStates[webState]; 316 AlertCoordinator* dialogToCancel =
317 if (dialogToCancel) { 317 cancelingPresentedDialog ? self.presentedDialogCoordinator
318 : _dialogCoordinatorsForWebStates[webState];
319 DCHECK(!cancelingPresentedDialog || dialogToCancel);
320 [dialogToCancel executeCancelHandler];
321 [dialogToCancel stop];
322
323 if (cancelingPresentedDialog) {
rohitrao (ping after 24h) 2017/06/12 23:43:50 Should we DCHECK(_dialogCoordinatorsForWebStates[w
kkhorimoto 2017/06/13 00:10:13 Done.
324 // Simulate a button tap to trigger showing the next dialog.
rohitrao (ping after 24h) 2017/06/12 23:43:50 Can a single WebState have multiple dialogs queued
kkhorimoto 2017/06/13 00:10:13 This class was built on the assumption that it was
325 [self buttonWasTappedForCoordinator:dialogToCancel];
rohitrao (ping after 24h) 2017/06/12 23:43:50 It feels a little weird to call a function with th
kkhorimoto 2017/06/13 00:10:13 I renamed it to |-dialogCoordinatorWasStopped:|, w
326 } else if (dialogToCancel) {
327 // Clean up queued state.
318 auto it = 328 auto it =
319 std::find(_queuedWebStates.begin(), _queuedWebStates.end(), webState); 329 std::find(_queuedWebStates.begin(), _queuedWebStates.end(), webState);
320 DCHECK(it != _queuedWebStates.end()); 330 DCHECK(it != _queuedWebStates.end());
321 _queuedWebStates.erase(it); 331 _queuedWebStates.erase(it);
322 [dialogToCancel executeCancelHandler];
323 [dialogToCancel stop];
324 _dialogCoordinatorsForWebStates.erase(webState); 332 _dialogCoordinatorsForWebStates.erase(webState);
325 } 333 }
326 } 334 }
327 335
328 - (void)cancelAllDialogs { 336 - (void)cancelAllDialogs {
329 [self.presentedDialogCoordinator executeCancelHandler]; 337 [self.presentedDialogCoordinator executeCancelHandler];
330 [self.presentedDialogCoordinator stop]; 338 [self.presentedDialogCoordinator stop];
331 self.presentedDialogCoordinator = nil; 339 self.presentedDialogCoordinator = nil;
332 self.presentedDialogWebState = nil; 340 self.presentedDialogWebState = nil;
333 while (!_queuedWebStates.empty()) { 341 while (!_queuedWebStates.empty()) {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 style:UIAlertActionStyleDestructive]; 507 style:UIAlertActionStyleDestructive];
500 [confirmationCoordinator addItemWithTitle:l10n_util::GetNSString(IDS_CANCEL) 508 [confirmationCoordinator addItemWithTitle:l10n_util::GetNSString(IDS_CANCEL)
501 action:cancelHandler 509 action:cancelHandler
502 style:UIAlertActionStyleCancel]; 510 style:UIAlertActionStyleCancel];
503 [weakSelf setBlockingConfirmationCoordinator:confirmationCoordinator]; 511 [weakSelf setBlockingConfirmationCoordinator:confirmationCoordinator];
504 [[weakSelf blockingConfirmationCoordinator] start]; 512 [[weakSelf blockingConfirmationCoordinator] start];
505 } copy]; 513 } copy];
506 } 514 }
507 515
508 @end 516 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698