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

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_bubble_model.cc

Issue 775843005: Moving member never_save_password of ManagePasswordsBubbleView to ManagePasswordsBubbleModel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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/passwords/manage_passwords_bubble_model.h" 5 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
6 6
7 #include "chrome/browser/password_manager/password_store_factory.h" 7 #include "chrome/browser/password_manager/password_store_factory.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/passwords/manage_passwords_ui_controller.h" 10 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
(...skipping 25 matching lines...) Expand all
36 36
37 void RecordExperimentStatistics(content::WebContents* web_contents, 37 void RecordExperimentStatistics(content::WebContents* web_contents,
38 metrics_util::UIDismissalReason reason) { 38 metrics_util::UIDismissalReason reason) {
39 if (!web_contents) 39 if (!web_contents)
40 return; 40 return;
41 Profile* profile = 41 Profile* profile =
42 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 42 Profile::FromBrowserContext(web_contents->GetBrowserContext());
43 password_bubble_experiment::RecordBubbleClosed(profile->GetPrefs(), reason); 43 password_bubble_experiment::RecordBubbleClosed(profile->GetPrefs(), reason);
44 } 44 }
45 45
46 base::string16 PendingStateTitleBasedOnSavePasswordPref(
47 bool never_save_passwords) {
48 return l10n_util::GetStringUTF16(
49 never_save_passwords ? IDS_MANAGE_PASSWORDS_BLACKLIST_CONFIRMATION_TITLE
50 : IDS_SAVE_PASSWORD);
51 }
52
46 } // namespace 53 } // namespace
47 54
48 ManagePasswordsBubbleModel::ManagePasswordsBubbleModel( 55 ManagePasswordsBubbleModel::ManagePasswordsBubbleModel(
49 content::WebContents* web_contents) 56 content::WebContents* web_contents)
50 : content::WebContentsObserver(web_contents), 57 : content::WebContentsObserver(web_contents),
51 display_disposition_( 58 never_save_passwords_(false),
52 metrics_util::AUTOMATIC_WITH_PASSWORD_PENDING), 59 display_disposition_(metrics_util::AUTOMATIC_WITH_PASSWORD_PENDING),
53 dismissal_reason_(metrics_util::NOT_DISPLAYED) { 60 dismissal_reason_(metrics_util::NOT_DISPLAYED) {
54 ManagePasswordsUIController* controller = 61 ManagePasswordsUIController* controller =
55 ManagePasswordsUIController::FromWebContents(web_contents); 62 ManagePasswordsUIController::FromWebContents(web_contents);
56 63
57 state_ = controller->state(); 64 state_ = controller->state();
58 if (password_manager::ui::IsPendingState(state_)) 65 if (password_manager::ui::IsPendingState(state_))
59 pending_password_ = controller->PendingPassword(); 66 pending_password_ = controller->PendingPassword();
60 if (password_manager::ui::IsCredentialsState(state_)) 67 if (password_manager::ui::IsCredentialsState(state_))
61 pending_credentials_.swap(controller->new_password_forms()); 68 pending_credentials_.swap(controller->new_password_forms());
62 else 69 else
63 best_matches_ = controller->best_matches(); 70 best_matches_ = controller->best_matches();
64 71
65 if (password_manager::ui::IsPendingState(state_)) { 72 if (password_manager::ui::IsPendingState(state_)) {
66 title_ = l10n_util::GetStringUTF16(IDS_SAVE_PASSWORD); 73 title_ = PendingStateTitleBasedOnSavePasswordPref(never_save_passwords_);
67 } else if (state_ == password_manager::ui::BLACKLIST_STATE) { 74 } else if (state_ == password_manager::ui::BLACKLIST_STATE) {
68 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_BLACKLISTED_TITLE); 75 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_BLACKLISTED_TITLE);
69 } else if (state_ == password_manager::ui::CONFIRMATION_STATE) { 76 } else if (state_ == password_manager::ui::CONFIRMATION_STATE) {
70 title_ = 77 title_ =
71 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_CONFIRM_GENERATED_TITLE); 78 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_CONFIRM_GENERATED_TITLE);
72 } else if (password_manager::ui::IsCredentialsState(state_)) { 79 } else if (password_manager::ui::IsCredentialsState(state_)) {
73 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_CHOOSE_TITLE); 80 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_CHOOSE_TITLE);
74 } else { 81 } else {
75 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_TITLE); 82 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_TITLE);
76 } 83 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 RecordExperimentStatistics(web_contents(), dismissal_reason_); 148 RecordExperimentStatistics(web_contents(), dismissal_reason_);
142 } 149 }
143 150
144 void ManagePasswordsBubbleModel::OnNopeClicked() { 151 void ManagePasswordsBubbleModel::OnNopeClicked() {
145 dismissal_reason_ = metrics_util::CLICKED_NOPE; 152 dismissal_reason_ = metrics_util::CLICKED_NOPE;
146 RecordExperimentStatistics(web_contents(), dismissal_reason_); 153 RecordExperimentStatistics(web_contents(), dismissal_reason_);
147 if (!password_manager::ui::IsCredentialsState(state_)) 154 if (!password_manager::ui::IsCredentialsState(state_))
148 state_ = password_manager::ui::PENDING_PASSWORD_STATE; 155 state_ = password_manager::ui::PENDING_PASSWORD_STATE;
149 } 156 }
150 157
158 void ManagePasswordsBubbleModel::OnConfirmationForNeverForThisSite() {
159 never_save_passwords_ = true;
160 title_ = PendingStateTitleBasedOnSavePasswordPref(never_save_passwords_);
161 }
162
163 void ManagePasswordsBubbleModel::OnUndoNeverForThisSite() {
164 never_save_passwords_ = false;
165 title_ = PendingStateTitleBasedOnSavePasswordPref(never_save_passwords_);
166 }
167
151 void ManagePasswordsBubbleModel::OnNeverForThisSiteClicked() { 168 void ManagePasswordsBubbleModel::OnNeverForThisSiteClicked() {
152 dismissal_reason_ = metrics_util::CLICKED_NEVER; 169 dismissal_reason_ = metrics_util::CLICKED_NEVER;
153 RecordExperimentStatistics(web_contents(), dismissal_reason_); 170 RecordExperimentStatistics(web_contents(), dismissal_reason_);
154 ManagePasswordsUIController* manage_passwords_ui_controller = 171 ManagePasswordsUIController* manage_passwords_ui_controller =
155 ManagePasswordsUIController::FromWebContents(web_contents()); 172 ManagePasswordsUIController::FromWebContents(web_contents());
156 manage_passwords_ui_controller->NeverSavePassword(); 173 manage_passwords_ui_controller->NeverSavePassword();
157 state_ = password_manager::ui::BLACKLIST_STATE; 174 state_ = password_manager::ui::BLACKLIST_STATE;
158 } 175 }
159 176
160 void ManagePasswordsBubbleModel::OnUnblacklistClicked() { 177 void ManagePasswordsBubbleModel::OnUnblacklistClicked() {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 236
220 // static 237 // static
221 int ManagePasswordsBubbleModel::UsernameFieldWidth() { 238 int ManagePasswordsBubbleModel::UsernameFieldWidth() {
222 return GetFieldWidth(USERNAME_FIELD); 239 return GetFieldWidth(USERNAME_FIELD);
223 } 240 }
224 241
225 // static 242 // static
226 int ManagePasswordsBubbleModel::PasswordFieldWidth() { 243 int ManagePasswordsBubbleModel::PasswordFieldWidth() {
227 return GetFieldWidth(PASSWORD_FIELD); 244 return GetFieldWidth(PASSWORD_FIELD);
228 } 245 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698