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

Side by Side Diff: chrome/browser/ui/views/passwords/account_chooser_dialog_view.cc

Issue 1972163002: Change the maximum account chooser height to 3.5 rows on Views. (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 #include "chrome/browser/ui/views/passwords/account_chooser_dialog_view.h" 5 #include "chrome/browser/ui/views/passwords/account_chooser_dialog_view.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" 9 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h"
10 #include "chrome/browser/ui/passwords/password_dialog_controller.h" 10 #include "chrome/browser/ui/passwords/password_dialog_controller.h"
11 #include "chrome/browser/ui/views/passwords/credentials_item_view.h" 11 #include "chrome/browser/ui/views/passwords/credentials_item_view.h"
12 #include "chrome/grit/generated_resources.h" 12 #include "chrome/grit/generated_resources.h"
13 #include "components/autofill/core/common/password_form.h" 13 #include "components/autofill/core/common/password_form.h"
14 #include "components/constrained_window/constrained_window_views.h" 14 #include "components/constrained_window/constrained_window_views.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
18 #include "ui/strings/grit/ui_strings.h" 18 #include "ui/strings/grit/ui_strings.h"
19 #include "ui/views/border.h" 19 #include "ui/views/border.h"
20 #include "ui/views/controls/scroll_view.h" 20 #include "ui/views/controls/scroll_view.h"
21 #include "ui/views/controls/styled_label.h" 21 #include "ui/views/controls/styled_label.h"
22 #include "ui/views/layout/box_layout.h" 22 #include "ui/views/layout/box_layout.h"
23 #include "ui/views/layout/grid_layout.h" 23 #include "ui/views/layout/grid_layout.h"
24 #include "ui/views/layout/layout_constants.h" 24 #include "ui/views/layout/layout_constants.h"
25 #include "ui/views/widget/widget.h" 25 #include "ui/views/widget/widget.h"
26 26
27 namespace { 27 namespace {
28 28
29 // Maximum number of accounts displayed before vertical scrolling appears. 29 // Maximum height of the credential list. The unit is one row's height.
30 const size_t kMaxAccounts = 3; 30 constexpr double kMaxHeightAccounts = 3.5;
31 31
32 const int kVerticalAvatarMargin = 8; 32 constexpr int kVerticalAvatarMargin = 8;
33 33
34 // An identifier for views::ColumnSet. 34 // An identifier for views::ColumnSet.
35 enum ColumnSetType { 35 enum ColumnSetType {
36 SINGLE_VIEW_COLUMN_SET, 36 SINGLE_VIEW_COLUMN_SET,
37 SINGLE_VIEW_COLUMN_SET_NO_PADDING, 37 SINGLE_VIEW_COLUMN_SET_NO_PADDING,
38 }; 38 };
39 39
40 // Construct a |type| ColumnSet and add it to |layout|. 40 // Construct a |type| ColumnSet and add it to |layout|.
41 void BuildColumnSet(ColumnSetType type, views::GridLayout* layout) { 41 void BuildColumnSet(ColumnSetType type, views::GridLayout* layout) {
42 views::ColumnSet* column_set = layout->AddColumnSet(type); 42 views::ColumnSet* column_set = layout->AddColumnSet(type);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 button_listener, titles.first, titles.second, kButtonHoverColor, 81 button_listener, titles.first, titles.second, kButtonHoverColor,
82 form.get(), request_context); 82 form.get(), request_context);
83 credential_view->SetLowerLabelColor(kAutoSigninTextColor); 83 credential_view->SetLowerLabelColor(kAutoSigninTextColor);
84 credential_view->SetBorder(views::Border::CreateEmptyBorder( 84 credential_view->SetBorder(views::Border::CreateEmptyBorder(
85 kVerticalAvatarMargin, views::kButtonHEdgeMarginNew, 85 kVerticalAvatarMargin, views::kButtonHEdgeMarginNew,
86 kVerticalAvatarMargin, views::kButtonHEdgeMarginNew)); 86 kVerticalAvatarMargin, views::kButtonHEdgeMarginNew));
87 item_height = std::max(item_height, credential_view->GetPreferredHeight()); 87 item_height = std::max(item_height, credential_view->GetPreferredHeight());
88 list_view->AddChildView(credential_view); 88 list_view->AddChildView(credential_view);
89 } 89 }
90 views::ScrollView* scroll_view = new views::ScrollView; 90 views::ScrollView* scroll_view = new views::ScrollView;
91 scroll_view->ClipHeightTo(0, kMaxAccounts * item_height); 91 scroll_view->ClipHeightTo(0, kMaxHeightAccounts * item_height);
92 scroll_view->SetContents(list_view); 92 scroll_view->SetContents(list_view);
93 return scroll_view; 93 return scroll_view;
94 } 94 }
95 95
96 } // namespace 96 } // namespace
97 97
98 AccountChooserDialogView::AccountChooserDialogView( 98 AccountChooserDialogView::AccountChooserDialogView(
99 PasswordDialogController* controller, 99 PasswordDialogController* controller,
100 content::WebContents* web_contents) 100 content::WebContents* web_contents)
101 : controller_(controller), 101 : controller_(controller),
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 GetProfileFromWebContents(web_contents_)->GetRequestContext())); 194 GetProfileFromWebContents(web_contents_)->GetRequestContext()));
195 // DialogClientView adds kRelatedControlVerticalSpacing padding once more for 195 // DialogClientView adds kRelatedControlVerticalSpacing padding once more for
196 // the buttons. 196 // the buttons.
197 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 197 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
198 } 198 }
199 199
200 AccountChooserPrompt* CreateAccountChooserPromptView( 200 AccountChooserPrompt* CreateAccountChooserPromptView(
201 PasswordDialogController* controller, content::WebContents* web_contents) { 201 PasswordDialogController* controller, content::WebContents* web_contents) {
202 return new AccountChooserDialogView(controller, web_contents); 202 return new AccountChooserDialogView(controller, web_contents);
203 } 203 }
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