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 "base/timer/timer.h" | 7 #include "base/timer/timer.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_finder.h" | 10 #include "chrome/browser/ui/browser_finder.h" |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 DISALLOW_COPY_AND_ASSIGN(PendingView); | 386 DISALLOW_COPY_AND_ASSIGN(PendingView); |
387 }; | 387 }; |
388 | 388 |
389 ManagePasswordsBubbleView::PendingView::PendingView( | 389 ManagePasswordsBubbleView::PendingView::PendingView( |
390 ManagePasswordsBubbleView* parent) | 390 ManagePasswordsBubbleView* parent) |
391 : parent_(parent) { | 391 : parent_(parent) { |
392 views::GridLayout* layout = new views::GridLayout(this); | 392 views::GridLayout* layout = new views::GridLayout(this); |
393 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); | 393 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); |
394 SetLayoutManager(layout); | 394 SetLayoutManager(layout); |
395 | 395 |
396 std::vector<const autofill::PasswordForm*> credentials( | |
397 1, &parent->model()->pending_password()); | |
398 // Create the pending credential item, save button and refusal combobox. | 396 // Create the pending credential item, save button and refusal combobox. |
399 ManagePasswordItemsView* item = | 397 ManagePasswordItemsView* item = nullptr; |
400 new ManagePasswordItemsView(parent_->model(), credentials); | 398 if (!parent->model()->pending_password() |
| 399 .IsPossibleChangePasswordFormWithoutUsername()) { |
| 400 std::vector<const autofill::PasswordForm*> credentials( |
| 401 1, &parent->model()->pending_password()); |
| 402 item = new ManagePasswordItemsView(parent_->model(), credentials); |
| 403 } |
401 save_button_ = new views::BlueButton( | 404 save_button_ = new views::BlueButton( |
402 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON)); | 405 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON)); |
403 save_button_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( | 406 save_button_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
404 ui::ResourceBundle::SmallFont)); | 407 ui::ResourceBundle::SmallFont)); |
405 | 408 |
406 combobox_model_.reset(new SavePasswordRefusalComboboxModel); | 409 combobox_model_.reset(new SavePasswordRefusalComboboxModel); |
407 refuse_combobox_.reset(new views::Combobox(combobox_model_.get())); | 410 refuse_combobox_.reset(new views::Combobox(combobox_model_.get())); |
408 refuse_combobox_->set_listener(this); | 411 refuse_combobox_->set_listener(this); |
409 refuse_combobox_->SetStyle(views::Combobox::STYLE_ACTION); | 412 refuse_combobox_->SetStyle(views::Combobox::STYLE_ACTION); |
410 // TODO(mkwst): Need a mechanism to pipe a font list down into a combobox. | 413 // TODO(mkwst): Need a mechanism to pipe a font list down into a combobox. |
411 | 414 |
412 // Title row. | 415 // Title row. |
413 views::StyledLabel* title_label = | 416 views::StyledLabel* title_label = |
414 new views::StyledLabel(parent_->model()->title(), this); | 417 new views::StyledLabel(parent_->model()->title(), this); |
415 title_label->SetBaseFontList( | 418 title_label->SetBaseFontList( |
416 ui::ResourceBundle::GetSharedInstance().GetFontList( | 419 ui::ResourceBundle::GetSharedInstance().GetFontList( |
417 ui::ResourceBundle::MediumFont)); | 420 ui::ResourceBundle::MediumFont)); |
418 if (!parent_->model()->title_brand_link_range().is_empty()) { | 421 if (!parent_->model()->title_brand_link_range().is_empty()) { |
419 title_label->AddStyleRange( | 422 title_label->AddStyleRange( |
420 parent_->model()->title_brand_link_range(), | 423 parent_->model()->title_brand_link_range(), |
421 views::StyledLabel::RangeStyleInfo::CreateForLink()); | 424 views::StyledLabel::RangeStyleInfo::CreateForLink()); |
422 } | 425 } |
423 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | 426 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
424 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | 427 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
425 layout->AddView(title_label); | 428 layout->AddView(title_label); |
426 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 429 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
427 | 430 |
428 // Credential row. | 431 // Credential row. |
429 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | 432 if (item) { |
430 layout->AddView(item); | 433 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
| 434 layout->AddView(item); |
| 435 } |
431 | 436 |
432 // Button row. | 437 // Button row. |
433 BuildColumnSet(layout, DOUBLE_BUTTON_COLUMN_SET); | 438 BuildColumnSet(layout, DOUBLE_BUTTON_COLUMN_SET); |
434 layout->StartRowWithPadding( | 439 layout->StartRowWithPadding( |
435 0, DOUBLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); | 440 0, DOUBLE_BUTTON_COLUMN_SET, 0, views::kRelatedControlVerticalSpacing); |
436 layout->AddView(save_button_); | 441 layout->AddView(save_button_); |
437 layout->AddView(refuse_combobox_.get()); | 442 layout->AddView(refuse_combobox_.get()); |
438 | 443 |
439 // Extra padding for visual awesomeness. | 444 // Extra padding for visual awesomeness. |
440 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 445 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { | 1245 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { |
1241 if (model()->local_credentials().empty()) { | 1246 if (model()->local_credentials().empty()) { |
1242 // Skip confirmation if there are no existing passwords for this site. | 1247 // Skip confirmation if there are no existing passwords for this site. |
1243 NotifyConfirmedNeverForThisSite(); | 1248 NotifyConfirmedNeverForThisSite(); |
1244 } else { | 1249 } else { |
1245 model()->OnConfirmationForNeverForThisSite(); | 1250 model()->OnConfirmationForNeverForThisSite(); |
1246 Refresh(); | 1251 Refresh(); |
1247 SizeToContents(); | 1252 SizeToContents(); |
1248 } | 1253 } |
1249 } | 1254 } |
OLD | NEW |