OLD | NEW |
---|---|
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 "grit/generated_resources.h" | 7 #include "grit/generated_resources.h" |
8 #include "grit/ui_resources.h" | 8 #include "grit/ui_resources.h" |
9 #include "ui/base/l10n/l10n_util.h" | 9 #include "ui/base/l10n/l10n_util.h" |
10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
11 #include "ui/views/controls/button/button.h" | 11 #include "ui/views/controls/button/button.h" |
12 #include "ui/views/controls/button/image_button.h" | 12 #include "ui/views/controls/button/image_button.h" |
13 #include "ui/views/layout/grid_layout.h" | 13 #include "ui/views/layout/grid_layout.h" |
14 #include "ui/views/layout/layout_constants.h" | 14 #include "ui/views/layout/layout_constants.h" |
15 | 15 |
16 ManagePasswordItemView::ManagePasswordItemView( | 16 ManagePasswordItemView::ManagePasswordItemView( |
17 ManagePasswordsBubbleModel* manage_passwords_bubble_model, | 17 ManagePasswordsBubbleModel* manage_passwords_bubble_model, |
18 autofill::PasswordForm password_form, | 18 autofill::PasswordForm password_form, |
19 int field_1_width, | 19 int field_1_width, |
20 int field_2_width) | 20 int field_2_width, |
21 Position position) | |
21 : manage_passwords_bubble_model_(manage_passwords_bubble_model), | 22 : manage_passwords_bubble_model_(manage_passwords_bubble_model), |
22 password_form_(password_form), | 23 password_form_(password_form), |
23 delete_password_(false), | 24 delete_password_(false), |
24 field_1_width_(field_1_width), | 25 field_1_width_(field_1_width), |
25 field_2_width_(field_2_width) { | 26 field_2_width_(field_2_width) { |
26 views::GridLayout* layout = new views::GridLayout(this); | 27 views::GridLayout* layout = new views::GridLayout(this); |
27 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 28 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
28 SetLayoutManager(layout); | 29 SetLayoutManager(layout); |
29 | 30 |
31 // When a password is displayed as the first item in a list, it has borders | |
32 // on both the top and bottom. When it's in the middle of a list, or at the | |
33 // end, it has a border only on the bottom. | |
34 SetBorder(views::Border::CreateSolidSidedBorder( | |
35 position == FIRST_ITEM ? 1 : 0, | |
36 0, | |
markusheintz_
2014/04/04 14:56:25
nit: I wonder whether we should add a comment or j
| |
37 1, | |
38 0, | |
39 GetNativeTheme()->GetSystemColor( | |
40 ui::NativeTheme::kColorId_EnabledMenuButtonBorderColor))); | |
41 | |
30 // Build the columnset we need for the current state of the model. | 42 // Build the columnset we need for the current state of the model. |
31 int column_set_to_build = | 43 int column_set_to_build = |
32 !manage_passwords_bubble_model_->WaitingToSavePassword() | 44 !manage_passwords_bubble_model_->WaitingToSavePassword() |
33 ? COLUMN_SET_MANAGE | 45 ? COLUMN_SET_MANAGE |
34 : COLUMN_SET_SAVE; | 46 : COLUMN_SET_SAVE; |
35 BuildColumnSet(layout, column_set_to_build); | 47 BuildColumnSet(layout, column_set_to_build); |
36 layout->StartRowWithPadding( | 48 layout->StartRowWithPadding( |
37 0, column_set_to_build, 0, views::kRelatedControlVerticalSpacing); | 49 0, column_set_to_build, 0, views::kRelatedControlVerticalSpacing); |
38 | 50 |
39 // Add the username field: fills the first non-padding column of the layout. | 51 // Add the username field: fills the first non-padding column of the layout. |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 delete_password_ = true; | 183 delete_password_ = true; |
172 Refresh(); | 184 Refresh(); |
173 } | 185 } |
174 | 186 |
175 void ManagePasswordItemView::LinkClicked(views::Link* source, | 187 void ManagePasswordItemView::LinkClicked(views::Link* source, |
176 int event_flags) { | 188 int event_flags) { |
177 DCHECK_EQ(source, label_2_); | 189 DCHECK_EQ(source, label_2_); |
178 delete_password_ = false; | 190 delete_password_ = false; |
179 Refresh(); | 191 Refresh(); |
180 } | 192 } |
OLD | NEW |