| 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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 | 368 |
| 369 ManagePasswordsBubbleView::ConfirmNeverView::ConfirmNeverView( | 369 ManagePasswordsBubbleView::ConfirmNeverView::ConfirmNeverView( |
| 370 ManagePasswordsBubbleView* parent) | 370 ManagePasswordsBubbleView* parent) |
| 371 : parent_(parent) { | 371 : parent_(parent) { |
| 372 views::GridLayout* layout = new views::GridLayout(this); | 372 views::GridLayout* layout = new views::GridLayout(this); |
| 373 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); | 373 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); |
| 374 SetLayoutManager(layout); | 374 SetLayoutManager(layout); |
| 375 | 375 |
| 376 // Title row. | 376 // Title row. |
| 377 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | 377 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); |
| 378 views::Label* title_label = new views::Label(l10n_util::GetStringUTF16( | 378 AddTitleRow(layout, parent_->model()); |
| 379 IDS_MANAGE_PASSWORDS_BLACKLIST_CONFIRMATION_TITLE)); | |
| 380 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
| 381 title_label->SetMultiLine(true); | |
| 382 title_label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( | |
| 383 ui::ResourceBundle::MediumFont)); | |
| 384 layout->StartRowWithPadding( | |
| 385 0, SINGLE_VIEW_COLUMN_SET, 0, views::kRelatedControlSmallVerticalSpacing); | |
| 386 layout->AddView(title_label); | |
| 387 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); | |
| 388 | 379 |
| 389 // Confirmation text. | 380 // Confirmation text. |
| 390 views::Label* confirmation = new views::Label(l10n_util::GetStringUTF16( | 381 views::Label* confirmation = new views::Label(l10n_util::GetStringUTF16( |
| 391 IDS_MANAGE_PASSWORDS_BLACKLIST_CONFIRMATION_TEXT)); | 382 IDS_MANAGE_PASSWORDS_BLACKLIST_CONFIRMATION_TEXT)); |
| 392 confirmation->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 383 confirmation->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 393 confirmation->SetMultiLine(true); | 384 confirmation->SetMultiLine(true); |
| 394 confirmation->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( | 385 confirmation->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
| 395 ui::ResourceBundle::SmallFont)); | 386 ui::ResourceBundle::SmallFont)); |
| 396 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | 387 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); |
| 397 layout->AddView(confirmation); | 388 layout->AddView(confirmation); |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 | 819 |
| 829 ManagePasswordsBubbleView::ManagePasswordsBubbleView( | 820 ManagePasswordsBubbleView::ManagePasswordsBubbleView( |
| 830 content::WebContents* web_contents, | 821 content::WebContents* web_contents, |
| 831 ManagePasswordsIconView* anchor_view, | 822 ManagePasswordsIconView* anchor_view, |
| 832 DisplayReason reason) | 823 DisplayReason reason) |
| 833 : ManagePasswordsBubble(web_contents, reason), | 824 : ManagePasswordsBubble(web_contents, reason), |
| 834 BubbleDelegateView(anchor_view, | 825 BubbleDelegateView(anchor_view, |
| 835 anchor_view ? views::BubbleBorder::TOP_RIGHT | 826 anchor_view ? views::BubbleBorder::TOP_RIGHT |
| 836 : views::BubbleBorder::NONE), | 827 : views::BubbleBorder::NONE), |
| 837 anchor_view_(anchor_view), | 828 anchor_view_(anchor_view), |
| 838 never_save_passwords_(false), | |
| 839 initially_focused_view_(NULL) { | 829 initially_focused_view_(NULL) { |
| 840 // Compensate for built-in vertical padding in the anchor view's image. | 830 // Compensate for built-in vertical padding in the anchor view's image. |
| 841 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); | 831 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); |
| 842 if (anchor_view) | 832 if (anchor_view) |
| 843 anchor_view->SetActive(true); | 833 anchor_view->SetActive(true); |
| 844 mouse_handler_.reset(new WebContentMouseHandler(this)); | 834 mouse_handler_.reset(new WebContentMouseHandler(this)); |
| 845 | 835 |
| 846 // Add observers to close the bubble if the fullscreen state changes. | 836 // Add observers to close the bubble if the fullscreen state changes. |
| 847 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 837 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
| 848 registrar_.Add( | 838 registrar_.Add( |
| (...skipping 23 matching lines...) Expand all Loading... |
| 872 | 862 |
| 873 void ManagePasswordsBubbleView::Close() { | 863 void ManagePasswordsBubbleView::Close() { |
| 874 mouse_handler_.reset(); | 864 mouse_handler_.reset(); |
| 875 GetWidget()->Close(); | 865 GetWidget()->Close(); |
| 876 } | 866 } |
| 877 | 867 |
| 878 void ManagePasswordsBubbleView::Refresh() { | 868 void ManagePasswordsBubbleView::Refresh() { |
| 879 RemoveAllChildViews(true); | 869 RemoveAllChildViews(true); |
| 880 initially_focused_view_ = NULL; | 870 initially_focused_view_ = NULL; |
| 881 if (password_manager::ui::IsPendingState(model()->state())) { | 871 if (password_manager::ui::IsPendingState(model()->state())) { |
| 882 if (never_save_passwords_) | 872 if (model()->never_save_passwords()) |
| 883 AddChildView(new ConfirmNeverView(this)); | 873 AddChildView(new ConfirmNeverView(this)); |
| 884 else | 874 else |
| 885 AddChildView(new PendingView(this)); | 875 AddChildView(new PendingView(this)); |
| 886 } else if (model()->state() == password_manager::ui::BLACKLIST_STATE) { | 876 } else if (model()->state() == password_manager::ui::BLACKLIST_STATE) { |
| 887 AddChildView(new BlacklistedView(this)); | 877 AddChildView(new BlacklistedView(this)); |
| 888 } else if (model()->state() == password_manager::ui::CONFIRMATION_STATE) { | 878 } else if (model()->state() == password_manager::ui::CONFIRMATION_STATE) { |
| 889 AddChildView(new SaveConfirmationView(this)); | 879 AddChildView(new SaveConfirmationView(this)); |
| 890 } else if (password_manager::ui::IsCredentialsState(model()->state())) { | 880 } else if (password_manager::ui::IsCredentialsState(model()->state())) { |
| 891 AddChildView(new AccountChooserView(this)); | 881 AddChildView(new AccountChooserView(this)); |
| 892 } else { | 882 } else { |
| 893 AddChildView(new ManageView(this)); | 883 AddChildView(new ManageView(this)); |
| 894 } | 884 } |
| 895 GetLayoutManager()->Layout(this); | 885 GetLayoutManager()->Layout(this); |
| 896 } | 886 } |
| 897 | 887 |
| 898 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { | 888 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { |
| 899 if (model()->best_matches().empty()) { | 889 if (model()->best_matches().empty()) { |
| 900 // Skip confirmation if there are no existing passwords for this site. | 890 // Skip confirmation if there are no existing passwords for this site. |
| 901 NotifyConfirmedNeverForThisSite(); | 891 NotifyConfirmedNeverForThisSite(); |
| 902 } else { | 892 } else { |
| 903 never_save_passwords_ = true; | 893 model()->OnConfirmationForNeverForThisSite(); |
| 904 Refresh(); | 894 Refresh(); |
| 905 } | 895 } |
| 906 } | 896 } |
| 907 | 897 |
| 908 void ManagePasswordsBubbleView::NotifyConfirmedNeverForThisSite() { | 898 void ManagePasswordsBubbleView::NotifyConfirmedNeverForThisSite() { |
| 909 model()->OnNeverForThisSiteClicked(); | 899 model()->OnNeverForThisSiteClicked(); |
| 910 Close(); | 900 Close(); |
| 911 } | 901 } |
| 912 | 902 |
| 913 void ManagePasswordsBubbleView::NotifyUndoNeverForThisSite() { | 903 void ManagePasswordsBubbleView::NotifyUndoNeverForThisSite() { |
| 914 never_save_passwords_ = false; | 904 model()->OnUndoNeverForThisSite(); |
| 915 Refresh(); | 905 Refresh(); |
| 916 } | 906 } |
| 917 | 907 |
| 918 void ManagePasswordsBubbleView::Init() { | 908 void ManagePasswordsBubbleView::Init() { |
| 919 views::FillLayout* layout = new views::FillLayout(); | 909 views::FillLayout* layout = new views::FillLayout(); |
| 920 SetLayoutManager(layout); | 910 SetLayoutManager(layout); |
| 921 | 911 |
| 922 Refresh(); | 912 Refresh(); |
| 923 } | 913 } |
| 924 | 914 |
| 925 void ManagePasswordsBubbleView::WindowClosing() { | 915 void ManagePasswordsBubbleView::WindowClosing() { |
| 926 // Close() closes the window asynchronously, so by the time we reach here, | 916 // Close() closes the window asynchronously, so by the time we reach here, |
| 927 // |manage_passwords_bubble_| may have already been reset. | 917 // |manage_passwords_bubble_| may have already been reset. |
| 928 if (manage_passwords_bubble_ == this) | 918 if (manage_passwords_bubble_ == this) |
| 929 manage_passwords_bubble_ = NULL; | 919 manage_passwords_bubble_ = NULL; |
| 930 } | 920 } |
| 931 | 921 |
| 932 views::View* ManagePasswordsBubbleView::GetInitiallyFocusedView() { | 922 views::View* ManagePasswordsBubbleView::GetInitiallyFocusedView() { |
| 933 return initially_focused_view_; | 923 return initially_focused_view_; |
| 934 } | 924 } |
| 935 | 925 |
| 936 void ManagePasswordsBubbleView::Observe( | 926 void ManagePasswordsBubbleView::Observe( |
| 937 int type, | 927 int type, |
| 938 const content::NotificationSource& source, | 928 const content::NotificationSource& source, |
| 939 const content::NotificationDetails& details) { | 929 const content::NotificationDetails& details) { |
| 940 DCHECK_EQ(type, chrome::NOTIFICATION_FULLSCREEN_CHANGED); | 930 DCHECK_EQ(type, chrome::NOTIFICATION_FULLSCREEN_CHANGED); |
| 941 GetWidget()->SetVisibilityAnimationTransition(views::Widget::ANIMATE_NONE); | 931 GetWidget()->SetVisibilityAnimationTransition(views::Widget::ANIMATE_NONE); |
| 942 CloseBubble(); | 932 CloseBubble(); |
| 943 } | 933 } |
| OLD | NEW |