| 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/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 Loading... |
| 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 parent_->model()->OnChooseCredetials(false, autofill::PasswordForm()); |
| 239 } else { |
| 240 CredentialsItemView* view = static_cast<CredentialsItemView*>(sender); |
| 241 parent_->model()->OnChooseCredetials(true, view->form()); |
| 242 } |
| 240 parent_->Close(); | 243 parent_->Close(); |
| 241 } | 244 } |
| 242 | 245 |
| 243 // ManagePasswordsBubbleView::PendingView ------------------------------------- | 246 // ManagePasswordsBubbleView::PendingView ------------------------------------- |
| 244 | 247 |
| 245 // A view offering the user the ability to save credentials. Contains a | 248 // A view offering the user the ability to save credentials. Contains a |
| 246 // single ManagePasswordItemView, along with a "Save Passwords" button | 249 // single ManagePasswordItemView, along with a "Save Passwords" button |
| 247 // and a rejection combobox. | 250 // and a rejection combobox. |
| 248 class ManagePasswordsBubbleView::PendingView : public views::View, | 251 class ManagePasswordsBubbleView::PendingView : public views::View, |
| 249 public views::ButtonListener, | 252 public views::ButtonListener, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 274 ManagePasswordsBubbleView::PendingView::PendingView( | 277 ManagePasswordsBubbleView::PendingView::PendingView( |
| 275 ManagePasswordsBubbleView* parent) | 278 ManagePasswordsBubbleView* parent) |
| 276 : parent_(parent) { | 279 : parent_(parent) { |
| 277 views::GridLayout* layout = new views::GridLayout(this); | 280 views::GridLayout* layout = new views::GridLayout(this); |
| 278 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); | 281 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); |
| 279 SetLayoutManager(layout); | 282 SetLayoutManager(layout); |
| 280 | 283 |
| 281 // Create the pending credential item, save button and refusal combobox. | 284 // Create the pending credential item, save button and refusal combobox. |
| 282 ManagePasswordItemView* item = | 285 ManagePasswordItemView* item = |
| 283 new ManagePasswordItemView(parent->model(), | 286 new ManagePasswordItemView(parent->model(), |
| 284 parent->model()->pending_credentials(), | 287 parent->model()->pending_password(), |
| 285 password_manager::ui::FIRST_ITEM); | 288 password_manager::ui::FIRST_ITEM); |
| 286 save_button_ = new views::BlueButton( | 289 save_button_ = new views::BlueButton( |
| 287 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON)); | 290 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON)); |
| 288 save_button_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( | 291 save_button_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
| 289 ui::ResourceBundle::SmallFont)); | 292 ui::ResourceBundle::SmallFont)); |
| 290 | 293 |
| 291 combobox_model_.reset(new SavePasswordRefusalComboboxModel()); | 294 combobox_model_.reset(new SavePasswordRefusalComboboxModel()); |
| 292 refuse_combobox_.reset(new views::Combobox(combobox_model_.get())); | 295 refuse_combobox_.reset(new views::Combobox(combobox_model_.get())); |
| 293 refuse_combobox_->set_listener(this); | 296 refuse_combobox_->set_listener(this); |
| 294 refuse_combobox_->SetStyle(views::Combobox::STYLE_ACTION); | 297 refuse_combobox_->SetStyle(views::Combobox::STYLE_ACTION); |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 initially_focused_view_ = NULL; | 884 initially_focused_view_ = NULL; |
| 882 if (password_manager::ui::IsPendingState(model()->state())) { | 885 if (password_manager::ui::IsPendingState(model()->state())) { |
| 883 if (never_save_passwords_) | 886 if (never_save_passwords_) |
| 884 AddChildView(new ConfirmNeverView(this)); | 887 AddChildView(new ConfirmNeverView(this)); |
| 885 else | 888 else |
| 886 AddChildView(new PendingView(this)); | 889 AddChildView(new PendingView(this)); |
| 887 } else if (model()->state() == password_manager::ui::BLACKLIST_STATE) { | 890 } else if (model()->state() == password_manager::ui::BLACKLIST_STATE) { |
| 888 AddChildView(new BlacklistedView(this)); | 891 AddChildView(new BlacklistedView(this)); |
| 889 } else if (model()->state() == password_manager::ui::CONFIRMATION_STATE) { | 892 } else if (model()->state() == password_manager::ui::CONFIRMATION_STATE) { |
| 890 AddChildView(new SaveConfirmationView(this)); | 893 AddChildView(new SaveConfirmationView(this)); |
| 894 } else if (model()->state() == |
| 895 password_manager::ui::PENDING_CREDENTIALS_AND_BUBBLE_STATE) { |
| 896 AddChildView(new AccountChooserView(this)); |
| 891 } else { | 897 } else { |
| 892 AddChildView(new ManageView(this)); | 898 AddChildView(new ManageView(this)); |
| 893 } | 899 } |
| 894 GetLayoutManager()->Layout(this); | 900 GetLayoutManager()->Layout(this); |
| 895 } | 901 } |
| 896 | 902 |
| 897 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { | 903 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { |
| 898 if (model()->best_matches().empty()) { | 904 if (model()->best_matches().empty()) { |
| 899 // Skip confirmation if there are no existing passwords for this site. | 905 // Skip confirmation if there are no existing passwords for this site. |
| 900 NotifyConfirmedNeverForThisSite(); | 906 NotifyConfirmedNeverForThisSite(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 } | 939 } |
| 934 | 940 |
| 935 void ManagePasswordsBubbleView::Observe( | 941 void ManagePasswordsBubbleView::Observe( |
| 936 int type, | 942 int type, |
| 937 const content::NotificationSource& source, | 943 const content::NotificationSource& source, |
| 938 const content::NotificationDetails& details) { | 944 const content::NotificationDetails& details) { |
| 939 DCHECK_EQ(type, chrome::NOTIFICATION_FULLSCREEN_CHANGED); | 945 DCHECK_EQ(type, chrome::NOTIFICATION_FULLSCREEN_CHANGED); |
| 940 GetWidget()->SetVisibilityAnimationTransition(views::Widget::ANIMATE_NONE); | 946 GetWidget()->SetVisibilityAnimationTransition(views::Widget::ANIMATE_NONE); |
| 941 CloseBubble(); | 947 CloseBubble(); |
| 942 } | 948 } |
| OLD | NEW |