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_items_with_state = [&layout, this]( |
vasilii
2015/01/16 14:07:26
Why don't you write a private method given that yo
melandory
2015/01/19 15:40:15
I thought since this routine is used only by one m
| |
211 for (autofill::PasswordForm* form : pending_credentials) { | 211 const ScopedVector<autofill::PasswordForm>& password_forms, |
212 CredentialsItemView* credential_view = new CredentialsItemView(this, *form); | 212 password_manager::CredentialType type) { |
213 // Add the title to the layout with appropriate padding. | 213 for (autofill::PasswordForm* form : password_forms) { |
214 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | 214 // Add the title to the layout with appropriate padding. |
215 layout->AddView(credential_view); | 215 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
216 } | 216 layout->AddView(new CredentialsItemView(this, *form, type)); |
217 } | |
218 }; | |
219 | |
220 add_credential_items_with_state( | |
221 parent_->model()->local_pending_credentials(), | |
222 password_manager::CredentialType::CREDENTIAL_TYPE_LOCAL); | |
223 | |
224 add_credential_items_with_state( | |
225 parent_->model()->federated_pending_credentials(), | |
226 password_manager::CredentialType::CREDENTIAL_TYPE_FEDERATED); | |
217 | 227 |
218 // Button row. | 228 // Button row. |
219 BuildColumnSet(layout, SINGLE_BUTTON_COLUMN_SET); | 229 BuildColumnSet(layout, SINGLE_BUTTON_COLUMN_SET); |
220 layout->StartRowWithPadding( | 230 layout->StartRowWithPadding( |
221 0, SINGLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); | 231 0, SINGLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); |
222 layout->AddView(cancel_button_); | 232 layout->AddView(cancel_button_); |
223 | 233 |
224 // Extra padding for visual awesomeness. | 234 // Extra padding for visual awesomeness. |
225 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 235 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
226 | 236 |
227 parent_->set_initially_focused_view(cancel_button_); | 237 parent_->set_initially_focused_view(cancel_button_); |
228 } | 238 } |
229 | 239 |
230 ManagePasswordsBubbleView::AccountChooserView::~AccountChooserView() { | 240 ManagePasswordsBubbleView::AccountChooserView::~AccountChooserView() { |
231 } | 241 } |
232 | 242 |
233 void ManagePasswordsBubbleView::AccountChooserView::ButtonPressed( | 243 void ManagePasswordsBubbleView::AccountChooserView::ButtonPressed( |
234 views::Button* sender, const ui::Event& event) { | 244 views::Button* sender, const ui::Event& event) { |
235 if (sender != cancel_button_) { | 245 if (sender != cancel_button_) { |
236 // ManagePasswordsBubbleModel should care about calling a callback in case | 246 // ManagePasswordsBubbleModel should care about calling a callback in case |
237 // the bubble is dismissed by any other means. | 247 // the bubble is dismissed by any other means. |
238 CredentialsItemView* view = static_cast<CredentialsItemView*>(sender); | 248 CredentialsItemView* view = static_cast<CredentialsItemView*>(sender); |
239 parent_->model()->OnChooseCredentials(view->form()); | 249 parent_->model()->OnChooseCredentials(view->form(), |
250 view->credential_type()); | |
240 } else { | 251 } else { |
241 parent_->model()->OnNopeClicked(); | 252 parent_->model()->OnNopeClicked(); |
242 } | 253 } |
243 parent_->Close(); | 254 parent_->Close(); |
244 } | 255 } |
245 | 256 |
246 // ManagePasswordsBubbleView::AskUserToSubmitURLView ------------------------- | 257 // ManagePasswordsBubbleView::AskUserToSubmitURLView ------------------------- |
247 | 258 |
248 // Asks users if they want to report the URL when the password manager failed | 259 // Asks users if they want to report the URL when the password manager failed |
249 // to detect the form. View has following structure: | 260 // to detect the form. View has following structure: |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
970 | 981 |
971 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { | 982 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { |
972 if (model()->best_matches().empty()) { | 983 if (model()->best_matches().empty()) { |
973 // Skip confirmation if there are no existing passwords for this site. | 984 // Skip confirmation if there are no existing passwords for this site. |
974 NotifyConfirmedNeverForThisSite(); | 985 NotifyConfirmedNeverForThisSite(); |
975 } else { | 986 } else { |
976 model()->OnConfirmationForNeverForThisSite(); | 987 model()->OnConfirmationForNeverForThisSite(); |
977 Refresh(); | 988 Refresh(); |
978 } | 989 } |
979 } | 990 } |
OLD | NEW |