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

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

Issue 1151373006: Update Confirmation UI for saved password change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed reviewer comments Created 5 years, 6 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 "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" 9 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
10 #include "chrome/grit/generated_resources.h" 10 #include "chrome/grit/generated_resources.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 148 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
149 // views::LinkListener: 149 // views::LinkListener:
150 void LinkClicked(views::Link* source, int event_flags) override; 150 void LinkClicked(views::Link* source, int event_flags) override;
151 151
152 void ResetControls(); 152 void ResetControls();
153 153
154 ManagePasswordItemsView* host_; 154 ManagePasswordItemsView* host_;
155 const autofill::PasswordForm* password_form_; 155 const autofill::PasswordForm* password_form_;
156 // The UI elements pointers are weak and owned by their parent. 156 // The UI elements pointers are weak and owned by their parent.
157 views::Link* undo_link_; 157 views::Link* undo_link_;
158 views::Link* update_link_;
158 views::ImageButton* delete_button_; 159 views::ImageButton* delete_button_;
159 const int fixed_height_; 160 const int fixed_height_;
160 bool deleted_; 161 bool deleted_;
161 162
162 DISALLOW_COPY_AND_ASSIGN(PasswordFormRow); 163 DISALLOW_COPY_AND_ASSIGN(PasswordFormRow);
163 }; 164 };
164 165
165 ManagePasswordItemsView::PasswordFormRow::PasswordFormRow( 166 ManagePasswordItemsView::PasswordFormRow::PasswordFormRow(
166 ManagePasswordItemsView* host, 167 ManagePasswordItemsView* host,
167 const autofill::PasswordForm* password_form, 168 const autofill::PasswordForm* password_form,
(...skipping 25 matching lines...) Expand all
193 return std::accumulate(row_views, row_views + arraysize(row_views), 0, 194 return std::accumulate(row_views, row_views + arraysize(row_views), 0,
194 [](int max_height, const views::View* view) { 195 [](int max_height, const views::View* view) {
195 return std::max(max_height, view->GetPreferredSize().height()); 196 return std::max(max_height, view->GetPreferredSize().height());
196 }); 197 });
197 } 198 }
198 199
199 void ManagePasswordItemsView::PasswordFormRow::AddCredentialsRow( 200 void ManagePasswordItemsView::PasswordFormRow::AddCredentialsRow(
200 views::GridLayout* layout) { 201 views::GridLayout* layout) {
201 ResetControls(); 202 ResetControls();
202 int column_set_id = 203 int column_set_id =
203 host_->model_->state() == password_manager::ui::PENDING_PASSWORD_STATE 204 host_->model_->state() == password_manager::ui::PENDING_PASSWORD_STATE &&
205 !host_->model_->account_for_update_selection()
vabr (Chromium) 2015/06/19 18:03:16 nit: Is this how clang-format indented the line? L
dvadym 2015/07/23 09:45:43 This change was removed.
204 ? TWO_COLUMN_SET 206 ? TWO_COLUMN_SET
205 : THREE_COLUMN_SET; 207 : THREE_COLUMN_SET;
206 BuildColumnSetIfNeeded(layout, column_set_id); 208 BuildColumnSetIfNeeded(layout, column_set_id);
207 layout->StartRowWithPadding(0, column_set_id, 0, 209 layout->StartRowWithPadding(0, column_set_id, 0,
208 views::kRelatedControlVerticalSpacing); 210 views::kRelatedControlVerticalSpacing);
209 layout->AddView(GenerateUsernameLabel(*password_form_).release(), 1, 1, 211 layout->AddView(GenerateUsernameLabel(*password_form_).release(), 1, 1,
210 views::GridLayout::FILL, views::GridLayout::FILL, 212 views::GridLayout::FILL, views::GridLayout::FILL,
211 0, fixed_height_); 213 0, fixed_height_);
212 layout->AddView(GeneratePasswordLabel(*password_form_).release(), 1, 1, 214 layout->AddView(GeneratePasswordLabel(*password_form_).release(), 1, 1,
213 views::GridLayout::FILL, views::GridLayout::FILL, 215 views::GridLayout::FILL, views::GridLayout::FILL,
214 0, fixed_height_); 216 0, fixed_height_);
215 if (column_set_id == THREE_COLUMN_SET) { 217 if (column_set_id == THREE_COLUMN_SET) {
216 delete_button_ = GenerateDeleteButton(this).release(); 218 if (host_->model_->account_for_update_selection()) {
217 layout->AddView(delete_button_, 1, 1, 219 update_link_ = new views::Link(
218 views::GridLayout::TRAILING, views::GridLayout::FILL, 220 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_UPDATE_LINK));
219 0, fixed_height_); 221 update_link_->SetHorizontalAlignment(gfx::ALIGN_RIGHT);
222 update_link_->set_listener(this);
223 update_link_->SetUnderline(false);
224 update_link_->SetFontList(
225 ui::ResourceBundle::GetSharedInstance().GetFontList(
226 ui::ResourceBundle::SmallFont));
227 layout->AddView(update_link_);
228 } else {
229 delete_button_ = GenerateDeleteButton(this).release();
230 layout->AddView(delete_button_, 1, 1, views::GridLayout::TRAILING,
231 views::GridLayout::FILL, 0, fixed_height_);
232 }
220 } 233 }
221 } 234 }
222 235
223 void ManagePasswordItemsView::PasswordFormRow::AddUndoRow( 236 void ManagePasswordItemsView::PasswordFormRow::AddUndoRow(
224 views::GridLayout* layout) { 237 views::GridLayout* layout) {
225 ResetControls(); 238 ResetControls();
226 scoped_ptr<views::Label> text = GenerateDeletedPasswordLabel(); 239 scoped_ptr<views::Label> text = GenerateDeletedPasswordLabel();
227 scoped_ptr<views::Link> undo_link = GenerateUndoLink(this); 240 scoped_ptr<views::Link> undo_link = GenerateUndoLink(this);
228 undo_link_ = undo_link.get(); 241 undo_link_ = undo_link.get();
229 BuildColumnSetIfNeeded(layout, TWO_COLUMN_SET); 242 BuildColumnSetIfNeeded(layout, TWO_COLUMN_SET);
230 layout->StartRowWithPadding(0, TWO_COLUMN_SET, 0, 243 layout->StartRowWithPadding(0, TWO_COLUMN_SET, 0,
231 views::kRelatedControlVerticalSpacing); 244 views::kRelatedControlVerticalSpacing);
232 layout->AddView(text.release(), 1, 1, 245 layout->AddView(text.release(), 1, 1,
233 views::GridLayout::FILL, views::GridLayout::FILL, 246 views::GridLayout::FILL, views::GridLayout::FILL,
234 0, fixed_height_); 247 0, fixed_height_);
235 layout->AddView(undo_link.release(), 1, 1, 248 layout->AddView(undo_link.release(), 1, 1,
236 views::GridLayout::FILL, views::GridLayout::FILL, 249 views::GridLayout::FILL, views::GridLayout::FILL,
237 0, fixed_height_); 250 0, fixed_height_);
238 } 251 }
239 252
240 void ManagePasswordItemsView::PasswordFormRow::ButtonPressed( 253 void ManagePasswordItemsView::PasswordFormRow::ButtonPressed(
241 views::Button* sender, const ui::Event& event) { 254 views::Button* sender, const ui::Event& event) {
242 DCHECK_EQ(delete_button_, sender); 255 DCHECK_EQ(delete_button_, sender);
243 deleted_ = true; 256 deleted_ = true;
244 host_->NotifyPasswordFormStatusChanged(*password_form_, deleted_); 257 host_->NotifyPasswordFormStatusChanged(*password_form_, deleted_);
245 } 258 }
246 259
247 void ManagePasswordItemsView::PasswordFormRow::LinkClicked(views::Link* sender, 260 void ManagePasswordItemsView::PasswordFormRow::LinkClicked(views::Link* sender,
248 int event_flags) { 261 int event_flags) {
249 DCHECK_EQ(undo_link_, sender); 262 DCHECK(sender == undo_link_ || sender == update_link_);
250 deleted_ = false; 263 if (sender == undo_link_) {
251 host_->NotifyPasswordFormStatusChanged(*password_form_, deleted_); 264 deleted_ = false;
265 host_->NotifyPasswordFormStatusChanged(*password_form_, deleted_);
266 } else {
267 host_->NotifyAccountForUpdateWasSelected(*password_form_);
268 }
252 } 269 }
253 270
254 void ManagePasswordItemsView::PasswordFormRow::ResetControls() { 271 void ManagePasswordItemsView::PasswordFormRow::ResetControls() {
255 delete_button_ = nullptr; 272 delete_button_ = nullptr;
256 undo_link_ = nullptr; 273 undo_link_ = nullptr;
257 } 274 }
258 275
259 // ManagePasswordItemsView 276 // ManagePasswordItemsView
260 ManagePasswordItemsView::ManagePasswordItemsView( 277 ManagePasswordItemsView::ManagePasswordItemsView(
261 ManagePasswordsBubbleModel* manage_passwords_bubble_model, 278 ManagePasswordsBubbleModel* manage_passwords_bubble_model,
(...skipping 22 matching lines...) Expand all
284 const autofill::PasswordForm& password_form, bool deleted) { 301 const autofill::PasswordForm& password_form, bool deleted) {
285 Refresh(); 302 Refresh();
286 // After the view is consistent, notify the model that the password needs to 303 // After the view is consistent, notify the model that the password needs to
287 // be updated (either removed or put back into the store, as appropriate. 304 // be updated (either removed or put back into the store, as appropriate.
288 model_->OnPasswordAction(password_form, 305 model_->OnPasswordAction(password_form,
289 deleted 306 deleted
290 ? ManagePasswordsBubbleModel::REMOVE_PASSWORD 307 ? ManagePasswordsBubbleModel::REMOVE_PASSWORD
291 : ManagePasswordsBubbleModel::ADD_PASSWORD); 308 : ManagePasswordsBubbleModel::ADD_PASSWORD);
292 } 309 }
293 310
311 void ManagePasswordItemsView::NotifyAccountForUpdateWasSelected(
312 const autofill::PasswordForm& password_form) {
313 model_->OnUpdateClicked(password_form);
314 }
315
294 void ManagePasswordItemsView::Refresh() { 316 void ManagePasswordItemsView::Refresh() {
295 DCHECK_NE(password_manager::ui::PENDING_PASSWORD_STATE, model_->state()); 317 DCHECK_NE(password_manager::ui::PENDING_PASSWORD_STATE, model_->state());
296 RemoveAllChildViews(true); 318 RemoveAllChildViews(true);
297 AddRows(); 319 AddRows();
298 } 320 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698