Chromium Code Reviews| Index: ios/chrome/browser/ui/alert_coordinator/modal_alert.mm |
| diff --git a/ios/chrome/browser/ui/alert_coordinator/modal_alert.mm b/ios/chrome/browser/ui/alert_coordinator/modal_alert.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..530c89b1e3b71c588b777042246941a9f25c44db |
| --- /dev/null |
| +++ b/ios/chrome/browser/ui/alert_coordinator/modal_alert.mm |
| @@ -0,0 +1,60 @@ |
| +// Copyright 2016 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. |
| + |
| +#import "ios/chrome/browser/ui/alert_coordinator/modal_alert.h" |
| + |
| +#import "base/mac/scoped_nsobject.h" |
| +#include "ui/base/l10n/l10n_util.h" |
| +#include "ui/strings/grit/ui_strings.h" |
| + |
| +@interface ModalAlert () { |
| + // Stores the title of the alert. |
| + base::scoped_nsobject<NSString> _title; |
| +} |
| + |
| +@end |
| + |
| +@implementation ModalAlert |
| + |
| +- (instancetype)initWithTitle:(NSString*)title { |
| + self = [super init]; |
| + if (self) { |
| + _title.reset([title copy]); |
| + } |
| + return self; |
| +} |
| + |
| +#pragma mark - Private Methods |
|
lpromero
2016/07/18 12:55:31
s/Private/AlertCoordinatorDelegate
|
| + |
| +- (BOOL)alertCoordinatorShouldStart:(AlertCoordinator*)alertCoordinator { |
| + // Check that the view is still visible on screen, otherwise just return and |
| + // don't show the alert. |
| + if (![alertCoordinator.baseViewController.view window] && |
|
marq (ping after 24h)
2016/07/18 13:02:41
The coordinator shouldn't need to hand off this ch
|
| + ![alertCoordinator.baseViewController.view |
| + isKindOfClass:[UIWindow class]]) |
| + return NO; |
| + |
| + if ([alertCoordinator actionsCount] == 0) { |
| + [alertCoordinator addItemWithTitle:l10n_util::GetNSString(IDS_APP_OK) |
|
lpromero
2016/07/18 12:11:36
Why here and not when creating the UIAlertControll
gambard
2016/07/18 12:40:20
This code adds an OK button only if there is no ot
lpromero
2016/07/18 12:55:31
I misunderstood the flow with alertCoordinatorUIAl
marq (ping after 24h)
2016/07/18 13:02:41
I don't like that UI configuration is being done h
lpromero
2016/07/18 13:25:19
The problem is that there are 2 cases we are handl
marq (ping after 24h)
2016/07/18 13:37:14
Yes, but coordinators are allowed to know things a
|
| + action:nil |
| + style:UIAlertActionStyleDefault]; |
| + } |
| + return YES; |
| +} |
| + |
| +- (UIAlertController*)alertCoordinatorUIAlertController: |
| + (AlertCoordinator*)alertCoordinator { |
| + UIAlertController* alert = |
| + [UIAlertController alertControllerWithTitle:_title |
| + message:alertCoordinator.message |
| + preferredStyle:UIAlertControllerStyleAlert]; |
| + return alert; |
| +} |
| + |
| +- (BOOL)alertCoordinatorShouldAddCancelButton: |
|
lpromero
2016/07/18 12:11:36
Reading the previous methods implementations, shou
gambard
2016/07/18 12:40:20
No, the OK button is only here if there is no othe
lpromero
2016/07/18 12:55:31
Acknowledged.
|
| + (AlertCoordinator*)alertCoordinator { |
| + return NO; |
| +} |
| + |
| +@end |