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

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

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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
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_items_view.h" 5 #include "chrome/browser/ui/views/passwords/manage_password_items_view.h"
6 6
7 #include <numeric> 7 #include <numeric>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 column_set->AddPaddingColumn(0, views::kItemLabelSpacing); 59 column_set->AddPaddingColumn(0, views::kItemLabelSpacing);
60 column_set->AddColumn(views::GridLayout::TRAILING, 60 column_set->AddColumn(views::GridLayout::TRAILING,
61 views::GridLayout::FILL, 61 views::GridLayout::FILL,
62 0, 62 0,
63 views::GridLayout::USE_PREF, 63 views::GridLayout::USE_PREF,
64 0, 64 0,
65 0); 65 0);
66 } 66 }
67 } 67 }
68 68
69 scoped_ptr<views::Label> GenerateUsernameLabel( 69 std::unique_ptr<views::Label> GenerateUsernameLabel(
70 const autofill::PasswordForm& form) { 70 const autofill::PasswordForm& form) {
71 scoped_ptr<views::Label> label(new views::Label(GetDisplayUsername(form))); 71 std::unique_ptr<views::Label> label(
72 new views::Label(GetDisplayUsername(form)));
72 label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( 73 label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList(
73 ui::ResourceBundle::SmallFont)); 74 ui::ResourceBundle::SmallFont));
74 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 75 label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
75 return label; 76 return label;
76 } 77 }
77 78
78 scoped_ptr<views::Label> GeneratePasswordLabel( 79 std::unique_ptr<views::Label> GeneratePasswordLabel(
79 const autofill::PasswordForm& form) { 80 const autofill::PasswordForm& form) {
80 base::string16 text = 81 base::string16 text =
81 form.federation_origin.unique() 82 form.federation_origin.unique()
82 ? form.password_value 83 ? form.password_value
83 : l10n_util::GetStringFUTF16( 84 : l10n_util::GetStringFUTF16(
84 IDS_PASSWORDS_VIA_FEDERATION, 85 IDS_PASSWORDS_VIA_FEDERATION,
85 base::UTF8ToUTF16(form.federation_origin.host())); 86 base::UTF8ToUTF16(form.federation_origin.host()));
86 scoped_ptr<views::Label> label(new views::Label(text)); 87 std::unique_ptr<views::Label> label(new views::Label(text));
87 label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( 88 label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList(
88 ui::ResourceBundle::SmallFont)); 89 ui::ResourceBundle::SmallFont));
89 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 90 label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
90 if (form.federation_origin.unique()) 91 if (form.federation_origin.unique())
91 label->SetObscured(true); 92 label->SetObscured(true);
92 return label; 93 return label;
93 } 94 }
94 95
95 scoped_ptr<views::ImageButton> GenerateDeleteButton( 96 std::unique_ptr<views::ImageButton> GenerateDeleteButton(
96 views::ButtonListener* listener) { 97 views::ButtonListener* listener) {
97 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 98 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
98 scoped_ptr<views::ImageButton> button(new views::ImageButton(listener)); 99 std::unique_ptr<views::ImageButton> button(new views::ImageButton(listener));
99 button->SetImage(views::ImageButton::STATE_NORMAL, 100 button->SetImage(views::ImageButton::STATE_NORMAL,
100 rb->GetImageNamed(IDR_CLOSE_2).ToImageSkia()); 101 rb->GetImageNamed(IDR_CLOSE_2).ToImageSkia());
101 button->SetImage(views::ImageButton::STATE_HOVERED, 102 button->SetImage(views::ImageButton::STATE_HOVERED,
102 rb->GetImageNamed(IDR_CLOSE_2_H).ToImageSkia()); 103 rb->GetImageNamed(IDR_CLOSE_2_H).ToImageSkia());
103 button->SetImage(views::ImageButton::STATE_PRESSED, 104 button->SetImage(views::ImageButton::STATE_PRESSED,
104 rb->GetImageNamed(IDR_CLOSE_2_P).ToImageSkia()); 105 rb->GetImageNamed(IDR_CLOSE_2_P).ToImageSkia());
105 return button; 106 return button;
106 } 107 }
107 108
108 scoped_ptr<views::Label> GenerateDeletedPasswordLabel() { 109 std::unique_ptr<views::Label> GenerateDeletedPasswordLabel() {
109 scoped_ptr<views::Label> text(new views::Label( 110 std::unique_ptr<views::Label> text(new views::Label(
110 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_DELETED))); 111 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_DELETED)));
111 text->SetHorizontalAlignment(gfx::ALIGN_LEFT); 112 text->SetHorizontalAlignment(gfx::ALIGN_LEFT);
112 text->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( 113 text->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList(
113 ui::ResourceBundle::SmallFont)); 114 ui::ResourceBundle::SmallFont));
114 return text; 115 return text;
115 } 116 }
116 117
117 scoped_ptr<views::Link> GenerateUndoLink(views::LinkListener* listener) { 118 std::unique_ptr<views::Link> GenerateUndoLink(views::LinkListener* listener) {
118 scoped_ptr<views::Link> undo_link(new views::Link( 119 std::unique_ptr<views::Link> undo_link(
119 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_UNDO))); 120 new views::Link(l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_UNDO)));
120 undo_link->SetHorizontalAlignment(gfx::ALIGN_RIGHT); 121 undo_link->SetHorizontalAlignment(gfx::ALIGN_RIGHT);
121 undo_link->set_listener(listener); 122 undo_link->set_listener(listener);
122 undo_link->SetUnderline(false); 123 undo_link->SetUnderline(false);
123 undo_link->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( 124 undo_link->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList(
124 ui::ResourceBundle::SmallFont)); 125 ui::ResourceBundle::SmallFont));
125 return undo_link; 126 return undo_link;
126 } 127 }
127 128
128 } // namespace 129 } // namespace
129 130
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 AddUndoRow(layout); 185 AddUndoRow(layout);
185 } else { 186 } else {
186 AddCredentialsRow(layout); 187 AddCredentialsRow(layout);
187 } 188 }
188 } 189 }
189 190
190 int ManagePasswordItemsView::PasswordFormRow::GetFixedHeight( 191 int ManagePasswordItemsView::PasswordFormRow::GetFixedHeight(
191 password_manager::ui::State state) { 192 password_manager::ui::State state) {
192 if (state != password_manager::ui::MANAGE_STATE) 193 if (state != password_manager::ui::MANAGE_STATE)
193 return 0; 194 return 0;
194 scoped_ptr<views::ImageButton> delete_button(GenerateDeleteButton(nullptr)); 195 std::unique_ptr<views::ImageButton> delete_button(
195 scoped_ptr<views::Link> link(GenerateUndoLink(nullptr)); 196 GenerateDeleteButton(nullptr));
196 scoped_ptr<views::Label> label(GenerateDeletedPasswordLabel()); 197 std::unique_ptr<views::Link> link(GenerateUndoLink(nullptr));
198 std::unique_ptr<views::Label> label(GenerateDeletedPasswordLabel());
197 views::View* row_views[] = {delete_button.get(), link.get(), label.get()}; 199 views::View* row_views[] = {delete_button.get(), link.get(), label.get()};
198 return std::accumulate(row_views, row_views + arraysize(row_views), 0, 200 return std::accumulate(row_views, row_views + arraysize(row_views), 0,
199 [](int max_height, const views::View* view) { 201 [](int max_height, const views::View* view) {
200 return std::max(max_height, view->GetPreferredSize().height()); 202 return std::max(max_height, view->GetPreferredSize().height());
201 }); 203 });
202 } 204 }
203 205
204 void ManagePasswordItemsView::PasswordFormRow::AddCredentialsRow( 206 void ManagePasswordItemsView::PasswordFormRow::AddCredentialsRow(
205 views::GridLayout* layout) { 207 views::GridLayout* layout) {
206 ResetControls(); 208 ResetControls();
(...skipping 13 matching lines...) Expand all
220 delete_button_ = GenerateDeleteButton(this).release(); 222 delete_button_ = GenerateDeleteButton(this).release();
221 layout->AddView(delete_button_, 1, 1, 223 layout->AddView(delete_button_, 1, 1,
222 views::GridLayout::TRAILING, views::GridLayout::FILL, 224 views::GridLayout::TRAILING, views::GridLayout::FILL,
223 0, fixed_height_); 225 0, fixed_height_);
224 } 226 }
225 } 227 }
226 228
227 void ManagePasswordItemsView::PasswordFormRow::AddUndoRow( 229 void ManagePasswordItemsView::PasswordFormRow::AddUndoRow(
228 views::GridLayout* layout) { 230 views::GridLayout* layout) {
229 ResetControls(); 231 ResetControls();
230 scoped_ptr<views::Label> text = GenerateDeletedPasswordLabel(); 232 std::unique_ptr<views::Label> text = GenerateDeletedPasswordLabel();
231 scoped_ptr<views::Link> undo_link = GenerateUndoLink(this); 233 std::unique_ptr<views::Link> undo_link = GenerateUndoLink(this);
232 undo_link_ = undo_link.get(); 234 undo_link_ = undo_link.get();
233 BuildColumnSetIfNeeded(layout, TWO_COLUMN_SET); 235 BuildColumnSetIfNeeded(layout, TWO_COLUMN_SET);
234 layout->StartRow(0, TWO_COLUMN_SET); 236 layout->StartRow(0, TWO_COLUMN_SET);
235 layout->AddView(text.release(), 1, 1, 237 layout->AddView(text.release(), 1, 1,
236 views::GridLayout::FILL, views::GridLayout::FILL, 238 views::GridLayout::FILL, views::GridLayout::FILL,
237 0, fixed_height_); 239 0, fixed_height_);
238 layout->AddView(undo_link.release(), 1, 1, 240 layout->AddView(undo_link.release(), 1, 1,
239 views::GridLayout::FILL, views::GridLayout::FILL, 241 views::GridLayout::FILL, views::GridLayout::FILL,
240 0, fixed_height_); 242 0, fixed_height_);
241 } 243 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 deleted 297 deleted
296 ? ManagePasswordsBubbleModel::REMOVE_PASSWORD 298 ? ManagePasswordsBubbleModel::REMOVE_PASSWORD
297 : ManagePasswordsBubbleModel::ADD_PASSWORD); 299 : ManagePasswordsBubbleModel::ADD_PASSWORD);
298 } 300 }
299 301
300 void ManagePasswordItemsView::Refresh() { 302 void ManagePasswordItemsView::Refresh() {
301 DCHECK_NE(password_manager::ui::PENDING_PASSWORD_STATE, model_->state()); 303 DCHECK_NE(password_manager::ui::PENDING_PASSWORD_STATE, model_->state());
302 RemoveAllChildViews(true); 304 RemoveAllChildViews(true);
303 AddRows(); 305 AddRows();
304 } 306 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698