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" |
11 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 11 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
12 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" | 12 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" |
13 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | 13 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
14 #include "chrome/browser/ui/passwords/save_account_more_combobox_model.h" | 14 #include "chrome/browser/ui/passwords/save_account_more_combobox_model.h" |
15 #include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h" | 15 #include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h" |
16 #include "chrome/browser/ui/views/frame/browser_view.h" | 16 #include "chrome/browser/ui/views/frame/browser_view.h" |
17 #include "chrome/browser/ui/views/passwords/credentials_item_view.h" | 17 #include "chrome/browser/ui/views/passwords/credentials_item_view.h" |
18 #include "chrome/browser/ui/views/passwords/credentials_selection_view.h" | |
18 #include "chrome/browser/ui/views/passwords/manage_credential_item_view.h" | 19 #include "chrome/browser/ui/views/passwords/manage_credential_item_view.h" |
19 #include "chrome/browser/ui/views/passwords/manage_password_items_view.h" | 20 #include "chrome/browser/ui/views/passwords/manage_password_items_view.h" |
20 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" | 21 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" |
21 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
22 #include "content/public/browser/render_view_host.h" | 23 #include "content/public/browser/render_view_host.h" |
23 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
24 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
25 #include "ui/views/controls/button/blue_button.h" | 26 #include "ui/views/controls/button/blue_button.h" |
26 #include "ui/views/controls/button/label_button.h" | 27 #include "ui/views/controls/button/label_button.h" |
27 #include "ui/views/controls/combobox/combobox.h" | 28 #include "ui/views/controls/combobox/combobox.h" |
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
967 if (event->type() == ui::ET_MOUSE_PRESSED) | 968 if (event->type() == ui::ET_MOUSE_PRESSED) |
968 bubble_->Close(); | 969 bubble_->Close(); |
969 } | 970 } |
970 | 971 |
971 void ManagePasswordsBubbleView::WebContentMouseHandler::OnTouchEvent( | 972 void ManagePasswordsBubbleView::WebContentMouseHandler::OnTouchEvent( |
972 ui::TouchEvent* event) { | 973 ui::TouchEvent* event) { |
973 if (event->type() == ui::ET_TOUCH_PRESSED) | 974 if (event->type() == ui::ET_TOUCH_PRESSED) |
974 bubble_->Close(); | 975 bubble_->Close(); |
975 } | 976 } |
976 | 977 |
978 // ManagePasswordsBubbleView::UpdatePendingView | |
979 // ------------------------------------- | |
vasilii
2015/07/23 15:15:13
Match the style of other classes.
dvadym
2015/07/24 16:42:40
Done.
| |
980 | |
981 // A view offering the user the ability to update credentials. Contains a | |
982 // single ManagePasswordItemsView, along with a "Update Passwords" button | |
983 // and a rejection button. | |
984 class ManagePasswordsBubbleView::UpdatePendingView | |
985 : public views::View, | |
986 public views::ButtonListener, | |
987 public views::StyledLabelListener { | |
988 public: | |
989 explicit UpdatePendingView(ManagePasswordsBubbleView* parent); | |
990 ~UpdatePendingView() override; | |
991 | |
992 private: | |
993 // views::ButtonListener: | |
994 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | |
995 | |
996 // views::StyledLabelListener: | |
997 void StyledLabelLinkClicked(const gfx::Range& range, | |
998 int event_flags) override; | |
999 | |
1000 ManagePasswordsBubbleView* parent_; | |
1001 | |
1002 CredentialsSelectionView* selection_view_; | |
1003 | |
1004 views::BlueButton* update_button_; | |
1005 | |
1006 views::LabelButton* nope_button_; | |
1007 | |
1008 DISALLOW_COPY_AND_ASSIGN(UpdatePendingView); | |
1009 }; | |
1010 | |
1011 ManagePasswordsBubbleView::UpdatePendingView::UpdatePendingView( | |
1012 ManagePasswordsBubbleView* parent) | |
1013 : parent_(parent), selection_view_(nullptr) { | |
1014 views::GridLayout* layout = new views::GridLayout(this); | |
1015 layout->set_minimum_size(gfx::Size(kDesiredBubbleWidth, 0)); | |
1016 SetLayoutManager(layout); | |
1017 | |
1018 // Create the pending credential item, update button. | |
1019 View* item; | |
vasilii
2015/07/23 15:15:13
Init
dvadym
2015/07/24 16:42:40
Done.
| |
1020 if (parent->model()->ShouldShowMultipleAccountUpdateUI()) { | |
1021 item = selection_view_ = new CredentialsSelectionView( | |
vasilii
2015/07/23 15:15:13
Split into 2 statements.
dvadym
2015/07/24 16:42:39
Done.
| |
1022 parent->model(), parent->model()->local_credentials().get()); | |
1023 } else { | |
1024 std::vector<const autofill::PasswordForm*> credentials; | |
1025 credentials.push_back(&parent->model()->pending_password()); | |
1026 item = new ManagePasswordItemsView(parent_->model(), credentials); | |
1027 } | |
1028 nope_button_ = new views::LabelButton( | |
1029 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_CANCEL_BUTTON)); | |
1030 nope_button_->SetStyle(views::Button::STYLE_BUTTON); | |
1031 nope_button_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( | |
1032 ui::ResourceBundle::SmallFont)); | |
1033 | |
1034 update_button_ = new views::BlueButton( | |
1035 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_UPDATE_BUTTON)); | |
1036 update_button_->SetFontList( | |
1037 ui::ResourceBundle::GetSharedInstance().GetFontList( | |
1038 ui::ResourceBundle::SmallFont)); | |
1039 | |
1040 // Title row. | |
1041 views::StyledLabel* title_label = | |
1042 new views::StyledLabel(parent_->model()->title(), this); | |
1043 title_label->SetBaseFontList( | |
1044 ui::ResourceBundle::GetSharedInstance().GetFontList( | |
1045 ui::ResourceBundle::MediumFont)); | |
1046 if (!parent_->model()->title_brand_link_range().is_empty()) { | |
1047 title_label->AddStyleRange( | |
1048 parent_->model()->title_brand_link_range(), | |
1049 views::StyledLabel::RangeStyleInfo::CreateForLink()); | |
1050 } | |
1051 BuildColumnSet(layout, SINGLE_VIEW_COLUMN_SET); | |
1052 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | |
1053 layout->AddView(title_label); | |
1054 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | |
1055 | |
1056 // Credential row. | |
1057 layout->StartRow(0, SINGLE_VIEW_COLUMN_SET); | |
1058 layout->AddView(item); | |
1059 | |
1060 // Button row. | |
1061 BuildColumnSet(layout, DOUBLE_BUTTON_COLUMN_SET); | |
1062 layout->StartRowWithPadding(0, DOUBLE_BUTTON_COLUMN_SET, 0, | |
1063 views::kRelatedControlVerticalSpacing); | |
1064 layout->AddView(update_button_); | |
1065 layout->AddView(nope_button_); | |
1066 | |
1067 // Extra padding for visual awesomeness. | |
1068 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | |
1069 | |
1070 parent_->set_initially_focused_view(update_button_); | |
1071 } | |
1072 | |
1073 ManagePasswordsBubbleView::UpdatePendingView::~UpdatePendingView() {} | |
1074 | |
1075 void ManagePasswordsBubbleView::UpdatePendingView::ButtonPressed( | |
1076 views::Button* sender, | |
1077 const ui::Event& event) { | |
1078 DCHECK(sender == update_button_ || sender == nope_button_); | |
1079 if (sender == update_button_) { | |
1080 if (selection_view_) { | |
1081 // Multi account case | |
vabr (Chromium)
2015/07/24 08:24:29
nit: Add a full-stop at the end.
dvadym
2015/07/24 16:42:40
Done.
| |
1082 parent_->model()->OnUpdateClicked( | |
1083 *selection_view_->GetSelectedCredentials()); | |
1084 } else { | |
1085 parent_->model()->OnUpdateClicked(parent_->model()->pending_password()); | |
1086 } | |
1087 } | |
1088 parent_->Close(); | |
1089 } | |
1090 | |
1091 void ManagePasswordsBubbleView::UpdatePendingView::StyledLabelLinkClicked( | |
1092 const gfx::Range& range, | |
1093 int event_flags) { | |
1094 DCHECK_EQ(range, parent_->model()->title_brand_link_range()); | |
1095 parent_->model()->OnBrandLinkClicked(); | |
1096 } | |
1097 | |
977 // ManagePasswordsBubbleView -------------------------------------------------- | 1098 // ManagePasswordsBubbleView -------------------------------------------------- |
978 | 1099 |
979 // static | 1100 // static |
980 ManagePasswordsBubbleView* ManagePasswordsBubbleView::manage_passwords_bubble_ = | 1101 ManagePasswordsBubbleView* ManagePasswordsBubbleView::manage_passwords_bubble_ = |
981 NULL; | 1102 NULL; |
982 | 1103 |
983 // static | 1104 // static |
984 void ManagePasswordsBubbleView::ShowBubble(content::WebContents* web_contents, | 1105 void ManagePasswordsBubbleView::ShowBubble(content::WebContents* web_contents, |
985 DisplayReason reason) { | 1106 DisplayReason reason) { |
986 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 1107 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1073 } | 1194 } |
1074 | 1195 |
1075 void ManagePasswordsBubbleView::Refresh() { | 1196 void ManagePasswordsBubbleView::Refresh() { |
1076 RemoveAllChildViews(true); | 1197 RemoveAllChildViews(true); |
1077 initially_focused_view_ = NULL; | 1198 initially_focused_view_ = NULL; |
1078 if (model()->state() == password_manager::ui::PENDING_PASSWORD_STATE) { | 1199 if (model()->state() == password_manager::ui::PENDING_PASSWORD_STATE) { |
1079 if (model()->never_save_passwords()) | 1200 if (model()->never_save_passwords()) |
1080 AddChildView(new ConfirmNeverView(this)); | 1201 AddChildView(new ConfirmNeverView(this)); |
1081 else | 1202 else |
1082 AddChildView(new PendingView(this)); | 1203 AddChildView(new PendingView(this)); |
1204 } else if (model()->state() == | |
1205 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE) { | |
1206 AddChildView(new UpdatePendingView(this)); | |
1083 } else if (model()->state() == password_manager::ui::BLACKLIST_STATE) { | 1207 } else if (model()->state() == password_manager::ui::BLACKLIST_STATE) { |
1084 AddChildView(new BlacklistedView(this)); | 1208 AddChildView(new BlacklistedView(this)); |
1085 } else if (model()->state() == password_manager::ui::CONFIRMATION_STATE) { | 1209 } else if (model()->state() == password_manager::ui::CONFIRMATION_STATE) { |
1086 AddChildView(new SaveConfirmationView(this)); | 1210 AddChildView(new SaveConfirmationView(this)); |
1087 } else if (model()->state() == | 1211 } else if (model()->state() == |
1088 password_manager::ui::CREDENTIAL_REQUEST_STATE) { | 1212 password_manager::ui::CREDENTIAL_REQUEST_STATE) { |
1089 AddChildView(new AccountChooserView(this)); | 1213 AddChildView(new AccountChooserView(this)); |
1090 } else if (model()->state() == password_manager::ui::AUTO_SIGNIN_STATE) { | 1214 } else if (model()->state() == password_manager::ui::AUTO_SIGNIN_STATE) { |
1091 AddChildView(new AutoSigninView(this)); | 1215 AddChildView(new AutoSigninView(this)); |
1092 } else { | 1216 } else { |
(...skipping 19 matching lines...) Expand all Loading... | |
1112 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { | 1236 void ManagePasswordsBubbleView::NotifyNeverForThisSiteClicked() { |
1113 if (model()->local_credentials().empty()) { | 1237 if (model()->local_credentials().empty()) { |
1114 // Skip confirmation if there are no existing passwords for this site. | 1238 // Skip confirmation if there are no existing passwords for this site. |
1115 NotifyConfirmedNeverForThisSite(); | 1239 NotifyConfirmedNeverForThisSite(); |
1116 } else { | 1240 } else { |
1117 model()->OnConfirmationForNeverForThisSite(); | 1241 model()->OnConfirmationForNeverForThisSite(); |
1118 Refresh(); | 1242 Refresh(); |
1119 SizeToContents(); | 1243 SizeToContents(); |
1120 } | 1244 } |
1121 } | 1245 } |
OLD | NEW |