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

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

Issue 2960843002: Edit button makes username editable in the password manager bubble. (Closed)
Patch Set: Merge with ToT Created 3 years, 5 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_passwords_bubble_view.h" 5 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/metrics/user_metrics.h" 8 #include "base/metrics/user_metrics.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/timer/timer.h" 10 #include "base/timer/timer.h"
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 void ManagePasswordsBubbleView::AutoSigninView::OnTimer() { 262 void ManagePasswordsBubbleView::AutoSigninView::OnTimer() {
263 parent_->model()->OnAutoSignInToastTimeout(); 263 parent_->model()->OnAutoSignInToastTimeout();
264 parent_->CloseBubble(); 264 parent_->CloseBubble();
265 } 265 }
266 266
267 // ManagePasswordsBubbleView::PendingView ------------------------------------- 267 // ManagePasswordsBubbleView::PendingView -------------------------------------
268 268
269 // A view offering the user the ability to save credentials. Contains a 269 // A view offering the user the ability to save credentials. Contains a
270 // single ManagePasswordItemsView, along with a "Save Passwords" button, 270 // single ManagePasswordItemsView, along with a "Save Passwords" button,
271 // a "Never" button and an "Edit" button to edit username field. 271 // a "Never" button and an "Edit" button to edit username field.
272 class ManagePasswordsBubbleView::PendingView : public views::View, 272 class ManagePasswordsBubbleView::PendingView
273 public views::ButtonListener { 273 : public views::View,
274 public views::ButtonListener,
275 public ManagePasswordItemsView::ManagePasswordItemsDelegate {
274 public: 276 public:
275 explicit PendingView(ManagePasswordsBubbleView* parent); 277 explicit PendingView(ManagePasswordsBubbleView* parent);
276 ~PendingView() override; 278 ~PendingView() override;
277 279
278 private: 280 private:
279 // views::ButtonListener: 281 // views::ButtonListener:
280 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 282 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
281 283
284 // ManagePasswordItemsView::ManagePasswordItemsDelegate:
285 void FocusedOnEditable() override;
286 void FocusLostOnEditable() override;
287
282 ManagePasswordsBubbleView* parent_; 288 ManagePasswordsBubbleView* parent_;
283 289
284 views::Button* edit_button_; 290 views::Button* edit_button_;
285 views::Button* save_button_; 291 views::Button* save_button_;
286 views::Button* never_button_; 292 views::Button* never_button_;
293 ManagePasswordItemsView* manage_password_items_view_;
287 294
288 DISALLOW_COPY_AND_ASSIGN(PendingView); 295 DISALLOW_COPY_AND_ASSIGN(PendingView);
289 }; 296 };
290 297
291 ManagePasswordsBubbleView::PendingView::PendingView( 298 ManagePasswordsBubbleView::PendingView::PendingView(
292 ManagePasswordsBubbleView* parent) 299 ManagePasswordsBubbleView* parent)
293 : parent_(parent), edit_button_(nullptr) { 300 : parent_(parent),
301 edit_button_(nullptr),
302 manage_password_items_view_(nullptr) {
294 views::GridLayout* layout = new views::GridLayout(this); 303 views::GridLayout* layout = new views::GridLayout(this);
295 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); 304 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0));
296 SetLayoutManager(layout); 305 SetLayoutManager(layout);
297 306
298 // Create the pending credential item, save button and refusal combobox. 307 // Create the pending credential item, edit button, save button and refusal
299 ManagePasswordItemsView* item = nullptr; 308 // combobox.
300 if (!parent->model()->pending_password().username_value.empty()) { 309 if (!parent->model()->pending_password().username_value.empty()) {
vasilii 2017/06/30 15:28:07 Actually if it's empty then we should allow to edi
301 item = new ManagePasswordItemsView(parent_->model(), 310 manage_password_items_view_ = new ManagePasswordItemsView(
302 &parent->model()->pending_password()); 311 parent_->model(), &parent->model()->pending_password(), this);
303 } 312 }
304 if (base::FeatureList::IsEnabled( 313 if (base::FeatureList::IsEnabled(
305 password_manager::features::kEnableUsernameCorrection)) { 314 password_manager::features::kEnableUsernameCorrection)) {
315 edit_button_ = views::MdTextButton::CreateSecondaryUiButton(
vasilii 2017/06/30 15:28:07 Broken merge?
irmakk 2017/07/03 14:56:54 Broken merge.
316 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_EDIT_BUTTON));
317 }
318 if (base::FeatureList::IsEnabled(
319 password_manager::features::kEnableUsernameCorrection)) {
306 edit_button_ = views::MdTextButton::CreateSecondaryUiButton( 320 edit_button_ = views::MdTextButton::CreateSecondaryUiButton(
307 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_EDIT_BUTTON)); 321 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_EDIT_BUTTON));
308 } 322 }
309 save_button_ = views::MdTextButton::CreateSecondaryUiBlueButton( 323 save_button_ = views::MdTextButton::CreateSecondaryUiBlueButton(
310 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON)); 324 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON));
311 never_button_ = views::MdTextButton::CreateSecondaryUiButton( 325 never_button_ = views::MdTextButton::CreateSecondaryUiButton(
312 this, 326 this,
313 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_BUBBLE_BLACKLIST_BUTTON)); 327 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_BUBBLE_BLACKLIST_BUTTON));
314 328
315 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); 329 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET);
316 330
317 // Credential row. 331 // Credential row.
318 if (item) { 332 if (manage_password_items_view_) {
319 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); 333 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET);
320 layout->AddView(item); 334 layout->AddView(manage_password_items_view_);
321 layout->AddPaddingRow(0, 335 layout->AddPaddingRow(0,
322 ChromeLayoutProvider::Get() 336 ChromeLayoutProvider::Get()
323 ->GetInsetsMetric(views::INSETS_DIALOG_CONTENTS) 337 ->GetInsetsMetric(views::INSETS_DIALOG_CONTENTS)
324 .bottom()); 338 .bottom());
325 } 339 }
326 340
327 // Button row. 341 // Button row.
328 ColumnSetType column_set_type = 342 ColumnSetType column_set_type =
329 edit_button_ ? TRIPLE_BUTTON_COLUMN_SET : DOUBLE_BUTTON_COLUMN_SET; 343 edit_button_ ? TRIPLE_BUTTON_COLUMN_SET : DOUBLE_BUTTON_COLUMN_SET;
330 BuildColumnSet(layout, column_set_type); 344 BuildColumnSet(layout, column_set_type);
331 layout->StartRow(0, column_set_type); 345 layout->StartRow(0, column_set_type);
332 if (column_set_type == TRIPLE_BUTTON_COLUMN_SET) { 346 if (column_set_type == TRIPLE_BUTTON_COLUMN_SET) {
333 layout->AddView(edit_button_); 347 layout->AddView(edit_button_);
334 } 348 }
335 layout->AddView(save_button_); 349 layout->AddView(save_button_);
336 layout->AddView(never_button_); 350 layout->AddView(never_button_);
337 351
338 parent_->set_initially_focused_view(save_button_); 352 parent_->set_initially_focused_view(save_button_);
339 } 353 }
340 354
341 ManagePasswordsBubbleView::PendingView::~PendingView() { 355 ManagePasswordsBubbleView::PendingView::~PendingView() {
342 } 356 }
343 357
344 void ManagePasswordsBubbleView::PendingView::ButtonPressed( 358 void ManagePasswordsBubbleView::PendingView::ButtonPressed(
345 views::Button* sender, 359 views::Button* sender,
346 const ui::Event& event) { 360 const ui::Event& event) {
347 // TODO(https://crbug.com/734965): Implement edit button logic. 361 // TODO(https://crbug.com/734965): Implement edit button logic.
348 if (sender == edit_button_) { 362 if (sender == edit_button_) {
363 manage_password_items_view_->SetRowStatusForPendingViewRow(
364 ManagePasswordItemsView::RowStatus::EDITING);
365 edit_button_->SetEnabled(false);
349 return; 366 return;
350 } else if (sender == save_button_) { 367 } else if (sender == save_button_) {
351 parent_->model()->OnSaveClicked(); 368 parent_->model()->OnSaveClicked();
352 if (parent_->model()->ReplaceToShowPromotionIfNeeded()) { 369 if (parent_->model()->ReplaceToShowPromotionIfNeeded()) {
353 parent_->Refresh(); 370 parent_->Refresh();
354 return; 371 return;
355 } 372 }
356 } else if (sender == never_button_) { 373 } else if (sender == never_button_) {
357 parent_->model()->OnNeverForThisSiteClicked(); 374 parent_->model()->OnNeverForThisSiteClicked();
358 } else { 375 } else {
359 NOTREACHED(); 376 NOTREACHED();
360 } 377 }
361 378
362 parent_->CloseBubble(); 379 parent_->CloseBubble();
363 } 380 }
364 381
382 void ManagePasswordsBubbleView::PendingView::FocusedOnEditable() {
vasilii 2017/06/30 15:28:07 We don't need this method. We can call SizeToConte
383 parent_->SizeToContents();
384 }
385
386 void ManagePasswordsBubbleView::PendingView::FocusLostOnEditable() {
387 edit_button_->SetEnabled(true);
388 GetFocusManager()->SetFocusedView(save_button_);
vasilii 2017/06/30 15:28:07 What happens if you click something outside of the
389 }
390
365 // ManagePasswordsBubbleView::ManageView -------------------------------------- 391 // ManagePasswordsBubbleView::ManageView --------------------------------------
366 392
367 // A view offering the user a list of their currently saved credentials 393 // A view offering the user a list of their currently saved credentials
368 // for the current page, along with a "Manage passwords" link and a 394 // for the current page, along with a "Manage passwords" link and a
369 // "Done" button. 395 // "Done" button.
370 class ManagePasswordsBubbleView::ManageView : public views::View, 396 class ManagePasswordsBubbleView::ManageView : public views::View,
371 public views::ButtonListener, 397 public views::ButtonListener,
372 public views::LinkListener { 398 public views::LinkListener {
373 public: 399 public:
374 explicit ManageView(ManagePasswordsBubbleView* parent); 400 explicit ManageView(ManagePasswordsBubbleView* parent);
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 } else if (model_.state() == 905 } else if (model_.state() ==
880 password_manager::ui::CHROME_DESKTOP_IOS_PROMO_STATE) { 906 password_manager::ui::CHROME_DESKTOP_IOS_PROMO_STATE) {
881 AddChildView(new DesktopIOSPromotionBubbleView( 907 AddChildView(new DesktopIOSPromotionBubbleView(
882 model_.GetProfile(), 908 model_.GetProfile(),
883 desktop_ios_promotion::PromotionEntryPoint::SAVE_PASSWORD_BUBBLE)); 909 desktop_ios_promotion::PromotionEntryPoint::SAVE_PASSWORD_BUBBLE));
884 #endif 910 #endif
885 } else { 911 } else {
886 AddChildView(new ManageView(this)); 912 AddChildView(new ManageView(this));
887 } 913 }
888 } 914 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698