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

Side by Side Diff: ios/chrome/browser/passwords/update_password_infobar_controller.mm

Issue 2127793002: Retain coordinator and update label in UpdatePasswordInfoBarController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Retain coordinator and update label in UpdatePasswordInfoBarController Created 4 years, 5 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/passwords/update_password_infobar_controller.h" 5 #import "ios/chrome/browser/passwords/update_password_infobar_controller.h"
6 6
7 #import "base/mac/objc_property_releaser.h"
7 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
8 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
9 #include "ios/chrome/browser/infobars/confirm_infobar_controller+protected.h" 10 #include "ios/chrome/browser/infobars/confirm_infobar_controller+protected.h"
10 #include "ios/chrome/browser/passwords/ios_chrome_update_password_infobar_delega te.h" 11 #include "ios/chrome/browser/passwords/ios_chrome_update_password_infobar_delega te.h"
11 #import "ios/chrome/browser/ui/elements/selector_coordinator.h" 12 #import "ios/chrome/browser/ui/elements/selector_coordinator.h"
12 #import "ios/public/provider/chrome/browser/ui/infobar_view_protocol.h" 13 #import "ios/public/provider/chrome/browser/ui/infobar_view_protocol.h"
13 14
14 namespace { 15 namespace {
15 // Tag for the account link in the info bar message. Set to 10 to avoid conflict 16 // Tag for the account link in the info bar message. Set to 10 to avoid conflict
16 // with tags from superclass ConfirmInfoBarController, which uses tags 1-4. 17 // with tags from superclass ConfirmInfoBarController, which uses tags 1-4.
17 NSUInteger kAccountTag = 10; 18 NSUInteger kAccountTag = 10;
18 } 19 }
19 20
20 @interface UpdatePasswordInfoBarController ()<SelectorCoordinatorDelegate> { 21 @interface UpdatePasswordInfoBarController ()<SelectorCoordinatorDelegate> {
22 base::mac::ObjCPropertyReleaser
23 _propertyReleaser_UpdatePasswordInfoBarController;
21 IOSChromeUpdatePasswordInfoBarDelegate* _delegate; 24 IOSChromeUpdatePasswordInfoBarDelegate* _delegate;
22 } 25 }
26 @property(nonatomic, retain) SelectorCoordinator* selectorCoordinator;
23 @end 27 @end
24 28
25 @implementation UpdatePasswordInfoBarController 29 @implementation UpdatePasswordInfoBarController
26 30
31 @synthesize selectorCoordinator = _selectorCoordinator;
32
33 - (instancetype)initWithDelegate:(InfoBarViewDelegate*)delegate {
34 self = [super initWithDelegate:delegate];
35 if (self) {
36 _propertyReleaser_UpdatePasswordInfoBarController.Init(
37 self, [UpdatePasswordInfoBarController class]);
38 }
39 return self;
40 }
41
27 - (base::scoped_nsobject<UIView<InfoBarViewProtocol>>) 42 - (base::scoped_nsobject<UIView<InfoBarViewProtocol>>)
28 viewForDelegate:(IOSChromeUpdatePasswordInfoBarDelegate*)delegate 43 viewForDelegate:(IOSChromeUpdatePasswordInfoBarDelegate*)delegate
29 frame:(CGRect)frame { 44 frame:(CGRect)frame {
30 _delegate = delegate; 45 _delegate = delegate;
31 return [super viewForDelegate:delegate frame:frame]; 46 return [super viewForDelegate:delegate frame:frame];
32 } 47 }
33 48
34 - (void)updateInfobarLabel:(UIView<InfoBarViewProtocol>*)view { 49 - (void)updateInfobarLabel:(UIView<InfoBarViewProtocol>*)view {
35 [super updateInfobarLabel:view]; 50 [super updateInfobarLabel:view];
36 51
(...skipping 14 matching lines...) Expand all
51 action:@selector(infobarLinkDidPress:)]; 66 action:@selector(infobarLinkDidPress:)];
52 } 67 }
53 68
54 - (void)infobarLinkDidPress:(NSNumber*)tag { 69 - (void)infobarLinkDidPress:(NSNumber*)tag {
55 [super infobarLinkDidPress:tag]; 70 [super infobarLinkDidPress:tag];
56 if ([tag unsignedIntegerValue] != kAccountTag) 71 if ([tag unsignedIntegerValue] != kAccountTag)
57 return; 72 return;
58 73
59 UIViewController* baseViewController = 74 UIViewController* baseViewController =
60 [[UIApplication sharedApplication] keyWindow].rootViewController; 75 [[UIApplication sharedApplication] keyWindow].rootViewController;
61 SelectorCoordinator* selectorCoordinator = [[[SelectorCoordinator alloc] 76 self.selectorCoordinator = [[SelectorCoordinator alloc]
62 initWithBaseViewController:baseViewController] autorelease]; 77 initWithBaseViewController:baseViewController];
63 selectorCoordinator.delegate = self; 78 self.selectorCoordinator.delegate = self;
64 selectorCoordinator.options = [_delegate->GetAccounts() copy]; 79 self.selectorCoordinator.options = [_delegate->GetAccounts() copy];
65 selectorCoordinator.defaultOption = 80 self.selectorCoordinator.defaultOption =
66 base::SysUTF16ToNSString(_delegate->selected_account()); 81 base::SysUTF16ToNSString(_delegate->selected_account());
67 [selectorCoordinator start]; 82 [self.selectorCoordinator start];
68 } 83 }
69 84
70 #pragma mark SelectorCoordinatorDelegate 85 #pragma mark SelectorCoordinatorDelegate
71 86
72 - (void)selectorCoordinator:(SelectorCoordinator*)coordinator 87 - (void)selectorCoordinator:(SelectorCoordinator*)coordinator
73 didCompleteWithSelection:(NSString*)selection { 88 didCompleteWithSelection:(NSString*)selection {
74 _delegate->set_selected_account(base::SysNSStringToUTF16(selection)); 89 _delegate->set_selected_account(base::SysNSStringToUTF16(selection));
90 [self updateInfobarLabel:self.view];
75 } 91 }
76 92
77 @end 93 @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