Chromium Code Reviews| Index: chrome/browser/ui/cocoa/passwords/update_pending_password_view_controller.mm |
| diff --git a/chrome/browser/ui/cocoa/passwords/update_pending_password_view_controller.mm b/chrome/browser/ui/cocoa/passwords/update_pending_password_view_controller.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..39465cb97d4f34750fa470b0999c92307a00105c |
| --- /dev/null |
| +++ b/chrome/browser/ui/cocoa/passwords/update_pending_password_view_controller.mm |
| @@ -0,0 +1,97 @@ |
| +// Copyright 2015 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 "chrome/browser/ui/cocoa/passwords/update_pending_password_view_controller.h" |
| + |
| +#import "chrome/browser/ui/cocoa/passwords/credentials_selection_view.h" |
| +#import "chrome/browser/ui/cocoa/passwords/passwords_list_view_controller.h" |
| +#include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" |
| +#include "chrome/grit/generated_resources.h" |
| +#include "ui/base/l10n/l10n_util.h" |
| + |
| +@interface UpdatePendingPasswordViewController () |
| +- (void)onUpdateClicked:(id)sender; |
| +- (void)onNopeClicked:(id)sender; |
| +@end |
| + |
| +@implementation UpdatePendingPasswordViewController |
| + |
| +- (UpdatePendingPasswordViewController*) |
| +initWithModel:(ManagePasswordsBubbleModel*)model |
| + delegate:(id<ManagePasswordsBubbleContentViewDelegate>)delegate { |
| + self = [super initWithModel:model delegate:delegate]; |
| + return self; |
| +} |
| + |
| +- (NSButton*)defaultButton { |
| + return updateButton_; |
| +} |
| + |
| +- (void)onUpdateClicked:(id)sender { |
| + if (passwordWithUsernameSelectionItem_) { |
| + // Multi account case. |
| + self.model->OnUpdateClicked( |
| + *[passwordWithUsernameSelectionItem_ getSelectedCredentials]); |
| + } else { |
| + self.model->OnUpdateClicked(self.model->pending_password()); |
| + } |
| + [delegate_ viewShouldDismiss]; |
| +} |
| + |
| +- (void)onNopeClicked:(id)sender { |
| + self.model->OnNopeUpdateClicked(); |
| + [delegate_ viewShouldDismiss]; |
| +} |
| + |
| +- (NSView*)createPasswordView { |
| + if (self.model->ShouldShowMultipleAccountUpdateUI()) { |
| + passwordWithUsernameSelectionItem_.reset( |
| + [[CredentialsSelectionView alloc] initWithModel:self.model]); |
| + return passwordWithUsernameSelectionItem_.get(); |
| + } else { |
| + std::vector<const autofill::PasswordForm*> password_forms; |
| + password_forms.push_back(&self.model->pending_password()); |
| + passwordItem_.reset([[PasswordsListViewController alloc] |
| + initWithModel:self.model |
| + forms:password_forms]); |
| + |
| + return [passwordItem_ view]; |
| + } |
| +} |
| + |
| +- (BOOL)shouldShowGoogleSmartLockWelcome { |
| + return NO; |
|
vasilii
2015/12/15 15:58:02
This is the default implementation.
dvadym
2015/12/16 14:16:31
Removed
|
| +} |
| + |
| +- (NSArray*)createButtonsAndAddThemToView:(NSView*)view { |
| + // Save button. |
| + updateButton_.reset([[self |
| + addButton:l10n_util::GetNSString(IDS_PASSWORD_MANAGER_UPDATE_BUTTON) |
| + toView:view |
| + target:self |
| + action:@selector(onUpdateClicked:)] retain]); |
| + |
| + // Never button. |
| + NSString* nopeButtonText = |
| + l10n_util::GetNSString(IDS_PASSWORD_MANAGER_CANCEL_BUTTON); |
| + nopeButton_.reset([[self addButton:nopeButtonText |
| + toView:view |
| + target:self |
| + action:@selector(onNopeClicked:)] retain]); |
| + return @[ updateButton_, nopeButton_ ]; |
| +} |
| + |
| +@end |
| + |
| +@implementation UpdatePendingPasswordViewController (Testing) |
| + |
| +- (NSButton*)updateButton { |
| + return updateButton_.get(); |
| +} |
| + |
| +- (NSButton*)noButton { |
| + return nopeButton_.get(); |
| +} |
| + |
| +@end |