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

Unified Diff: chrome/browser/ui/views/passwords/manage_password_item_view.cc

Issue 266973002: Password bubble: Create subviews for ManagePasswordsBubbleView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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/views/passwords/manage_password_item_view.cc
diff --git a/chrome/browser/ui/views/passwords/manage_password_item_view.cc b/chrome/browser/ui/views/passwords/manage_password_item_view.cc
index 8f0773e4c0308fd71b452a9158de29c55105df95..d293532647ac83c5e6bb4a7a7818fa5bc1c34f27 100644
--- a/chrome/browser/ui/views/passwords/manage_password_item_view.cc
+++ b/chrome/browser/ui/views/passwords/manage_password_item_view.cc
@@ -15,6 +15,40 @@
#include "ui/views/layout/grid_layout.h"
#include "ui/views/layout/layout_constants.h"
+namespace {
+
+enum FieldType { USERNAME_FIELD, PASSWORD_FIELD };
+
+// Upper limit on the size of the username and password fields.
+const int kUsernameFieldSize = 30;
+const int kPasswordFieldSize = 22;
+
+// Returns the width of |type| field.
+int GetFieldWidth(FieldType type) {
+ return ui::ResourceBundle::GetSharedInstance()
+ .GetFontList(ui::ResourceBundle::SmallFont)
+ .GetExpectedTextWidth(type == USERNAME_FIELD ? kUsernameFieldSize
+ : kPasswordFieldSize);
+}
+
+int FirstFieldWidth() {
+ return std::max(
+ GetFieldWidth(USERNAME_FIELD),
+ views::Label(l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_DELETED))
+ .GetPreferredSize()
+ .width());
+}
+
+int SecondFieldWidth() {
+ return std::max(
+ GetFieldWidth(PASSWORD_FIELD),
+ views::Label(l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_UNDO))
+ .GetPreferredSize()
+ .width());
+}
+
+} // namespace
+
// Pending View
ManagePasswordItemView::PendingView::PendingView(
ManagePasswordItemView* parent) {
@@ -99,14 +133,10 @@ ManagePasswordItemView::UndoView::~UndoView() {}
ManagePasswordItemView::ManagePasswordItemView(
ManagePasswordsBubbleModel* manage_passwords_bubble_model,
autofill::PasswordForm password_form,
- int field_1_width,
- int field_2_width,
Position position)
: manage_passwords_bubble_model_(manage_passwords_bubble_model),
password_form_(password_form),
- delete_password_(false),
- field_1_width_(field_1_width),
- field_2_width_(field_2_width) {
+ delete_password_(false) {
views::FillLayout* layout = new views::FillLayout();
SetLayoutManager(layout);
@@ -140,8 +170,8 @@ void ManagePasswordItemView::BuildColumnSet(views::GridLayout* layout,
views::GridLayout::FILL,
0,
views::GridLayout::FIXED,
- field_1_width_,
- field_1_width_);
+ FirstFieldWidth(),
+ FirstFieldWidth());
// The password/"Undo!" field.
column_set->AddPaddingColumn(0, views::kItemLabelSpacing);
@@ -149,8 +179,8 @@ void ManagePasswordItemView::BuildColumnSet(views::GridLayout* layout,
views::GridLayout::FILL,
1,
views::GridLayout::USE_PREF,
- field_2_width_,
- field_2_width_);
+ SecondFieldWidth(),
+ SecondFieldWidth());
// If we're in manage-mode, we need another column for the delete button.
if (column_set_id == THREE_COLUMN_SET) {

Powered by Google App Engine
This is Rietveld 408576698