Commit 0912e400 authored by dconnelly's avatar dconnelly Committed by Commit bot

Fix Mac password bubble crash due to the "nope" menu hanging around.

By default open menus in Cocoa exist until the user makes a choice, but
since the bubble and its backing controller are owned and managed by
cross-platform code, this model doesn't make sense. Hiding the menu
programmatically matches the Views implementation and fixes the crash.

Since triggering the NSPopUpButton's menu with |performClick:| spins
a run loop waiting for user input, getting a test working was extremely
difficult. The solution is to refactor BubbleCombobox to subclass
MenuButton instead of NSPopUpButton; http://crbug.com/415088 created
to track this work, which will then support a test for this bug.

BUG=413267

Review URL: https://codereview.chromium.org/563093003

Cr-Commit-Position: refs/heads/master@{#296398}
parent 5fa22ca7
...@@ -32,6 +32,7 @@ const CGFloat kUnrelatedControlVerticalPadding = 20; ...@@ -32,6 +32,7 @@ const CGFloat kUnrelatedControlVerticalPadding = 20;
- (NSButton*)addButton:(NSString*)title target:(id)target action:(SEL)action; - (NSButton*)addButton:(NSString*)title target:(id)target action:(SEL)action;
- (NSTextField*)addTitleLabel:(NSString*)title; - (NSTextField*)addTitleLabel:(NSString*)title;
- (NSTextField*)addLabel:(NSString*)title; - (NSTextField*)addLabel:(NSString*)title;
- (void)bubbleWillDisappear;
@end @end
#endif // CHROME_BROWSER_UI_COCOA_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_CONTENT_VIEW_CONTROLLER_H_ #endif // CHROME_BROWSER_UI_COCOA_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_CONTENT_VIEW_CONTROLLER_H_
...@@ -43,4 +43,7 @@ ...@@ -43,4 +43,7 @@
return label; return label;
} }
- (void)bubbleWillDisappear {
}
@end @end
...@@ -23,7 +23,8 @@ ...@@ -23,7 +23,8 @@
ManagePasswordsBubblePendingViewDelegate> { ManagePasswordsBubblePendingViewDelegate> {
@private @private
ManagePasswordsBubbleModel* model_; ManagePasswordsBubbleModel* model_;
base::scoped_nsobject<NSViewController> currentController_; base::scoped_nsobject<ManagePasswordsBubbleContentViewController>
currentController_;
} }
- (id)initWithParentWindow:(NSWindow*)parentWindow - (id)initWithParentWindow:(NSWindow*)parentWindow
model:(ManagePasswordsBubbleModel*)model; model:(ManagePasswordsBubbleModel*)model;
......
...@@ -42,6 +42,11 @@ ...@@ -42,6 +42,11 @@
[super showWindow:sender]; [super showWindow:sender];
} }
- (void)close {
[currentController_ bubbleWillDisappear];
[super close];
}
- (void)updateState { - (void)updateState {
// Find the next view controller. // Find the next view controller.
currentController_.reset(); currentController_.reset();
......
...@@ -35,6 +35,13 @@ using namespace password_manager::mac::ui; ...@@ -35,6 +35,13 @@ using namespace password_manager::mac::ui;
return self; return self;
} }
- (void)bubbleWillDisappear {
// The "nope" drop-down won't be dismissed until the user chooses an option,
// but if the bubble is dismissed (by cross-platform code) before the user
// makes a choice, then the choice won't actually take any effect.
[[nopeButton_ menu] cancelTrackingWithoutAnimation];
}
- (void)onSaveClicked:(id)sender { - (void)onSaveClicked:(id)sender {
model_->OnSaveClicked(); model_->OnSaveClicked();
[delegate_ viewShouldDismiss]; [delegate_ viewShouldDismiss];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment