| 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 "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
| 8 #include "chrome/browser/ui/browser_finder.h" | 8 #include "chrome/browser/ui/browser_finder.h" |
| 9 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 9 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
| 10 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" | 10 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_CANCEL)); | 200 new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_CANCEL)); |
| 201 cancel_button_->SetStyle(views::Button::STYLE_BUTTON); | 201 cancel_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 202 cancel_button_->SetFontList( | 202 cancel_button_->SetFontList( |
| 203 ui::ResourceBundle::GetSharedInstance().GetFontList( | 203 ui::ResourceBundle::GetSharedInstance().GetFontList( |
| 204 ui::ResourceBundle::SmallFont)); | 204 ui::ResourceBundle::SmallFont)); |
| 205 | 205 |
| 206 // Title row. | 206 // Title row. |
| 207 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | 207 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
| 208 AddTitleRow(layout, parent_->model()); | 208 AddTitleRow(layout, parent_->model()); |
| 209 | 209 |
| 210 const auto& pending_credentials = parent_->model()->pending_credentials(); | 210 auto add_credential_item_with_state = |
| 211 for (autofill::PasswordForm* form : pending_credentials) { | 211 [&layout, this](const autofill::PasswordForm& form, |
| 212 CredentialsItemView* credential_view = new CredentialsItemView(this, *form); | 212 password_manager::CredentialType type) { |
| 213 // Add the title to the layout with appropriate padding. | 213 // Add the title to the layout with appropriate padding. |
| 214 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | 214 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
| 215 layout->AddView(credential_view); | 215 layout->AddView(new CredentialsItemView(this, form, type)); |
| 216 }; |
| 217 |
| 218 for (autofill::PasswordForm* form : |
| 219 parent_->model()->local_pending_credentials()) { |
| 220 add_credential_item_with_state( |
| 221 *form, password_manager::CredentialType::CREDENTIAL_TYPE_LOCAL); |
| 222 } |
| 223 |
| 224 for (autofill::PasswordForm* form : |
| 225 parent_->model()->federated_pending_credentials()) { |
| 226 add_credential_item_with_state( |
| 227 *form, password_manager::CredentialType::CREDENTIAL_TYPE_FEDERATED); |
| 216 } | 228 } |
| 217 | 229 |
| 218 // Button row. | 230 // Button row. |
| 219 BuildColumnSet(layout, SINGLE_BUTTON_COLUMN_SET); | 231 BuildColumnSet(layout, SINGLE_BUTTON_COLUMN_SET); |
| 220 layout->StartRowWithPadding( | 232 layout->StartRowWithPadding( |
| 221 0, SINGLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); | 233 0, SINGLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); |
| 222 layout->AddView(cancel_button_); | 234 layout->AddView(cancel_button_); |
| 223 | 235 |
| 224 // Extra padding for visual awesomeness. | 236 // Extra padding for visual awesomeness. |
| 225 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 237 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 226 | 238 |
| 227 parent_->set_initially_focused_view(cancel_button_); | 239 parent_->set_initially_focused_view(cancel_button_); |
| 228 } | 240 } |
| 229 | 241 |
| 230 ManagePasswordsBubbleView::AccountChooserView::~AccountChooserView() { | 242 ManagePasswordsBubbleView::AccountChooserView::~AccountChooserView() { |
| 231 } | 243 } |
| 232 | 244 |
| 233 void ManagePasswordsBubbleView::AccountChooserView::ButtonPressed( | 245 void ManagePasswordsBubbleView::AccountChooserView::ButtonPressed( |
| 234 views::Button* sender, const ui::Event& event) { | 246 views::Button* sender, const ui::Event& event) { |
| 235 if (sender != cancel_button_) { | 247 if (sender != cancel_button_) { |
| 236 // ManagePasswordsBubbleModel should care about calling a callback in case | 248 // ManagePasswordsBubbleModel should care about calling a callback in case |
| 237 // the bubble is dismissed by any other means. | 249 // the bubble is dismissed by any other means. |
| 238 CredentialsItemView* view = static_cast<CredentialsItemView*>(sender); | 250 CredentialsItemView* view = static_cast<CredentialsItemView*>(sender); |
| 239 parent_->model()->OnChooseCredentials(view->form()); | 251 parent_->model()->OnChooseCredentials(view->form(), |
| 252 view->credential_type()); |
| 240 } else { | 253 } else { |
| 241 parent_->model()->OnNopeClicked(); | 254 parent_->model()->OnNopeClicked(); |
| 242 } | 255 } |
| 243 parent_->Close(); | 256 parent_->Close(); |
| 244 } | 257 } |
| 245 | 258 |
| 246 // ManagePasswordsBubbleView::AskUserToSubmitURLView ------------------------- | 259 // ManagePasswordsBubbleView::AskUserToSubmitURLView ------------------------- |
| 247 | 260 |
| 248 // Asks users if they want to report the URL when the password manager failed | 261 // Asks users if they want to report the URL when the password manager failed |
| 249 // to detect the form. View has following structure: | 262 // to detect the form. View has following structure: |
| (...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 | 983 |
| 971 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { | 984 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { |
| 972 if (model()->best_matches().empty()) { | 985 if (model()->best_matches().empty()) { |
| 973 // Skip confirmation if there are no existing passwords for this site. | 986 // Skip confirmation if there are no existing passwords for this site. |
| 974 NotifyConfirmedNeverForThisSite(); | 987 NotifyConfirmedNeverForThisSite(); |
| 975 } else { | 988 } else { |
| 976 model()->OnConfirmationForNeverForThisSite(); | 989 model()->OnConfirmationForNeverForThisSite(); |
| 977 Refresh(); | 990 Refresh(); |
| 978 } | 991 } |
| 979 } | 992 } |
| OLD | NEW |