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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 : public views::View, | 179 : public views::View, |
180 public views::ButtonListener { | 180 public views::ButtonListener { |
181 public: | 181 public: |
182 explicit AccountChooserView(ManagePasswordsBubbleView* parent); | 182 explicit AccountChooserView(ManagePasswordsBubbleView* parent); |
183 ~AccountChooserView() override; | 183 ~AccountChooserView() override; |
184 | 184 |
185 private: | 185 private: |
186 // views::ButtonListener: | 186 // views::ButtonListener: |
187 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 187 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
188 | 188 |
189 // Adds |password_forms| to the |layout| remembering their |type|. | |
190 void AddCredentialItemsWithState( | |
vasilii
2015/01/21 17:47:35
What is the meaning of State here?
With type proba
melandory
2015/01/22 10:47:34
Done.
| |
191 views::GridLayout* layout, | |
vasilii
2015/01/21 17:47:35
nit: I think you can extract it with GetLayoutMana
melandory
2015/01/22 10:47:34
Then I need to cast it to GridLayout. I do not lik
| |
192 const ScopedVector<autofill::PasswordForm>& password_forms, | |
193 password_manager::CredentialType type); | |
194 | |
189 ManagePasswordsBubbleView* parent_; | 195 ManagePasswordsBubbleView* parent_; |
190 views::LabelButton* cancel_button_; | 196 views::LabelButton* cancel_button_; |
191 }; | 197 }; |
192 | 198 |
193 ManagePasswordsBubbleView::AccountChooserView::AccountChooserView( | 199 ManagePasswordsBubbleView::AccountChooserView::AccountChooserView( |
194 ManagePasswordsBubbleView* parent) | 200 ManagePasswordsBubbleView* parent) |
195 : parent_(parent) { | 201 : parent_(parent) { |
196 views::GridLayout* layout = new views::GridLayout(this); | 202 views::GridLayout* layout = new views::GridLayout(this); |
197 SetLayoutManager(layout); | 203 SetLayoutManager(layout); |
198 | 204 |
199 cancel_button_ = | 205 cancel_button_ = |
200 new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_CANCEL)); | 206 new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_CANCEL)); |
201 cancel_button_->SetStyle(views::Button::STYLE_BUTTON); | 207 cancel_button_->SetStyle(views::Button::STYLE_BUTTON); |
202 cancel_button_->SetFontList( | 208 cancel_button_->SetFontList( |
203 ui::ResourceBundle::GetSharedInstance().GetFontList( | 209 ui::ResourceBundle::GetSharedInstance().GetFontList( |
204 ui::ResourceBundle::SmallFont)); | 210 ui::ResourceBundle::SmallFont)); |
205 | 211 |
206 // Title row. | 212 // Title row. |
207 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | 213 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
208 AddTitleRow(layout, parent_->model()); | 214 AddTitleRow(layout, parent_->model()); |
209 | 215 |
210 const auto& pending_credentials = parent_->model()->pending_credentials(); | 216 AddCredentialItemsWithState( |
211 for (autofill::PasswordForm* form : pending_credentials) { | 217 layout, parent_->model()->local_pending_credentials(), |
212 CredentialsItemView* credential_view = new CredentialsItemView(this, *form); | 218 password_manager::CredentialType::CREDENTIAL_TYPE_LOCAL); |
213 // Add the title to the layout with appropriate padding. | 219 |
214 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | 220 AddCredentialItemsWithState( |
215 layout->AddView(credential_view); | 221 layout, parent_->model()->federated_pending_credentials(), |
216 } | 222 password_manager::CredentialType::CREDENTIAL_TYPE_FEDERATED); |
217 | 223 |
218 // Button row. | 224 // Button row. |
219 BuildColumnSet(layout, SINGLE_BUTTON_COLUMN_SET); | 225 BuildColumnSet(layout, SINGLE_BUTTON_COLUMN_SET); |
220 layout->StartRowWithPadding( | 226 layout->StartRowWithPadding( |
221 0, SINGLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); | 227 0, SINGLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); |
222 layout->AddView(cancel_button_); | 228 layout->AddView(cancel_button_); |
223 | 229 |
224 // Extra padding for visual awesomeness. | 230 // Extra padding for visual awesomeness. |
225 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 231 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
226 | 232 |
227 parent_->set_initially_focused_view(cancel_button_); | 233 parent_->set_initially_focused_view(cancel_button_); |
228 } | 234 } |
229 | 235 |
230 ManagePasswordsBubbleView::AccountChooserView::~AccountChooserView() { | 236 ManagePasswordsBubbleView::AccountChooserView::~AccountChooserView() { |
231 } | 237 } |
232 | 238 |
239 void ManagePasswordsBubbleView::AccountChooserView::AddCredentialItemsWithState( | |
240 views::GridLayout* layout, | |
241 const ScopedVector<autofill::PasswordForm>& password_forms, | |
242 password_manager::CredentialType type) { | |
243 for (autofill::PasswordForm* form : password_forms) { | |
244 // Add the title to the layout with appropriate padding. | |
245 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | |
246 layout->AddView(new CredentialsItemView(this, *form, type)); | |
247 } | |
248 } | |
249 | |
233 void ManagePasswordsBubbleView::AccountChooserView::ButtonPressed( | 250 void ManagePasswordsBubbleView::AccountChooserView::ButtonPressed( |
234 views::Button* sender, const ui::Event& event) { | 251 views::Button* sender, const ui::Event& event) { |
235 if (sender != cancel_button_) { | 252 if (sender != cancel_button_) { |
236 // ManagePasswordsBubbleModel should care about calling a callback in case | 253 // ManagePasswordsBubbleModel should care about calling a callback in case |
237 // the bubble is dismissed by any other means. | 254 // the bubble is dismissed by any other means. |
238 CredentialsItemView* view = static_cast<CredentialsItemView*>(sender); | 255 CredentialsItemView* view = static_cast<CredentialsItemView*>(sender); |
239 parent_->model()->OnChooseCredentials(view->form()); | 256 parent_->model()->OnChooseCredentials(view->form(), |
257 view->credential_type()); | |
240 } else { | 258 } else { |
241 parent_->model()->OnNopeClicked(); | 259 parent_->model()->OnNopeClicked(); |
242 } | 260 } |
243 parent_->Close(); | 261 parent_->Close(); |
244 } | 262 } |
245 | 263 |
246 // ManagePasswordsBubbleView::AskUserToSubmitURLView ------------------------- | 264 // ManagePasswordsBubbleView::AskUserToSubmitURLView ------------------------- |
247 | 265 |
248 // Asks users if they want to report the URL when the password manager failed | 266 // Asks users if they want to report the URL when the password manager failed |
249 // to detect the form. View has following structure: | 267 // to detect the form. View has following structure: |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
970 | 988 |
971 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { | 989 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { |
972 if (model()->best_matches().empty()) { | 990 if (model()->best_matches().empty()) { |
973 // Skip confirmation if there are no existing passwords for this site. | 991 // Skip confirmation if there are no existing passwords for this site. |
974 NotifyConfirmedNeverForThisSite(); | 992 NotifyConfirmedNeverForThisSite(); |
975 } else { | 993 } else { |
976 model()->OnConfirmationForNeverForThisSite(); | 994 model()->OnConfirmationForNeverForThisSite(); |
977 Refresh(); | 995 Refresh(); |
978 } | 996 } |
979 } | 997 } |
OLD | NEW |