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/password_manager/chrome_password_manager_client.h" | 5 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
13 #include "base/metrics/field_trial.h" | 13 #include "base/metrics/field_trial.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
16 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 16 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
17 #include "chrome/browser/password_manager/password_store_factory.h" | 17 #include "chrome/browser/password_manager/password_store_factory.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/signin/signin_manager_factory.h" | 19 #include "chrome/browser/signin/signin_manager_factory.h" |
20 #include "chrome/browser/sync/profile_sync_service_factory.h" | 20 #include "chrome/browser/sync/profile_sync_service_factory.h" |
21 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h
" | 21 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h
" |
22 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | 22 #include "chrome/browser/ui/passwords/passwords_client_ui_delegate.h" |
23 #include "chrome/common/channel_info.h" | 23 #include "chrome/common/channel_info.h" |
24 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/common/url_constants.h" | 25 #include "chrome/common/url_constants.h" |
26 #include "components/autofill/content/browser/content_autofill_driver.h" | 26 #include "components/autofill/content/browser/content_autofill_driver.h" |
27 #include "components/autofill/content/browser/content_autofill_driver_factory.h" | 27 #include "components/autofill/content/browser/content_autofill_driver_factory.h" |
28 #include "components/autofill/content/common/autofill_messages.h" | 28 #include "components/autofill/content/common/autofill_messages.h" |
29 #include "components/autofill/core/browser/password_generator.h" | 29 #include "components/autofill/core/browser/password_generator.h" |
30 #include "components/autofill/core/common/password_form.h" | 30 #include "components/autofill/core/common/password_form.h" |
31 #include "components/browser_sync/browser/profile_sync_service.h" | 31 #include "components/browser_sync/browser/profile_sync_service.h" |
32 #include "components/password_manager/content/browser/content_password_manager_d
river.h" | 32 #include "components/password_manager/content/browser/content_password_manager_d
river.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 password_manager::CredentialSourceType type, | 211 password_manager::CredentialSourceType type, |
212 bool update_password) { | 212 bool update_password) { |
213 // Save password infobar and the password bubble prompts in case of | 213 // Save password infobar and the password bubble prompts in case of |
214 // "webby" URLs and do not prompt in case of "non-webby" URLS (e.g. file://). | 214 // "webby" URLs and do not prompt in case of "non-webby" URLS (e.g. file://). |
215 if (!BrowsingDataHelper::IsWebScheme( | 215 if (!BrowsingDataHelper::IsWebScheme( |
216 web_contents()->GetLastCommittedURL().scheme())) { | 216 web_contents()->GetLastCommittedURL().scheme())) { |
217 return false; | 217 return false; |
218 } | 218 } |
219 | 219 |
220 if (IsTheHotNewBubbleUIEnabled()) { | 220 if (IsTheHotNewBubbleUIEnabled()) { |
221 ManagePasswordsUIController* manage_passwords_ui_controller = | 221 PasswordsClientUIDelegate* manage_passwords_ui_controller = |
222 ManagePasswordsUIController::FromWebContents(web_contents()); | 222 PasswordsClientUIDelegateFromWebContents(web_contents()); |
223 if (update_password && IsUpdatePasswordUIEnabled()) { | 223 if (update_password && IsUpdatePasswordUIEnabled()) { |
224 manage_passwords_ui_controller->OnUpdatePasswordSubmitted( | 224 manage_passwords_ui_controller->OnUpdatePasswordSubmitted( |
225 form_to_save.Pass()); | 225 form_to_save.Pass()); |
226 } else { | 226 } else { |
227 manage_passwords_ui_controller->OnPasswordSubmitted(form_to_save.Pass()); | 227 manage_passwords_ui_controller->OnPasswordSubmitted(form_to_save.Pass()); |
228 } | 228 } |
229 } else { | 229 } else { |
230 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 230 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
231 if (form_to_save->IsBlacklisted()) | 231 if (form_to_save->IsBlacklisted()) |
232 return false; | 232 return false; |
233 std::string uma_histogram_suffix( | 233 std::string uma_histogram_suffix( |
234 password_manager::metrics_util::GroupIdToString( | 234 password_manager::metrics_util::GroupIdToString( |
235 password_manager::metrics_util::MonitoredDomainGroupId( | 235 password_manager::metrics_util::MonitoredDomainGroupId( |
236 form_to_save->pending_credentials().signon_realm, GetPrefs()))); | 236 form_to_save->pending_credentials().signon_realm, GetPrefs()))); |
237 SavePasswordInfoBarDelegate::Create( | 237 SavePasswordInfoBarDelegate::Create( |
238 web_contents(), form_to_save.Pass(), uma_histogram_suffix, type); | 238 web_contents(), form_to_save.Pass(), uma_histogram_suffix, type); |
239 #else | 239 #else |
240 NOTREACHED() << "Aura platforms should always use the bubble"; | 240 NOTREACHED() << "Aura platforms should always use the bubble"; |
241 #endif | 241 #endif |
242 } | 242 } |
243 return true; | 243 return true; |
244 } | 244 } |
245 | 245 |
246 bool ChromePasswordManagerClient::PromptUserToChooseCredentials( | 246 bool ChromePasswordManagerClient::PromptUserToChooseCredentials( |
247 ScopedVector<autofill::PasswordForm> local_forms, | 247 ScopedVector<autofill::PasswordForm> local_forms, |
248 ScopedVector<autofill::PasswordForm> federated_forms, | 248 ScopedVector<autofill::PasswordForm> federated_forms, |
249 const GURL& origin, | 249 const GURL& origin, |
250 base::Callback<void(const password_manager::CredentialInfo&)> callback) { | 250 base::Callback<void(const password_manager::CredentialInfo&)> callback) { |
251 return ManagePasswordsUIController::FromWebContents(web_contents())-> | 251 return PasswordsClientUIDelegateFromWebContents(web_contents()) |
252 OnChooseCredentials(local_forms.Pass(), federated_forms.Pass(), origin, | 252 ->OnChooseCredentials(local_forms.Pass(), federated_forms.Pass(), origin, |
253 callback); | 253 callback); |
254 } | 254 } |
255 | 255 |
256 void ChromePasswordManagerClient::ForceSavePassword() { | 256 void ChromePasswordManagerClient::ForceSavePassword() { |
257 password_manager::ContentPasswordManagerDriver* driver = | 257 password_manager::ContentPasswordManagerDriver* driver = |
258 driver_factory_->GetDriverForFrame(web_contents()->GetFocusedFrame()); | 258 driver_factory_->GetDriverForFrame(web_contents()->GetFocusedFrame()); |
259 driver->ForceSavePassword(); | 259 driver->ForceSavePassword(); |
260 } | 260 } |
261 | 261 |
262 void ChromePasswordManagerClient::NotifyUserAutoSignin( | 262 void ChromePasswordManagerClient::NotifyUserAutoSignin( |
263 ScopedVector<autofill::PasswordForm> local_forms) { | 263 ScopedVector<autofill::PasswordForm> local_forms) { |
264 DCHECK(!local_forms.empty()); | 264 DCHECK(!local_forms.empty()); |
265 #if defined(OS_ANDROID) | 265 #if defined(OS_ANDROID) |
266 ShowAutoSigninPrompt(web_contents(), local_forms[0]->username_value); | 266 ShowAutoSigninPrompt(web_contents(), local_forms[0]->username_value); |
267 #else | 267 #else |
268 ManagePasswordsUIController::FromWebContents(web_contents())-> | 268 PasswordsClientUIDelegateFromWebContents(web_contents()) |
269 OnAutoSignin(local_forms.Pass()); | 269 ->OnAutoSignin(local_forms.Pass()); |
270 | 270 |
271 #endif | 271 #endif |
272 } | 272 } |
273 | 273 |
274 void ChromePasswordManagerClient::AutomaticPasswordSave( | 274 void ChromePasswordManagerClient::AutomaticPasswordSave( |
275 scoped_ptr<password_manager::PasswordFormManager> saved_form) { | 275 scoped_ptr<password_manager::PasswordFormManager> saved_form) { |
276 #if defined(OS_ANDROID) | 276 #if defined(OS_ANDROID) |
277 GeneratedPasswordSavedInfoBarDelegateAndroid::Create(web_contents()); | 277 GeneratedPasswordSavedInfoBarDelegateAndroid::Create(web_contents()); |
278 #else | 278 #else |
279 if (IsTheHotNewBubbleUIEnabled()) { | 279 if (IsTheHotNewBubbleUIEnabled()) { |
280 ManagePasswordsUIController* manage_passwords_ui_controller = | 280 PasswordsClientUIDelegate* manage_passwords_ui_controller = |
281 ManagePasswordsUIController::FromWebContents(web_contents()); | 281 PasswordsClientUIDelegateFromWebContents(web_contents()); |
282 manage_passwords_ui_controller->OnAutomaticPasswordSave( | 282 manage_passwords_ui_controller->OnAutomaticPasswordSave( |
283 saved_form.Pass()); | 283 saved_form.Pass()); |
284 } | 284 } |
285 #endif | 285 #endif |
286 } | 286 } |
287 | 287 |
288 void ChromePasswordManagerClient::PasswordWasAutofilled( | 288 void ChromePasswordManagerClient::PasswordWasAutofilled( |
289 const autofill::PasswordFormMap& best_matches, | 289 const autofill::PasswordFormMap& best_matches, |
290 const GURL& origin) const { | 290 const GURL& origin) const { |
291 ManagePasswordsUIController* manage_passwords_ui_controller = | 291 PasswordsClientUIDelegate* manage_passwords_ui_controller = |
292 ManagePasswordsUIController::FromWebContents(web_contents()); | 292 PasswordsClientUIDelegateFromWebContents(web_contents()); |
293 if (manage_passwords_ui_controller && IsTheHotNewBubbleUIEnabled()) | 293 if (manage_passwords_ui_controller && IsTheHotNewBubbleUIEnabled()) |
294 manage_passwords_ui_controller->OnPasswordAutofilled(best_matches, origin); | 294 manage_passwords_ui_controller->OnPasswordAutofilled(best_matches, origin); |
295 } | 295 } |
296 | 296 |
297 void ChromePasswordManagerClient::HidePasswordGenerationPopup() { | 297 void ChromePasswordManagerClient::HidePasswordGenerationPopup() { |
298 if (popup_controller_) | 298 if (popup_controller_) |
299 popup_controller_->HideAndDestroy(); | 299 popup_controller_->HideAndDestroy(); |
300 } | 300 } |
301 | 301 |
302 PrefService* ChromePasswordManagerClient::GetPrefs() { | 302 PrefService* ChromePasswordManagerClient::GetPrefs() { |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 | 523 |
524 const password_manager::CredentialsFilter* | 524 const password_manager::CredentialsFilter* |
525 ChromePasswordManagerClient::GetStoreResultFilter() const { | 525 ChromePasswordManagerClient::GetStoreResultFilter() const { |
526 return &credentials_filter_; | 526 return &credentials_filter_; |
527 } | 527 } |
528 | 528 |
529 const password_manager::LogManager* ChromePasswordManagerClient::GetLogManager() | 529 const password_manager::LogManager* ChromePasswordManagerClient::GetLogManager() |
530 const { | 530 const { |
531 return log_manager_.get(); | 531 return log_manager_.get(); |
532 } | 532 } |
OLD | NEW |