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

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 PendingStateTitleBasedOnSafePasswordPref(
47 bool never_save_passwords) {
48 if (!never_save_passwords)
Mike West 2014/12/04 00:11:48 Negations are confusing. :) How about something m
melandory 2014/12/04 09:41:30 Done.
49 return l10n_util::GetStringUTF16(IDS_SAVE_PASSWORD);
50 else
51 return l10n_util::GetStringUTF16(
52 IDS_MANAGE_PASSWORDS_BLACKLIST_CONFIRMATION_TITLE);
53 }
54
46 } // namespace 55 } // namespace
47 56
48 ManagePasswordsBubbleModel::ManagePasswordsBubbleModel( 57 ManagePasswordsBubbleModel::ManagePasswordsBubbleModel(
49 content::WebContents* web_contents) 58 content::WebContents* web_contents)
50 : content::WebContentsObserver(web_contents), 59 : content::WebContentsObserver(web_contents),
51 display_disposition_( 60 never_save_passwords_(false),
52 metrics_util::AUTOMATIC_WITH_PASSWORD_PENDING), 61 display_disposition_(metrics_util::AUTOMATIC_WITH_PASSWORD_PENDING),
53 dismissal_reason_(metrics_util::NOT_DISPLAYED) { 62 dismissal_reason_(metrics_util::NOT_DISPLAYED) {
54 ManagePasswordsUIController* controller = 63 ManagePasswordsUIController* controller =
55 ManagePasswordsUIController::FromWebContents(web_contents); 64 ManagePasswordsUIController::FromWebContents(web_contents);
56 65
57 state_ = controller->state(); 66 state_ = controller->state();
58 if (password_manager::ui::IsPendingState(state_)) 67 if (password_manager::ui::IsPendingState(state_))
59 pending_password_ = controller->PendingPassword(); 68 pending_password_ = controller->PendingPassword();
60 if (password_manager::ui::IsCredentialsState(state_)) 69 if (password_manager::ui::IsCredentialsState(state_))
61 pending_credentials_.swap(controller->new_password_forms()); 70 pending_credentials_.swap(controller->new_password_forms());
62 else 71 else
63 best_matches_ = controller->best_matches(); 72 best_matches_ = controller->best_matches();
64 73
65 if (password_manager::ui::IsPendingState(state_)) { 74 if (password_manager::ui::IsPendingState(state_)) {
66 title_ = l10n_util::GetStringUTF16(IDS_SAVE_PASSWORD); 75 title_ = PendingStateTitleBasedOnSafePasswordPref(never_save_passwords_);
Mike West 2014/12/04 00:11:48 Nit: s/Safe/Save/?
melandory 2014/12/04 09:41:30 Done.
67 } else if (state_ == password_manager::ui::BLACKLIST_STATE) { 76 } else if (state_ == password_manager::ui::BLACKLIST_STATE) {
68 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_BLACKLISTED_TITLE); 77 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_BLACKLISTED_TITLE);
69 } else if (state_ == password_manager::ui::CONFIRMATION_STATE) { 78 } else if (state_ == password_manager::ui::CONFIRMATION_STATE) {
70 title_ = 79 title_ =
71 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_CONFIRM_GENERATED_TITLE); 80 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_CONFIRM_GENERATED_TITLE);
72 } else if (password_manager::ui::IsCredentialsState(state_)) { 81 } else if (password_manager::ui::IsCredentialsState(state_)) {
73 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_CHOOSE_TITLE); 82 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_CHOOSE_TITLE);
74 } else { 83 } else {
75 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_TITLE); 84 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_TITLE);
76 } 85 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 RecordExperimentStatistics(web_contents(), dismissal_reason_); 150 RecordExperimentStatistics(web_contents(), dismissal_reason_);
142 } 151 }
143 152
144 void ManagePasswordsBubbleModel::OnNopeClicked() { 153 void ManagePasswordsBubbleModel::OnNopeClicked() {
145 dismissal_reason_ = metrics_util::CLICKED_NOPE; 154 dismissal_reason_ = metrics_util::CLICKED_NOPE;
146 RecordExperimentStatistics(web_contents(), dismissal_reason_); 155 RecordExperimentStatistics(web_contents(), dismissal_reason_);
147 if (!password_manager::ui::IsCredentialsState(state_)) 156 if (!password_manager::ui::IsCredentialsState(state_))
148 state_ = password_manager::ui::PENDING_PASSWORD_STATE; 157 state_ = password_manager::ui::PENDING_PASSWORD_STATE;
149 } 158 }
150 159
160 void ManagePasswordsBubbleModel::OnConfirmationForNeverForThisSite() {
161 never_save_passwords_ = true;
162 PendingStateTitleBasedOnSafePasswordPref(never_save_passwords_);
Mike West 2014/12/04 00:11:48 You're not doing anything with the result of this
melandory 2014/12/04 09:41:30 Nope. It's bug, thanks for catching.
163 }
164
165 void ManagePasswordsBubbleModel::OnUndoNeverForThisSite() {
166 never_save_passwords_ = false;
167 PendingStateTitleBasedOnSafePasswordPref(never_save_passwords_);
Mike West 2014/12/04 00:11:48 Ditto.
melandory 2014/12/04 09:41:30 Done.
168 }
169
151 void ManagePasswordsBubbleModel::OnNeverForThisSiteClicked() { 170 void ManagePasswordsBubbleModel::OnNeverForThisSiteClicked() {
152 dismissal_reason_ = metrics_util::CLICKED_NEVER; 171 dismissal_reason_ = metrics_util::CLICKED_NEVER;
153 RecordExperimentStatistics(web_contents(), dismissal_reason_); 172 RecordExperimentStatistics(web_contents(), dismissal_reason_);
154 ManagePasswordsUIController* manage_passwords_ui_controller = 173 ManagePasswordsUIController* manage_passwords_ui_controller =
155 ManagePasswordsUIController::FromWebContents(web_contents()); 174 ManagePasswordsUIController::FromWebContents(web_contents());
156 manage_passwords_ui_controller->NeverSavePassword(); 175 manage_passwords_ui_controller->NeverSavePassword();
157 state_ = password_manager::ui::BLACKLIST_STATE; 176 state_ = password_manager::ui::BLACKLIST_STATE;
158 } 177 }
159 178
160 void ManagePasswordsBubbleModel::OnUnblacklistClicked() { 179 void ManagePasswordsBubbleModel::OnUnblacklistClicked() {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 238
220 // static 239 // static
221 int ManagePasswordsBubbleModel::UsernameFieldWidth() { 240 int ManagePasswordsBubbleModel::UsernameFieldWidth() {
222 return GetFieldWidth(USERNAME_FIELD); 241 return GetFieldWidth(USERNAME_FIELD);
223 } 242 }
224 243
225 // static 244 // static
226 int ManagePasswordsBubbleModel::PasswordFieldWidth() { 245 int ManagePasswordsBubbleModel::PasswordFieldWidth() {
227 return GetFieldWidth(PASSWORD_FIELD); 246 return GetFieldWidth(PASSWORD_FIELD);
228 } 247 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698