| 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_passwords_bubble_view.h" | 5 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" |
| 6 | 6 |
| 7 #include "base/timer/timer.h" | 7 #include "base/timer/timer.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_finder.h" | 10 #include "chrome/browser/ui/browser_finder.h" |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 ManagePasswordsBubbleView* parent) | 263 ManagePasswordsBubbleView* parent) |
| 264 : parent_(parent) { | 264 : parent_(parent) { |
| 265 SetLayoutManager(new views::FillLayout); | 265 SetLayoutManager(new views::FillLayout); |
| 266 CredentialsItemView* credential = new CredentialsItemView( | 266 CredentialsItemView* credential = new CredentialsItemView( |
| 267 this, | 267 this, |
| 268 &parent_->model()->pending_password(), | 268 &parent_->model()->pending_password(), |
| 269 password_manager::CredentialType::CREDENTIAL_TYPE_LOCAL, | 269 password_manager::CredentialType::CREDENTIAL_TYPE_LOCAL, |
| 270 CredentialsItemView::AUTO_SIGNIN, | 270 CredentialsItemView::AUTO_SIGNIN, |
| 271 parent_->model()->GetProfile()->GetRequestContext()); | 271 parent_->model()->GetProfile()->GetRequestContext()); |
| 272 AddChildView(credential); | 272 AddChildView(credential); |
| 273 // TODO(vasilii): enable the button to switch to the "Managed" state. | |
| 274 credential->SetEnabled(false); | |
| 275 parent_->set_initially_focused_view(credential); | 273 parent_->set_initially_focused_view(credential); |
| 276 | 274 |
| 277 timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kAutoSigninToastTimeout), | 275 timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kAutoSigninToastTimeout), |
| 278 this, &AutoSigninView::OnTimer); | 276 this, &AutoSigninView::OnTimer); |
| 279 } | 277 } |
| 280 | 278 |
| 281 void ManagePasswordsBubbleView::AutoSigninView::ButtonPressed( | 279 void ManagePasswordsBubbleView::AutoSigninView::ButtonPressed( |
| 282 views::Button* sender, const ui::Event& event) { | 280 views::Button* sender, const ui::Event& event) { |
| 283 // TODO(vasilii): close the toast and switch to the "Managed" state. | 281 parent_->model()->OnAutoSignInClicked(); |
| 282 parent_->Close(); |
| 284 } | 283 } |
| 285 | 284 |
| 286 void ManagePasswordsBubbleView::AutoSigninView::OnTimer() { | 285 void ManagePasswordsBubbleView::AutoSigninView::OnTimer() { |
| 287 parent_->model()->OnAutoSignInToastTimeout(); | 286 parent_->model()->OnAutoSignInToastTimeout(); |
| 288 parent_->Close(); | 287 parent_->Close(); |
| 289 } | 288 } |
| 290 | 289 |
| 291 // ManagePasswordsBubbleView::PendingView ------------------------------------- | 290 // ManagePasswordsBubbleView::PendingView ------------------------------------- |
| 292 | 291 |
| 293 // A view offering the user the ability to save credentials. Contains a | 292 // A view offering the user the ability to save credentials. Contains a |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 } else if (model()->state() == password_manager::ui::BLACKLIST_STATE) { | 989 } else if (model()->state() == password_manager::ui::BLACKLIST_STATE) { |
| 991 AddChildView(new BlacklistedView(this)); | 990 AddChildView(new BlacklistedView(this)); |
| 992 } else if (model()->state() == password_manager::ui::CONFIRMATION_STATE) { | 991 } else if (model()->state() == password_manager::ui::CONFIRMATION_STATE) { |
| 993 AddChildView(new SaveConfirmationView(this)); | 992 AddChildView(new SaveConfirmationView(this)); |
| 994 } else if (model()->state() == | 993 } else if (model()->state() == |
| 995 password_manager::ui::CREDENTIAL_REQUEST_STATE) { | 994 password_manager::ui::CREDENTIAL_REQUEST_STATE) { |
| 996 AddChildView(new AccountChooserView(this)); | 995 AddChildView(new AccountChooserView(this)); |
| 997 } else if (model()->state() == password_manager::ui::AUTO_SIGNIN_STATE) { | 996 } else if (model()->state() == password_manager::ui::AUTO_SIGNIN_STATE) { |
| 998 AddChildView(new AutoSigninView(this)); | 997 AddChildView(new AutoSigninView(this)); |
| 999 } else { | 998 } else { |
| 1000 AddChildView(new ManageView(this)); | 999 if (model()->IsNewUIActive()) |
| 1000 AddChildView(new ManageAccountsView(this)); |
| 1001 else |
| 1002 AddChildView(new ManageView(this)); |
| 1001 } | 1003 } |
| 1002 GetLayoutManager()->Layout(this); | 1004 GetLayoutManager()->Layout(this); |
| 1003 } | 1005 } |
| 1004 | 1006 |
| 1005 void ManagePasswordsBubbleView::NotifyConfirmedNeverForThisSite() { | 1007 void ManagePasswordsBubbleView::NotifyConfirmedNeverForThisSite() { |
| 1006 model()->OnNeverForThisSiteClicked(); | 1008 model()->OnNeverForThisSiteClicked(); |
| 1007 Close(); | 1009 Close(); |
| 1008 } | 1010 } |
| 1009 | 1011 |
| 1010 void ManagePasswordsBubbleView::NotifyUndoNeverForThisSite() { | 1012 void ManagePasswordsBubbleView::NotifyUndoNeverForThisSite() { |
| 1011 model()->OnUndoNeverForThisSite(); | 1013 model()->OnUndoNeverForThisSite(); |
| 1012 Refresh(); | 1014 Refresh(); |
| 1013 } | 1015 } |
| 1014 | 1016 |
| 1015 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { | 1017 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { |
| 1016 if (model()->local_credentials().empty()) { | 1018 if (model()->local_credentials().empty()) { |
| 1017 // Skip confirmation if there are no existing passwords for this site. | 1019 // Skip confirmation if there are no existing passwords for this site. |
| 1018 NotifyConfirmedNeverForThisSite(); | 1020 NotifyConfirmedNeverForThisSite(); |
| 1019 } else { | 1021 } else { |
| 1020 model()->OnConfirmationForNeverForThisSite(); | 1022 model()->OnConfirmationForNeverForThisSite(); |
| 1021 Refresh(); | 1023 Refresh(); |
| 1022 } | 1024 } |
| 1023 } | 1025 } |
| OLD | NEW |