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

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

Issue 462563002: Add ManagePasswordsBubbleManageViewController and unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix views Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/manage_password_item_view.h" 5 #include "chrome/browser/ui/views/passwords/manage_password_item_view.h"
6 6
7 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" 7 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
8 #include "components/password_manager/core/common/password_manager_ui.h" 8 #include "components/password_manager/core/common/password_manager_ui.h"
9 #include "grit/generated_resources.h" 9 #include "grit/generated_resources.h"
10 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
11 #include "ui/base/resource/resource_bundle.h" 11 #include "ui/base/resource/resource_bundle.h"
12 #include "ui/resources/grit/ui_resources.h" 12 #include "ui/resources/grit/ui_resources.h"
13 #include "ui/views/controls/button/button.h" 13 #include "ui/views/controls/button/button.h"
14 #include "ui/views/controls/button/image_button.h" 14 #include "ui/views/controls/button/image_button.h"
15 #include "ui/views/layout/fill_layout.h" 15 #include "ui/views/layout/fill_layout.h"
16 #include "ui/views/layout/grid_layout.h" 16 #include "ui/views/layout/grid_layout.h"
17 #include "ui/views/layout/layout_constants.h" 17 #include "ui/views/layout/layout_constants.h"
18 18
19 namespace { 19 namespace {
20 20
21 enum FieldType { USERNAME_FIELD, PASSWORD_FIELD };
22
23 // Upper limit on the size of the username and password fields.
24 const int kUsernameFieldSize = 30;
25 const int kPasswordFieldSize = 22;
26
27 // Returns the width of |type| field.
28 int GetFieldWidth(FieldType type) {
29 return ui::ResourceBundle::GetSharedInstance()
30 .GetFontList(ui::ResourceBundle::SmallFont)
31 .GetExpectedTextWidth(type == USERNAME_FIELD ? kUsernameFieldSize
32 : kPasswordFieldSize);
33 }
34
35 int FirstFieldWidth() { 21 int FirstFieldWidth() {
36 return std::max( 22 return std::max(
37 GetFieldWidth(USERNAME_FIELD), 23 ManagePasswordsBubbleModel::UsernameFieldWidth(),
38 views::Label(l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_DELETED)) 24 views::Label(l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_DELETED))
39 .GetPreferredSize() 25 .GetPreferredSize()
40 .width()); 26 .width());
41 } 27 }
42 28
43 int SecondFieldWidth() { 29 int SecondFieldWidth() {
44 return std::max( 30 return std::max(
45 GetFieldWidth(PASSWORD_FIELD), 31 ManagePasswordsBubbleModel::PasswordFieldWidth(),
46 views::Label(l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_UNDO)) 32 views::Label(l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_UNDO))
47 .GetPreferredSize() 33 .GetPreferredSize()
48 .width()); 34 .width());
49 } 35 }
50 36
51 enum ColumnSets { TWO_COLUMN_SET = 0, THREE_COLUMN_SET }; 37 enum ColumnSets { TWO_COLUMN_SET = 0, THREE_COLUMN_SET };
52 38
53 void BuildColumnSet(views::GridLayout* layout, int column_set_id) { 39 void BuildColumnSet(views::GridLayout* layout, int column_set_id) {
54 views::ColumnSet* column_set = layout->AddColumnSet(column_set_id); 40 views::ColumnSet* column_set = layout->AddColumnSet(column_set_id);
55 41
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 229
244 void ManagePasswordItemView::NotifyClickedDelete() { 230 void ManagePasswordItemView::NotifyClickedDelete() {
245 delete_password_ = true; 231 delete_password_ = true;
246 Refresh(); 232 Refresh();
247 } 233 }
248 234
249 void ManagePasswordItemView::NotifyClickedUndo() { 235 void ManagePasswordItemView::NotifyClickedUndo() {
250 delete_password_ = false; 236 delete_password_ = false;
251 Refresh(); 237 Refresh();
252 } 238 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/passwords/manage_passwords_bubble_model.cc ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698