Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(546)

Side by Side Diff: chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc

Issue 733463003: Show user credentials chooser bubble. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Aura compilation Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.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/fullscreen/fullscreen_controller.h" 10 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_CANCEL)); 202 new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_CANCEL));
203 cancel_button_->SetStyle(views::Button::STYLE_BUTTON); 203 cancel_button_->SetStyle(views::Button::STYLE_BUTTON);
204 cancel_button_->SetFontList( 204 cancel_button_->SetFontList(
205 ui::ResourceBundle::GetSharedInstance().GetFontList( 205 ui::ResourceBundle::GetSharedInstance().GetFontList(
206 ui::ResourceBundle::SmallFont)); 206 ui::ResourceBundle::SmallFont));
207 207
208 // Title row. 208 // Title row.
209 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); 209 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET);
210 AddTitleRow(layout, parent_->model()); 210 AddTitleRow(layout, parent_->model());
211 211
212 // TODO(vasilii): this is a stub instead of actual data. We temporary show 2 212 const auto& pending_credentials = parent_->model()->pending_credentials();
213 // credentials. 213 for (autofill::PasswordForm* form : pending_credentials) {
214 for (int i = 0; i < 2; ++i) { 214 CredentialsItemView* credential_view = new CredentialsItemView(this, *form);
215 base::string16 name =
216 l10n_util::GetStringFUTF16Int(IDS_NUMBERED_PROFILE_NAME, i);
217 CredentialsItemView* credential_view = new CredentialsItemView(this, name);
218 // Add the title to the layout with appropriate padding. 215 // Add the title to the layout with appropriate padding.
219 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); 216 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET);
220 layout->AddView(credential_view); 217 layout->AddView(credential_view);
221 } 218 }
222 219
223 // Button row. 220 // Button row.
224 BuildColumnSet(layout, SINGLE_BUTTON_COLUMN_SET); 221 BuildColumnSet(layout, SINGLE_BUTTON_COLUMN_SET);
225 layout->StartRowWithPadding( 222 layout->StartRowWithPadding(
226 0, SINGLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); 223 0, SINGLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing);
227 layout->AddView(cancel_button_); 224 layout->AddView(cancel_button_);
228 225
229 // Extra padding for visual awesomeness. 226 // Extra padding for visual awesomeness.
230 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 227 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
231 228
232 parent_->set_initially_focused_view(cancel_button_); 229 parent_->set_initially_focused_view(cancel_button_);
233 } 230 }
234 231
235 ManagePasswordsBubbleView::AccountChooserView::~AccountChooserView() { 232 ManagePasswordsBubbleView::AccountChooserView::~AccountChooserView() {
236 } 233 }
237 234
238 void ManagePasswordsBubbleView::AccountChooserView::ButtonPressed( 235 void ManagePasswordsBubbleView::AccountChooserView::ButtonPressed(
239 views::Button* sender, const ui::Event& event) { 236 views::Button* sender, const ui::Event& event) {
237 if (sender != cancel_button_) {
238 // ManagePasswordsBubbleModel should care about calling a callback in case
239 // the bubble is dismissed by any other means.
240 CredentialsItemView* view = static_cast<CredentialsItemView*>(sender);
241 parent_->model()->OnChooseCredentials(view->form());
242 } else {
243 parent_->model()->OnNopeClicked();
244 }
240 parent_->Close(); 245 parent_->Close();
241 } 246 }
242 247
243 // ManagePasswordsBubbleView::PendingView ------------------------------------- 248 // ManagePasswordsBubbleView::PendingView -------------------------------------
244 249
245 // A view offering the user the ability to save credentials. Contains a 250 // A view offering the user the ability to save credentials. Contains a
246 // single ManagePasswordItemView, along with a "Save Passwords" button 251 // single ManagePasswordItemView, along with a "Save Passwords" button
247 // and a rejection combobox. 252 // and a rejection combobox.
248 class ManagePasswordsBubbleView::PendingView : public views::View, 253 class ManagePasswordsBubbleView::PendingView : public views::View,
249 public views::ButtonListener, 254 public views::ButtonListener,
(...skipping 24 matching lines...) Expand all
274 ManagePasswordsBubbleView::PendingView::PendingView( 279 ManagePasswordsBubbleView::PendingView::PendingView(
275 ManagePasswordsBubbleView* parent) 280 ManagePasswordsBubbleView* parent)
276 : parent_(parent) { 281 : parent_(parent) {
277 views::GridLayout* layout = new views::GridLayout(this); 282 views::GridLayout* layout = new views::GridLayout(this);
278 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); 283 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0));
279 SetLayoutManager(layout); 284 SetLayoutManager(layout);
280 285
281 // Create the pending credential item, save button and refusal combobox. 286 // Create the pending credential item, save button and refusal combobox.
282 ManagePasswordItemView* item = 287 ManagePasswordItemView* item =
283 new ManagePasswordItemView(parent->model(), 288 new ManagePasswordItemView(parent->model(),
284 parent->model()->pending_credentials(), 289 parent->model()->pending_password(),
285 password_manager::ui::FIRST_ITEM); 290 password_manager::ui::FIRST_ITEM);
286 save_button_ = new views::BlueButton( 291 save_button_ = new views::BlueButton(
287 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON)); 292 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON));
288 save_button_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( 293 save_button_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList(
289 ui::ResourceBundle::SmallFont)); 294 ui::ResourceBundle::SmallFont));
290 295
291 combobox_model_.reset(new SavePasswordRefusalComboboxModel()); 296 combobox_model_.reset(new SavePasswordRefusalComboboxModel());
292 refuse_combobox_.reset(new views::Combobox(combobox_model_.get())); 297 refuse_combobox_.reset(new views::Combobox(combobox_model_.get()));
293 refuse_combobox_->set_listener(this); 298 refuse_combobox_->set_listener(this);
294 refuse_combobox_->SetStyle(views::Combobox::STYLE_ACTION); 299 refuse_combobox_->SetStyle(views::Combobox::STYLE_ACTION);
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 initially_focused_view_ = NULL; 886 initially_focused_view_ = NULL;
882 if (password_manager::ui::IsPendingState(model()->state())) { 887 if (password_manager::ui::IsPendingState(model()->state())) {
883 if (never_save_passwords_) 888 if (never_save_passwords_)
884 AddChildView(new ConfirmNeverView(this)); 889 AddChildView(new ConfirmNeverView(this));
885 else 890 else
886 AddChildView(new PendingView(this)); 891 AddChildView(new PendingView(this));
887 } else if (model()->state() == password_manager::ui::BLACKLIST_STATE) { 892 } else if (model()->state() == password_manager::ui::BLACKLIST_STATE) {
888 AddChildView(new BlacklistedView(this)); 893 AddChildView(new BlacklistedView(this));
889 } else if (model()->state() == password_manager::ui::CONFIRMATION_STATE) { 894 } else if (model()->state() == password_manager::ui::CONFIRMATION_STATE) {
890 AddChildView(new SaveConfirmationView(this)); 895 AddChildView(new SaveConfirmationView(this));
896 } else if (model()->state() ==
897 password_manager::ui::CREDENTIAL_REQUEST_STATE) {
898 AddChildView(new AccountChooserView(this));
891 } else { 899 } else {
892 AddChildView(new ManageView(this)); 900 AddChildView(new ManageView(this));
893 } 901 }
894 GetLayoutManager()->Layout(this); 902 GetLayoutManager()->Layout(this);
895 } 903 }
896 904
897 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { 905 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() {
898 if (model()->best_matches().empty()) { 906 if (model()->best_matches().empty()) {
899 // Skip confirmation if there are no existing passwords for this site. 907 // Skip confirmation if there are no existing passwords for this site.
900 NotifyConfirmedNeverForThisSite(); 908 NotifyConfirmedNeverForThisSite();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 } 941 }
934 942
935 void ManagePasswordsBubbleView::Observe( 943 void ManagePasswordsBubbleView::Observe(
936 int type, 944 int type,
937 const content::NotificationSource& source, 945 const content::NotificationSource& source,
938 const content::NotificationDetails& details) { 946 const content::NotificationDetails& details) {
939 DCHECK_EQ(type, chrome::NOTIFICATION_FULLSCREEN_CHANGED); 947 DCHECK_EQ(type, chrome::NOTIFICATION_FULLSCREEN_CHANGED);
940 GetWidget()->SetVisibilityAnimationTransition(views::Widget::ANIMATE_NONE); 948 GetWidget()->SetVisibilityAnimationTransition(views::Widget::ANIMATE_NONE);
941 CloseBubble(); 949 CloseBubble();
942 } 950 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698