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

Side by Side Diff: chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.mm

Issue 1969383002: Change the maximum account chooser height to 3.5 rows 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 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/account_chooser_view_controller.h" 5 #import "chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #include "base/mac/scoped_nsobject.h" 8 #include "base/mac/scoped_nsobject.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 13 matching lines...) Expand all
24 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
25 #include "ui/base/resource/resource_bundle.h" 25 #include "ui/base/resource/resource_bundle.h"
26 #include "ui/strings/grit/ui_strings.h" 26 #include "ui/strings/grit/ui_strings.h"
27 27
28 namespace { 28 namespace {
29 29
30 // Returns height of one credential item. 30 // Returns height of one credential item.
31 constexpr CGFloat kCredentialHeight = 31 constexpr CGFloat kCredentialHeight =
32 kAvatarImageSize + 2 * kVerticalAvatarMargin; 32 kAvatarImageSize + 2 * kVerticalAvatarMargin;
33 33
34 // Maximum number of accounts displayed before vertical scrolling appears. 34 // Maximum height of the credential list. The unit is one row height.
35 constexpr size_t kMaxAccounts = 3; 35 constexpr CGFloat kMaxHeightAccounts = 3.5;
36 36
37 } // namespace 37 } // namespace
38 38
39 @interface AccountChooserViewController () { 39 @interface AccountChooserViewController () {
40 NSButton* cancelButton_; // Weak. 40 NSButton* cancelButton_; // Weak.
41 NSTextView* titleView_; // Weak. 41 NSTextView* titleView_; // Weak.
42 base::scoped_nsobject<NSArray> credentialButtons_; 42 base::scoped_nsobject<NSArray> credentialButtons_;
43 base::scoped_nsobject<AccountAvatarFetcherManager> avatarManager_; 43 base::scoped_nsobject<AccountAvatarFetcherManager> avatarManager_;
44 } 44 }
45 - (void)onCancelClicked:(id)sender; 45 - (void)onCancelClicked:(id)sender;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 [cancelButton_ setKeyEquivalent:kKeyEquivalentEscape]; 97 [cancelButton_ setKeyEquivalent:kKeyEquivalentEscape];
98 [view addSubview:cancelButton_]; 98 [view addSubview:cancelButton_];
99 99
100 // Lay out the views. 100 // Lay out the views.
101 [cancelButton_ setFrameOrigin:NSMakePoint( 101 [cancelButton_ setFrameOrigin:NSMakePoint(
102 kFramePadding + width - NSWidth([cancelButton_ frame]), 102 kFramePadding + width - NSWidth([cancelButton_ frame]),
103 kFramePadding)]; 103 kFramePadding)];
104 104
105 NSSize buttonsSize = NSMakeSize( 105 NSSize buttonsSize = NSMakeSize(
106 kDesiredBubbleWidth, 106 kDesiredBubbleWidth,
107 std::min([credentialButtons_ count], kMaxAccounts) * kCredentialHeight); 107 std::min<CGFloat>([credentialButtons_ count], kMaxHeightAccounts) *
108 kCredentialHeight);
108 base::scoped_nsobject<NSScrollView> scrollView = [[NSScrollView alloc] 109 base::scoped_nsobject<NSScrollView> scrollView = [[NSScrollView alloc]
109 initWithFrame:NSMakeRect(0, 0, buttonsSize.width, buttonsSize.height)]; 110 initWithFrame:NSMakeRect(0, 0, buttonsSize.width, buttonsSize.height)];
110 [scrollView setHasVerticalScroller:[credentialButtons_ count] > kMaxAccounts 111 [scrollView
111 ? YES 112 setHasVerticalScroller:[credentialButtons_ count] > kMaxHeightAccounts
112 : NO]; 113 ? YES
114 : NO];
113 [scrollView setBorderType:NSNoBorder]; 115 [scrollView setBorderType:NSNoBorder];
114 CGFloat buttonWidth = [scrollView contentSize].width; 116 CGFloat buttonWidth = [scrollView contentSize].width;
115 CGFloat curY = 0; 117 CGFloat curY = 0;
116 base::scoped_nsobject<NSView> documentView([[NSView alloc] 118 base::scoped_nsobject<NSView> documentView([[NSView alloc]
117 initWithFrame:NSMakeRect(0, 0, buttonWidth, [credentialButtons_ count] * 119 initWithFrame:NSMakeRect(0, 0, buttonWidth, [credentialButtons_ count] *
118 kCredentialHeight)]); 120 kCredentialHeight)]);
119 for (CredentialItemButton* button in credentialButtons_.get()) { 121 for (CredentialItemButton* button in credentialButtons_.get()) {
120 [documentView addSubview:button]; 122 [documentView addSubview:button];
121 [button setFrame:NSMakeRect(0, curY, buttonWidth, kCredentialHeight)]; 123 [button setFrame:NSMakeRect(0, curY, buttonWidth, kCredentialHeight)];
122 curY = NSMaxY([button frame]); 124 curY = NSMaxY([button frame]);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 227
226 - (NSArray*)credentialButtons { 228 - (NSArray*)credentialButtons {
227 return credentialButtons_; 229 return credentialButtons_;
228 } 230 }
229 231
230 - (NSTextView*)titleView { 232 - (NSTextView*)titleView {
231 return titleView_; 233 return titleView_;
232 } 234 }
233 235
234 @end 236 @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