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

Unified Diff: chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.mm

Issue 1992633003: Add "Sign In" button to the account chooser on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.mm
diff --git a/chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.mm b/chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.mm
index 949b5139ccaa955bc8df680172f8cfb6f27a3cf8..5e0c932cc3e58a022930c991f0f900155bc90340 100644
--- a/chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.mm
+++ b/chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.mm
@@ -38,12 +38,14 @@ constexpr CGFloat kMaxHeightAccounts = 3.5;
@interface AccountChooserViewController () {
NSButton* cancelButton_; // Weak.
+ NSButton* signInButton_; // Weak.
NSTextView* titleView_; // Weak.
base::scoped_nsobject<NSArray> credentialButtons_;
base::scoped_nsobject<AccountAvatarFetcherManager> avatarManager_;
}
- (void)onCancelClicked:(id)sender;
- (void)onCredentialClicked:(id)sender;
+- (void)onSignInClicked:(id)sender;
- (void)loadCredentialItems;
@end
@@ -57,6 +59,10 @@ constexpr CGFloat kMaxHeightAccounts = 3.5;
return [self initWithBridge:bridge avatarManager:avatarManager];
}
+- (NSButton*)defaultButton {
+ return signInButton_;
+}
+
- (void)loadView {
base::scoped_nsobject<NSView> view([[NSView alloc] initWithFrame:NSZeroRect]);
@@ -70,13 +76,14 @@ constexpr CGFloat kMaxHeightAccounts = 3.5;
// | | | credential view |
// | ---- |
// | |
- // | [ Cancel ] |
+ // | [ Cancel ] [Sign In] |
// ------------------------------------
// Create the views.
// Title.
+ PasswordDialogController* controller = bridge_->GetDialogController();
std::pair<base::string16, gfx::Range> title_text =
- bridge_->GetDialogController()->GetAccoutChooserTitle();
+ controller->GetAccoutChooserTitle();
titleView_ =
TitleDialogLabelWithLink(title_text.first, title_text.second, self);
// Force the text to wrap to fit in the bubble size.
@@ -91,15 +98,30 @@ constexpr CGFloat kMaxHeightAccounts = 3.5;
[self loadCredentialItems];
// "Cancel" button.
- cancelButton_ = DialogButton(l10n_util::GetNSString(IDS_APP_CANCEL));
+ cancelButton_ = BiggerDialogButton(l10n_util::GetNSString(IDS_APP_CANCEL));
[cancelButton_ setTarget:self];
[cancelButton_ setAction:@selector(onCancelClicked:)];
[cancelButton_ setKeyEquivalent:kKeyEquivalentEscape];
[view addSubview:cancelButton_];
+ // "Sign In" button.
+ if (controller->ShouldShowSignInButton()) {
+ signInButton_ = BiggerDialogButton(
+ l10n_util::GetNSString(IDS_PASSWORD_MANAGER_ACCOUNT_CHOOSER_SIGN_IN));
+ [signInButton_ setTarget:self];
+ [signInButton_ setAction:@selector(onSignInClicked:)];
+ [signInButton_ setKeyEquivalent:kKeyEquivalentReturn];
+ [view addSubview:signInButton_];
+ }
+
// Lay out the views.
+ CGFloat curX = kFramePadding + width;
+ if (signInButton_) {
+ curX -= NSWidth([signInButton_ frame]);
+ [signInButton_ setFrameOrigin:NSMakePoint(curX, kFramePadding)];
+ }
[cancelButton_ setFrameOrigin:NSMakePoint(
- kFramePadding + width - NSWidth([cancelButton_ frame]),
+ curX - NSWidth([cancelButton_ frame]),
kFramePadding)];
NSSize buttonsSize = NSMakeSize(
@@ -159,6 +181,11 @@ constexpr CGFloat kMaxHeightAccounts = 3.5;
}
}
+- (void)onSignInClicked:(id)sender {
+ if (bridge_ && bridge_->GetDialogController())
+ bridge_->GetDialogController()->OnSignInClicked();
+}
+
- (void)loadCredentialItems {
base::scoped_nsobject<NSMutableArray> items([[NSMutableArray alloc] init]);
PasswordDialogController* controller = self.bridge->GetDialogController();
@@ -225,6 +252,10 @@ constexpr CGFloat kMaxHeightAccounts = 3.5;
return cancelButton_;
}
+- (NSButton*)signInButton {
+ return signInButton_;
+}
+
- (NSArray*)credentialButtons {
return credentialButtons_;
}

Powered by Google App Engine
This is Rietveld 408576698