| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/ui/cocoa/passwords/passwords_bubble_controller.h" | 5 #import "chrome/browser/ui/cocoa/passwords/passwords_bubble_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 #include "chrome/browser/ui/browser_finder.h" | 8 #include "chrome/browser/ui/browser_finder.h" |
| 9 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 9 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 10 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 10 #import "chrome/browser/ui/cocoa/info_bubble_view.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 [super dealloc]; | 45 [super dealloc]; |
| 46 } | 46 } |
| 47 | 47 |
| 48 - (void)showWindow:(id)sender { | 48 - (void)showWindow:(id)sender { |
| 49 [self performLayout]; | 49 [self performLayout]; |
| 50 [super showWindow:sender]; | 50 [super showWindow:sender]; |
| 51 } | 51 } |
| 52 | 52 |
| 53 - (void)close { | 53 - (void)close { |
| 54 [currentController_ bubbleWillDisappear]; | 54 [currentController_ bubbleWillDisappear]; |
| 55 // The bubble is about to be closed. It destroys the model. |
| 56 model_ = nil; |
| 55 [super close]; | 57 [super close]; |
| 56 } | 58 } |
| 57 | 59 |
| 58 - (void)updateState { | 60 - (void)updateState { |
| 59 // Find the next view controller. | 61 // Find the next view controller. |
| 60 currentController_.reset(); | 62 currentController_.reset(); |
| 61 if (model_->state() == password_manager::ui::PENDING_PASSWORD_STATE) { | 63 if (model_->state() == password_manager::ui::PENDING_PASSWORD_STATE) { |
| 62 currentController_.reset([[SavePendingPasswordViewController alloc] | 64 currentController_.reset([[SavePendingPasswordViewController alloc] |
| 63 initWithModel:model_ | 65 initWithDelegate:self]); |
| 64 delegate:self]); | |
| 65 } else if (model_->state() == | 66 } else if (model_->state() == |
| 66 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE) { | 67 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE) { |
| 67 currentController_.reset([[UpdatePendingPasswordViewController alloc] | 68 currentController_.reset([[UpdatePendingPasswordViewController alloc] |
| 68 initWithModel:model_ | 69 initWithDelegate:self]); |
| 69 delegate:self]); | |
| 70 } else if (model_->state() == password_manager::ui::CONFIRMATION_STATE) { | 70 } else if (model_->state() == password_manager::ui::CONFIRMATION_STATE) { |
| 71 currentController_.reset( | 71 currentController_.reset( |
| 72 [[ManagePasswordsBubbleConfirmationViewController alloc] | 72 [[ManagePasswordsBubbleConfirmationViewController alloc] |
| 73 initWithModel:model_ | 73 initWithModel:model_ |
| 74 delegate:self]); | 74 delegate:self]); |
| 75 } else if (model_->state() == password_manager::ui::MANAGE_STATE) { | 75 } else if (model_->state() == password_manager::ui::MANAGE_STATE) { |
| 76 currentController_.reset( | 76 currentController_.reset( |
| 77 [[ManagePasswordsBubbleManageViewController alloc] | 77 [[ManagePasswordsBubbleManageViewController alloc] |
| 78 initWithModel:model_ | 78 initWithModel:model_ |
| 79 delegate:self]); | 79 delegate:self]); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 display:YES | 141 display:YES |
| 142 animate:[window isVisible]]; | 142 animate:[window isVisible]]; |
| 143 } | 143 } |
| 144 | 144 |
| 145 #pragma mark ManagePasswordsBubbleContentViewDelegate | 145 #pragma mark ManagePasswordsBubbleContentViewDelegate |
| 146 | 146 |
| 147 - (void)viewShouldDismiss { | 147 - (void)viewShouldDismiss { |
| 148 [self close]; | 148 [self close]; |
| 149 } | 149 } |
| 150 | 150 |
| 151 - (ManagePasswordsBubbleModel*)model { |
| 152 return model_; |
| 153 } |
| 154 |
| 151 @end | 155 @end |
| 152 | 156 |
| 153 @implementation ManagePasswordsBubbleController (Testing) | 157 @implementation ManagePasswordsBubbleController (Testing) |
| 154 | 158 |
| 155 - (NSViewController*)currentController { | 159 - (NSViewController*)currentController { |
| 156 return currentController_.get(); | 160 return currentController_.get(); |
| 157 } | 161 } |
| 158 | 162 |
| 159 @end | 163 @end |
| OLD | NEW |