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/passwords/manage_passwords_bubble_model.h" | 5 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/password_manager/password_store_factory.h" | 9 #include "chrome/browser/password_manager/password_store_factory.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 content::WebContents* web_contents) | 89 content::WebContents* web_contents) |
90 : content::WebContentsObserver(web_contents), | 90 : content::WebContentsObserver(web_contents), |
91 never_save_passwords_(false), | 91 never_save_passwords_(false), |
92 display_disposition_(metrics_util::AUTOMATIC_WITH_PASSWORD_PENDING), | 92 display_disposition_(metrics_util::AUTOMATIC_WITH_PASSWORD_PENDING), |
93 dismissal_reason_(metrics_util::NOT_DISPLAYED) { | 93 dismissal_reason_(metrics_util::NOT_DISPLAYED) { |
94 ManagePasswordsUIController* controller = | 94 ManagePasswordsUIController* controller = |
95 ManagePasswordsUIController::FromWebContents(web_contents); | 95 ManagePasswordsUIController::FromWebContents(web_contents); |
96 | 96 |
97 origin_ = controller->origin(); | 97 origin_ = controller->origin(); |
98 state_ = controller->state(); | 98 state_ = controller->state(); |
99 if (state_ == password_manager::ui::PENDING_PASSWORD_STATE) { | 99 if (state_ == password_manager::ui::PENDING_PASSWORD_STATE || |
100 state_ == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE) { | |
100 pending_password_ = controller->PendingPassword(); | 101 pending_password_ = controller->PendingPassword(); |
101 local_credentials_ = DeepCopyForms(controller->GetCurrentForms()); | 102 local_credentials_ = DeepCopyForms(controller->GetCurrentForms()); |
102 } else if (state_ == password_manager::ui::CONFIRMATION_STATE) { | 103 } else if (state_ == password_manager::ui::CONFIRMATION_STATE) { |
103 // We don't need anything. | 104 // We don't need anything. |
104 } else if (state_ == password_manager::ui::CREDENTIAL_REQUEST_STATE) { | 105 } else if (state_ == password_manager::ui::CREDENTIAL_REQUEST_STATE) { |
105 local_credentials_ = DeepCopyForms(controller->GetCurrentForms()); | 106 local_credentials_ = DeepCopyForms(controller->GetCurrentForms()); |
106 federated_credentials_ = DeepCopyForms(controller->GetFederatedForms()); | 107 federated_credentials_ = DeepCopyForms(controller->GetFederatedForms()); |
107 } else if (state_ == password_manager::ui::AUTO_SIGNIN_STATE) { | 108 } else if (state_ == password_manager::ui::AUTO_SIGNIN_STATE) { |
108 pending_password_ = *controller->GetCurrentForms()[0]; | 109 pending_password_ = *controller->GetCurrentForms()[0]; |
109 } else { | 110 } else { |
110 local_credentials_ = DeepCopyForms(controller->GetCurrentForms()); | 111 local_credentials_ = DeepCopyForms(controller->GetCurrentForms()); |
111 } | 112 } |
112 | 113 |
113 if (state_ == password_manager::ui::PENDING_PASSWORD_STATE) { | 114 if (state_ == password_manager::ui::PENDING_PASSWORD_STATE || |
115 state_ == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE) { | |
114 UpdatePendingStateTitle(); | 116 UpdatePendingStateTitle(); |
115 } else if (state_ == password_manager::ui::BLACKLIST_STATE) { | 117 } else if (state_ == password_manager::ui::BLACKLIST_STATE) { |
116 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_BLACKLISTED_TITLE); | 118 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_BLACKLISTED_TITLE); |
117 } else if (state_ == password_manager::ui::CONFIRMATION_STATE) { | 119 } else if (state_ == password_manager::ui::CONFIRMATION_STATE) { |
118 title_ = | 120 title_ = |
119 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_CONFIRM_GENERATED_TITLE); | 121 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_CONFIRM_GENERATED_TITLE); |
120 } else if (state_ == password_manager::ui::CREDENTIAL_REQUEST_STATE) { | 122 } else if (state_ == password_manager::ui::CREDENTIAL_REQUEST_STATE) { |
121 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_CHOOSE_TITLE); | 123 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_CHOOSE_TITLE); |
122 } else if (state_ == password_manager::ui::AUTO_SIGNIN_STATE) { | 124 } else if (state_ == password_manager::ui::AUTO_SIGNIN_STATE) { |
123 // There is no title. | 125 // There is no title. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 | 243 |
242 void ManagePasswordsBubbleModel::OnSaveClicked() { | 244 void ManagePasswordsBubbleModel::OnSaveClicked() { |
243 dismissal_reason_ = metrics_util::CLICKED_SAVE; | 245 dismissal_reason_ = metrics_util::CLICKED_SAVE; |
244 RecordExperimentStatistics(web_contents(), dismissal_reason_); | 246 RecordExperimentStatistics(web_contents(), dismissal_reason_); |
245 ManagePasswordsUIController* manage_passwords_ui_controller = | 247 ManagePasswordsUIController* manage_passwords_ui_controller = |
246 ManagePasswordsUIController::FromWebContents(web_contents()); | 248 ManagePasswordsUIController::FromWebContents(web_contents()); |
247 manage_passwords_ui_controller->SavePassword(); | 249 manage_passwords_ui_controller->SavePassword(); |
248 state_ = password_manager::ui::MANAGE_STATE; | 250 state_ = password_manager::ui::MANAGE_STATE; |
249 } | 251 } |
250 | 252 |
253 void ManagePasswordsBubbleModel::OnUpdateClicked( | |
254 const autofill::PasswordForm& password_form) { | |
255 dismissal_reason_ = metrics_util::CLICKED_UPDATE; | |
256 RecordExperimentStatistics(web_contents(), dismissal_reason_); | |
vasilii
2015/07/27 15:44:49
You should call this only for the "Save?" bubble.
dvadym
2015/07/30 11:22:44
Removed
vabr (Chromium)
2015/07/31 12:48:13
So why don't we gather the statistics here?
vasilii
2015/07/31 14:38:53
Because it's not a save bubble and it should not a
| |
257 ManagePasswordsUIController* manage_passwords_ui_controller = | |
258 ManagePasswordsUIController::FromWebContents(web_contents()); | |
259 manage_passwords_ui_controller->UpdatePassword(password_form); | |
260 state_ = password_manager::ui::MANAGE_STATE; | |
261 } | |
262 | |
251 void ManagePasswordsBubbleModel::OnDoneClicked() { | 263 void ManagePasswordsBubbleModel::OnDoneClicked() { |
252 dismissal_reason_ = metrics_util::CLICKED_DONE; | 264 dismissal_reason_ = metrics_util::CLICKED_DONE; |
253 } | 265 } |
254 | 266 |
255 // TODO(gcasto): Is it worth having this be separate from OnDoneClicked()? | 267 // TODO(gcasto): Is it worth having this be separate from OnDoneClicked()? |
256 // User intent is pretty similar in both cases. | 268 // User intent is pretty similar in both cases. |
257 void ManagePasswordsBubbleModel::OnOKClicked() { | 269 void ManagePasswordsBubbleModel::OnOKClicked() { |
258 dismissal_reason_ = metrics_util::CLICKED_OK; | 270 dismissal_reason_ = metrics_util::CLICKED_OK; |
259 } | 271 } |
260 | 272 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 | 329 |
318 Profile* ManagePasswordsBubbleModel::GetProfile() const { | 330 Profile* ManagePasswordsBubbleModel::GetProfile() const { |
319 return GetProfileFromWebContents(web_contents()); | 331 return GetProfileFromWebContents(web_contents()); |
320 } | 332 } |
321 | 333 |
322 bool ManagePasswordsBubbleModel::IsNewUIActive() const { | 334 bool ManagePasswordsBubbleModel::IsNewUIActive() const { |
323 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 335 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
324 switches::kEnableCredentialManagerAPI); | 336 switches::kEnableCredentialManagerAPI); |
325 } | 337 } |
326 | 338 |
339 bool ManagePasswordsBubbleModel::ShouldShowMultipleAccountUpdateUI() const { | |
340 return state_ == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE && | |
341 local_credentials_.size() > 1; | |
342 } | |
343 | |
327 // static | 344 // static |
328 int ManagePasswordsBubbleModel::UsernameFieldWidth() { | 345 int ManagePasswordsBubbleModel::UsernameFieldWidth() { |
329 return GetFieldWidth(USERNAME_FIELD); | 346 return GetFieldWidth(USERNAME_FIELD); |
330 } | 347 } |
331 | 348 |
332 // static | 349 // static |
333 int ManagePasswordsBubbleModel::PasswordFieldWidth() { | 350 int ManagePasswordsBubbleModel::PasswordFieldWidth() { |
334 return GetFieldWidth(PASSWORD_FIELD); | 351 return GetFieldWidth(PASSWORD_FIELD); |
335 } | 352 } |
336 | 353 |
337 void ManagePasswordsBubbleModel::UpdatePendingStateTitle() { | 354 void ManagePasswordsBubbleModel::UpdatePendingStateTitle() { |
338 title_brand_link_range_ = gfx::Range(); | 355 title_brand_link_range_ = gfx::Range(); |
339 if (never_save_passwords_) { | 356 if (never_save_passwords_) { |
340 title_ = l10n_util::GetStringUTF16( | 357 title_ = l10n_util::GetStringUTF16( |
341 IDS_MANAGE_PASSWORDS_BLACKLIST_CONFIRMATION_TITLE); | 358 IDS_MANAGE_PASSWORDS_BLACKLIST_CONFIRMATION_TITLE); |
342 } else { | 359 } else { |
343 GetSavePasswordDialogTitleTextAndLinkRange( | 360 GetSavePasswordDialogTitleTextAndLinkRange( |
344 web_contents()->GetVisibleURL(), origin(), | 361 web_contents()->GetVisibleURL(), origin(), |
345 IsSmartLockBrandingEnabled(GetProfile()), &title_, | 362 IsSmartLockBrandingEnabled(GetProfile()), |
363 state_ == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE, &title_, | |
346 &title_brand_link_range_); | 364 &title_brand_link_range_); |
347 } | 365 } |
348 } | 366 } |
OLD | NEW |