OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_ui_controller.h" | 5 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "chrome/grit/generated_resources.h" | 25 #include "chrome/grit/generated_resources.h" |
26 #include "components/password_manager/core/browser/browser_save_password_progres
s_logger.h" | 26 #include "components/password_manager/core/browser/browser_save_password_progres
s_logger.h" |
27 #include "components/password_manager/core/browser/password_bubble_experiment.h" | 27 #include "components/password_manager/core/browser/password_bubble_experiment.h" |
28 #include "components/password_manager/core/browser/password_form_manager.h" | 28 #include "components/password_manager/core/browser/password_form_manager.h" |
29 #include "components/password_manager/core/browser/password_manager_constants.h" | 29 #include "components/password_manager/core/browser/password_manager_constants.h" |
30 #include "components/password_manager/core/browser/statistics_table.h" | 30 #include "components/password_manager/core/browser/statistics_table.h" |
31 #include "components/password_manager/core/common/credential_manager_types.h" | 31 #include "components/password_manager/core/common/credential_manager_types.h" |
32 #include "content/public/browser/navigation_details.h" | 32 #include "content/public/browser/navigation_details.h" |
33 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
34 | 34 |
35 using autofill::PasswordFormMap; | |
36 using password_manager::PasswordFormManager; | 35 using password_manager::PasswordFormManager; |
37 | 36 |
38 namespace { | 37 namespace { |
39 | 38 |
40 password_manager::PasswordStore* GetPasswordStore( | 39 password_manager::PasswordStore* GetPasswordStore( |
41 content::WebContents* web_contents) { | 40 content::WebContents* web_contents) { |
42 return PasswordStoreFactory::GetForProfile( | 41 return PasswordStoreFactory::GetForProfile( |
43 Profile::FromBrowserContext(web_contents->GetBrowserContext()), | 42 Profile::FromBrowserContext(web_contents->GetBrowserContext()), |
44 ServiceAccessType::EXPLICIT_ACCESS).get(); | 43 ServiceAccessType::EXPLICIT_ACCESS).get(); |
45 } | 44 } |
(...skipping 24 matching lines...) Expand all Loading... |
70 } | 69 } |
71 | 70 |
72 ManagePasswordsUIController::~ManagePasswordsUIController() {} | 71 ManagePasswordsUIController::~ManagePasswordsUIController() {} |
73 | 72 |
74 void ManagePasswordsUIController::OnPasswordSubmitted( | 73 void ManagePasswordsUIController::OnPasswordSubmitted( |
75 std::unique_ptr<PasswordFormManager> form_manager) { | 74 std::unique_ptr<PasswordFormManager> form_manager) { |
76 bool show_bubble = !form_manager->IsBlacklisted(); | 75 bool show_bubble = !form_manager->IsBlacklisted(); |
77 DestroyAccountChooser(); | 76 DestroyAccountChooser(); |
78 passwords_data_.OnPendingPassword(std::move(form_manager)); | 77 passwords_data_.OnPendingPassword(std::move(form_manager)); |
79 if (show_bubble) { | 78 if (show_bubble) { |
80 password_manager::InteractionsStats* stats = GetCurrentInteractionStats(); | 79 const password_manager::InteractionsStats* stats = |
| 80 GetCurrentInteractionStats(); |
81 const int show_threshold = | 81 const int show_threshold = |
82 password_bubble_experiment::GetSmartBubbleDismissalThreshold(); | 82 password_bubble_experiment::GetSmartBubbleDismissalThreshold(); |
83 if (stats && show_threshold > 0 && stats->dismissal_count >= show_threshold) | 83 if (stats && show_threshold > 0 && stats->dismissal_count >= show_threshold) |
84 show_bubble = false; | 84 show_bubble = false; |
85 } | 85 } |
86 if (show_bubble) | 86 if (show_bubble) |
87 bubble_status_ = SHOULD_POP_UP; | 87 bubble_status_ = SHOULD_POP_UP; |
88 UpdateBubbleAndIconVisibility(); | 88 UpdateBubbleAndIconVisibility(); |
89 } | 89 } |
90 | 90 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 142 |
143 void ManagePasswordsUIController::OnAutomaticPasswordSave( | 143 void ManagePasswordsUIController::OnAutomaticPasswordSave( |
144 std::unique_ptr<PasswordFormManager> form_manager) { | 144 std::unique_ptr<PasswordFormManager> form_manager) { |
145 DestroyAccountChooser(); | 145 DestroyAccountChooser(); |
146 passwords_data_.OnAutomaticPasswordSave(std::move(form_manager)); | 146 passwords_data_.OnAutomaticPasswordSave(std::move(form_manager)); |
147 bubble_status_ = SHOULD_POP_UP; | 147 bubble_status_ = SHOULD_POP_UP; |
148 UpdateBubbleAndIconVisibility(); | 148 UpdateBubbleAndIconVisibility(); |
149 } | 149 } |
150 | 150 |
151 void ManagePasswordsUIController::OnPasswordAutofilled( | 151 void ManagePasswordsUIController::OnPasswordAutofilled( |
152 const autofill::PasswordFormMap& password_form_map, | 152 const std::map<base::string16, const autofill::PasswordForm*>& |
| 153 password_form_map, |
153 const GURL& origin, | 154 const GURL& origin, |
154 const std::vector<std::unique_ptr<autofill::PasswordForm>>* | 155 const std::vector<const autofill::PasswordForm*>* federated_matches) { |
155 federated_matches) { | |
156 // To change to managed state only when the managed state is more important | 156 // To change to managed state only when the managed state is more important |
157 // for the user that the current state. | 157 // for the user that the current state. |
158 if (passwords_data_.state() == password_manager::ui::INACTIVE_STATE || | 158 if (passwords_data_.state() == password_manager::ui::INACTIVE_STATE || |
159 passwords_data_.state() == password_manager::ui::MANAGE_STATE) { | 159 passwords_data_.state() == password_manager::ui::MANAGE_STATE) { |
160 passwords_data_.OnPasswordAutofilled(password_form_map, origin, | 160 passwords_data_.OnPasswordAutofilled(password_form_map, origin, |
161 federated_matches); | 161 federated_matches); |
162 UpdateBubbleAndIconVisibility(); | 162 UpdateBubbleAndIconVisibility(); |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 const std::vector<std::unique_ptr<autofill::PasswordForm>>& | 234 const std::vector<std::unique_ptr<autofill::PasswordForm>>& |
235 ManagePasswordsUIController::GetCurrentForms() const { | 235 ManagePasswordsUIController::GetCurrentForms() const { |
236 return passwords_data_.GetCurrentForms(); | 236 return passwords_data_.GetCurrentForms(); |
237 } | 237 } |
238 | 238 |
239 const std::vector<std::unique_ptr<autofill::PasswordForm>>& | 239 const std::vector<std::unique_ptr<autofill::PasswordForm>>& |
240 ManagePasswordsUIController::GetFederatedForms() const { | 240 ManagePasswordsUIController::GetFederatedForms() const { |
241 return passwords_data_.federation_providers_forms(); | 241 return passwords_data_.federation_providers_forms(); |
242 } | 242 } |
243 | 243 |
244 password_manager::InteractionsStats* | 244 const password_manager::InteractionsStats* |
245 ManagePasswordsUIController::GetCurrentInteractionStats() const { | 245 ManagePasswordsUIController::GetCurrentInteractionStats() const { |
246 DCHECK_EQ(password_manager::ui::PENDING_PASSWORD_STATE, GetState()); | 246 DCHECK_EQ(password_manager::ui::PENDING_PASSWORD_STATE, GetState()); |
247 password_manager::PasswordFormManager* form_manager = | 247 password_manager::PasswordFormManager* form_manager = |
248 passwords_data_.form_manager(); | 248 passwords_data_.form_manager(); |
249 return password_manager::FindStatsByUsername( | 249 return password_manager::FindStatsByUsername( |
250 form_manager->interactions_stats(), | 250 form_manager->interactions_stats(), |
251 form_manager->pending_credentials().username_value); | 251 form_manager->pending_credentials().username_value); |
252 } | 252 } |
253 | 253 |
254 void ManagePasswordsUIController::OnBubbleShown() { | 254 void ManagePasswordsUIController::OnBubbleShown() { |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); | 453 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); |
454 } | 454 } |
455 } | 455 } |
456 | 456 |
457 void ManagePasswordsUIController::WebContentsDestroyed() { | 457 void ManagePasswordsUIController::WebContentsDestroyed() { |
458 password_manager::PasswordStore* password_store = | 458 password_manager::PasswordStore* password_store = |
459 GetPasswordStore(web_contents()); | 459 GetPasswordStore(web_contents()); |
460 if (password_store) | 460 if (password_store) |
461 password_store->RemoveObserver(this); | 461 password_store->RemoveObserver(this); |
462 } | 462 } |
OLD | NEW |