| 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/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/browser_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
| 10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 : public views::View, | 180 : public views::View, |
| 181 public views::ButtonListener { | 181 public views::ButtonListener { |
| 182 public: | 182 public: |
| 183 explicit AccountChooserView(ManagePasswordsBubbleView* parent); | 183 explicit AccountChooserView(ManagePasswordsBubbleView* parent); |
| 184 ~AccountChooserView() override; | 184 ~AccountChooserView() override; |
| 185 | 185 |
| 186 private: | 186 private: |
| 187 // views::ButtonListener: | 187 // views::ButtonListener: |
| 188 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 188 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 189 | 189 |
| 190 // Adds |password_forms| to the layout remembering their |type|. |
| 191 void AddCredentialItemsWithType( |
| 192 views::GridLayout* layout, |
| 193 const ScopedVector<autofill::PasswordForm>& password_forms, |
| 194 password_manager::CredentialType type); |
| 195 |
| 190 ManagePasswordsBubbleView* parent_; | 196 ManagePasswordsBubbleView* parent_; |
| 191 views::LabelButton* cancel_button_; | 197 views::LabelButton* cancel_button_; |
| 192 }; | 198 }; |
| 193 | 199 |
| 194 ManagePasswordsBubbleView::AccountChooserView::AccountChooserView( | 200 ManagePasswordsBubbleView::AccountChooserView::AccountChooserView( |
| 195 ManagePasswordsBubbleView* parent) | 201 ManagePasswordsBubbleView* parent) |
| 196 : parent_(parent) { | 202 : parent_(parent) { |
| 197 views::GridLayout* layout = new views::GridLayout(this); | 203 views::GridLayout* layout = new views::GridLayout(this); |
| 198 SetLayoutManager(layout); | 204 SetLayoutManager(layout); |
| 199 | 205 |
| 200 cancel_button_ = | 206 cancel_button_ = |
| 201 new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_CANCEL)); | 207 new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_CANCEL)); |
| 202 cancel_button_->SetStyle(views::Button::STYLE_BUTTON); | 208 cancel_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 203 cancel_button_->SetFontList( | 209 cancel_button_->SetFontList( |
| 204 ui::ResourceBundle::GetSharedInstance().GetFontList( | 210 ui::ResourceBundle::GetSharedInstance().GetFontList( |
| 205 ui::ResourceBundle::SmallFont)); | 211 ui::ResourceBundle::SmallFont)); |
| 206 | 212 |
| 207 // Title row. | 213 // Title row. |
| 208 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | 214 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
| 209 AddTitleRow(layout, parent_->model()); | 215 AddTitleRow(layout, parent_->model()); |
| 210 | 216 |
| 211 const auto& pending_credentials = parent_->model()->pending_credentials(); | 217 AddCredentialItemsWithType( |
| 212 net::URLRequestContextGetter* request_context = | 218 layout, parent_->model()->local_pending_credentials(), |
| 213 parent_->model()->GetProfile()->GetRequestContext(); | 219 password_manager::CredentialType::CREDENTIAL_TYPE_LOCAL); |
| 214 for (autofill::PasswordForm* form : pending_credentials) { | 220 |
| 215 CredentialsItemView* credential_view = | 221 AddCredentialItemsWithType( |
| 216 new CredentialsItemView(this, *form, request_context); | 222 layout, parent_->model()->federated_pending_credentials(), |
| 217 // Add the title to the layout with appropriate padding. | 223 password_manager::CredentialType::CREDENTIAL_TYPE_FEDERATED); |
| 218 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | |
| 219 layout->AddView(credential_view); | |
| 220 } | |
| 221 | 224 |
| 222 // Button row. | 225 // Button row. |
| 223 BuildColumnSet(layout, SINGLE_BUTTON_COLUMN_SET); | 226 BuildColumnSet(layout, SINGLE_BUTTON_COLUMN_SET); |
| 224 layout->StartRowWithPadding( | 227 layout->StartRowWithPadding( |
| 225 0, SINGLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); | 228 0, SINGLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); |
| 226 layout->AddView(cancel_button_); | 229 layout->AddView(cancel_button_); |
| 227 | 230 |
| 228 // Extra padding for visual awesomeness. | 231 // Extra padding for visual awesomeness. |
| 229 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 232 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 230 | 233 |
| 231 parent_->set_initially_focused_view(cancel_button_); | 234 parent_->set_initially_focused_view(cancel_button_); |
| 232 } | 235 } |
| 233 | 236 |
| 234 ManagePasswordsBubbleView::AccountChooserView::~AccountChooserView() { | 237 ManagePasswordsBubbleView::AccountChooserView::~AccountChooserView() { |
| 235 } | 238 } |
| 236 | 239 |
| 240 void ManagePasswordsBubbleView::AccountChooserView::AddCredentialItemsWithType( |
| 241 views::GridLayout* layout, |
| 242 const ScopedVector<autofill::PasswordForm>& password_forms, |
| 243 password_manager::CredentialType type) { |
| 244 net::URLRequestContextGetter* request_context = |
| 245 parent_->model()->GetProfile()->GetRequestContext(); |
| 246 for (autofill::PasswordForm* form : password_forms) { |
| 247 // Add the title to the layout with appropriate padding. |
| 248 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
| 249 layout->AddView( |
| 250 new CredentialsItemView(this, *form, type, request_context)); |
| 251 } |
| 252 } |
| 253 |
| 237 void ManagePasswordsBubbleView::AccountChooserView::ButtonPressed( | 254 void ManagePasswordsBubbleView::AccountChooserView::ButtonPressed( |
| 238 views::Button* sender, const ui::Event& event) { | 255 views::Button* sender, const ui::Event& event) { |
| 239 if (sender != cancel_button_) { | 256 if (sender != cancel_button_) { |
| 240 // ManagePasswordsBubbleModel should care about calling a callback in case | 257 // ManagePasswordsBubbleModel should care about calling a callback in case |
| 241 // the bubble is dismissed by any other means. | 258 // the bubble is dismissed by any other means. |
| 242 CredentialsItemView* view = static_cast<CredentialsItemView*>(sender); | 259 CredentialsItemView* view = static_cast<CredentialsItemView*>(sender); |
| 243 parent_->model()->OnChooseCredentials(view->form()); | 260 parent_->model()->OnChooseCredentials(view->form(), |
| 261 view->credential_type()); |
| 244 } else { | 262 } else { |
| 245 parent_->model()->OnNopeClicked(); | 263 parent_->model()->OnNopeClicked(); |
| 246 } | 264 } |
| 247 parent_->Close(); | 265 parent_->Close(); |
| 248 } | 266 } |
| 249 | 267 |
| 250 // ManagePasswordsBubbleView::AskUserToSubmitURLView ------------------------- | 268 // ManagePasswordsBubbleView::AskUserToSubmitURLView ------------------------- |
| 251 | 269 |
| 252 // Asks users if they want to report the URL when the password manager failed | 270 // Asks users if they want to report the URL when the password manager failed |
| 253 // to detect the form. View has following structure: | 271 // to detect the form. View has following structure: |
| (...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 | 992 |
| 975 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { | 993 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { |
| 976 if (model()->best_matches().empty()) { | 994 if (model()->best_matches().empty()) { |
| 977 // Skip confirmation if there are no existing passwords for this site. | 995 // Skip confirmation if there are no existing passwords for this site. |
| 978 NotifyConfirmedNeverForThisSite(); | 996 NotifyConfirmedNeverForThisSite(); |
| 979 } else { | 997 } else { |
| 980 model()->OnConfirmationForNeverForThisSite(); | 998 model()->OnConfirmationForNeverForThisSite(); |
| 981 Refresh(); | 999 Refresh(); |
| 982 } | 1000 } |
| 983 } | 1001 } |
| OLD | NEW |