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 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #include "components/signin/core/browser/signin_manager.h" | 52 #include "components/signin/core/browser/signin_manager.h" |
53 #include "components/version_info/version_info.h" | 53 #include "components/version_info/version_info.h" |
54 #include "content/public/browser/navigation_entry.h" | 54 #include "content/public/browser/navigation_entry.h" |
55 #include "content/public/browser/render_view_host.h" | 55 #include "content/public/browser/render_view_host.h" |
56 #include "content/public/browser/ssl_status.h" | 56 #include "content/public/browser/ssl_status.h" |
57 #include "content/public/browser/web_contents.h" | 57 #include "content/public/browser/web_contents.h" |
58 #include "google_apis/gaia/gaia_urls.h" | 58 #include "google_apis/gaia/gaia_urls.h" |
59 #include "net/base/url_util.h" | 59 #include "net/base/url_util.h" |
60 #include "third_party/re2/src/re2/re2.h" | 60 #include "third_party/re2/src/re2/re2.h" |
61 | 61 |
62 #if BUILDFLAG(ANDROID_JAVA_UI) | 62 #if defined(OS_ANDROID) |
63 #include "chrome/browser/android/tab_android.h" | 63 #include "chrome/browser/android/tab_android.h" |
64 #include "chrome/browser/password_manager/account_chooser_dialog_android.h" | 64 #include "chrome/browser/password_manager/account_chooser_dialog_android.h" |
65 #include "chrome/browser/password_manager/auto_signin_first_run_dialog_android.h
" | 65 #include "chrome/browser/password_manager/auto_signin_first_run_dialog_android.h
" |
66 #include "chrome/browser/password_manager/generated_password_saved_infobar_deleg
ate_android.h" | 66 #include "chrome/browser/password_manager/generated_password_saved_infobar_deleg
ate_android.h" |
67 #include "chrome/browser/password_manager/save_password_infobar_delegate_android
.h" | 67 #include "chrome/browser/password_manager/save_password_infobar_delegate_android
.h" |
68 #include "chrome/browser/password_manager/update_password_infobar_delegate_andro
id.h" | 68 #include "chrome/browser/password_manager/update_password_infobar_delegate_andro
id.h" |
69 #include "chrome/browser/ui/android/snackbars/auto_signin_prompt_controller.h" | 69 #include "chrome/browser/ui/android/snackbars/auto_signin_prompt_controller.h" |
70 #endif | 70 #endif |
71 | 71 |
72 using password_manager::ContentPasswordManagerDriverFactory; | 72 using password_manager::ContentPasswordManagerDriverFactory; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 std::unique_ptr<password_manager::PasswordFormManager> form_to_save, | 230 std::unique_ptr<password_manager::PasswordFormManager> form_to_save, |
231 password_manager::CredentialSourceType type, | 231 password_manager::CredentialSourceType type, |
232 bool update_password) { | 232 bool update_password) { |
233 // Save password infobar and the password bubble prompts in case of | 233 // Save password infobar and the password bubble prompts in case of |
234 // "webby" URLs and do not prompt in case of "non-webby" URLS (e.g. file://). | 234 // "webby" URLs and do not prompt in case of "non-webby" URLS (e.g. file://). |
235 if (!BrowsingDataHelper::IsWebScheme( | 235 if (!BrowsingDataHelper::IsWebScheme( |
236 web_contents()->GetLastCommittedURL().scheme())) { | 236 web_contents()->GetLastCommittedURL().scheme())) { |
237 return false; | 237 return false; |
238 } | 238 } |
239 | 239 |
240 #if !BUILDFLAG(ANDROID_JAVA_UI) | 240 #if !defined(OS_ANDROID) |
241 PasswordsClientUIDelegate* manage_passwords_ui_controller = | 241 PasswordsClientUIDelegate* manage_passwords_ui_controller = |
242 PasswordsClientUIDelegateFromWebContents(web_contents()); | 242 PasswordsClientUIDelegateFromWebContents(web_contents()); |
243 if (update_password) { | 243 if (update_password) { |
244 manage_passwords_ui_controller->OnUpdatePasswordSubmitted( | 244 manage_passwords_ui_controller->OnUpdatePasswordSubmitted( |
245 std::move(form_to_save)); | 245 std::move(form_to_save)); |
246 } else { | 246 } else { |
247 manage_passwords_ui_controller->OnPasswordSubmitted( | 247 manage_passwords_ui_controller->OnPasswordSubmitted( |
248 std::move(form_to_save)); | 248 std::move(form_to_save)); |
249 } | 249 } |
250 #else | 250 #else |
251 if (form_to_save->IsBlacklisted()) | 251 if (form_to_save->IsBlacklisted()) |
252 return false; | 252 return false; |
253 | 253 |
254 if (update_password) { | 254 if (update_password) { |
255 UpdatePasswordInfoBarDelegate::Create(web_contents(), | 255 UpdatePasswordInfoBarDelegate::Create(web_contents(), |
256 std::move(form_to_save)); | 256 std::move(form_to_save)); |
257 return true; | 257 return true; |
258 } | 258 } |
259 SavePasswordInfoBarDelegate::Create(web_contents(), | 259 SavePasswordInfoBarDelegate::Create(web_contents(), |
260 std::move(form_to_save)); | 260 std::move(form_to_save)); |
261 #endif // !BUILDFLAG(ANDROID_JAVA_UI) | 261 #endif // !defined(OS_ANDROID) |
262 return true; | 262 return true; |
263 } | 263 } |
264 | 264 |
265 bool ChromePasswordManagerClient::PromptUserToChooseCredentials( | 265 bool ChromePasswordManagerClient::PromptUserToChooseCredentials( |
266 std::vector<std::unique_ptr<autofill::PasswordForm>> local_forms, | 266 std::vector<std::unique_ptr<autofill::PasswordForm>> local_forms, |
267 const GURL& origin, | 267 const GURL& origin, |
268 const CredentialsCallback& callback) { | 268 const CredentialsCallback& callback) { |
269 // Set up an intercept callback if the prompt is zero-clickable (e.g. just one | 269 // Set up an intercept callback if the prompt is zero-clickable (e.g. just one |
270 // form provided). | 270 // form provided). |
271 CredentialsCallback intercept = | 271 CredentialsCallback intercept = |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 driver->GeneratePassword(); | 310 driver->GeneratePassword(); |
311 } | 311 } |
312 | 312 |
313 void ChromePasswordManagerClient::NotifyUserAutoSignin( | 313 void ChromePasswordManagerClient::NotifyUserAutoSignin( |
314 std::vector<std::unique_ptr<autofill::PasswordForm>> local_forms, | 314 std::vector<std::unique_ptr<autofill::PasswordForm>> local_forms, |
315 const GURL& origin) { | 315 const GURL& origin) { |
316 DCHECK(!local_forms.empty()); | 316 DCHECK(!local_forms.empty()); |
317 // If a site gets back a credential some navigations are likely to occur. They | 317 // If a site gets back a credential some navigations are likely to occur. They |
318 // shouldn't trigger the autofill password manager. | 318 // shouldn't trigger the autofill password manager. |
319 password_manager_.DropFormManagers(); | 319 password_manager_.DropFormManagers(); |
320 #if BUILDFLAG(ANDROID_JAVA_UI) | 320 #if defined(OS_ANDROID) |
321 ShowAutoSigninPrompt(web_contents(), local_forms[0]->username_value); | 321 ShowAutoSigninPrompt(web_contents(), local_forms[0]->username_value); |
322 #else | 322 #else |
323 PasswordsClientUIDelegateFromWebContents(web_contents()) | 323 PasswordsClientUIDelegateFromWebContents(web_contents()) |
324 ->OnAutoSignin(std::move(local_forms), origin); | 324 ->OnAutoSignin(std::move(local_forms), origin); |
325 #endif | 325 #endif |
326 } | 326 } |
327 | 327 |
328 void ChromePasswordManagerClient::NotifyUserCouldBeAutoSignedIn( | 328 void ChromePasswordManagerClient::NotifyUserCouldBeAutoSignedIn( |
329 std::unique_ptr<autofill::PasswordForm> form) { | 329 std::unique_ptr<autofill::PasswordForm> form) { |
330 possible_auto_sign_in_ = std::move(form); | 330 possible_auto_sign_in_ = std::move(form); |
(...skipping 13 matching lines...) Expand all Loading... |
344 } | 344 } |
345 | 345 |
346 void ChromePasswordManagerClient::NotifyStorePasswordCalled() { | 346 void ChromePasswordManagerClient::NotifyStorePasswordCalled() { |
347 // If a site stores a credential the autofill password manager shouldn't kick | 347 // If a site stores a credential the autofill password manager shouldn't kick |
348 // in. | 348 // in. |
349 password_manager_.DropFormManagers(); | 349 password_manager_.DropFormManagers(); |
350 } | 350 } |
351 | 351 |
352 void ChromePasswordManagerClient::AutomaticPasswordSave( | 352 void ChromePasswordManagerClient::AutomaticPasswordSave( |
353 std::unique_ptr<password_manager::PasswordFormManager> saved_form) { | 353 std::unique_ptr<password_manager::PasswordFormManager> saved_form) { |
354 #if BUILDFLAG(ANDROID_JAVA_UI) | 354 #if defined(OS_ANDROID) |
355 GeneratedPasswordSavedInfoBarDelegateAndroid::Create(web_contents()); | 355 GeneratedPasswordSavedInfoBarDelegateAndroid::Create(web_contents()); |
356 #else | 356 #else |
357 PasswordsClientUIDelegate* manage_passwords_ui_controller = | 357 PasswordsClientUIDelegate* manage_passwords_ui_controller = |
358 PasswordsClientUIDelegateFromWebContents(web_contents()); | 358 PasswordsClientUIDelegateFromWebContents(web_contents()); |
359 manage_passwords_ui_controller->OnAutomaticPasswordSave( | 359 manage_passwords_ui_controller->OnAutomaticPasswordSave( |
360 std::move(saved_form)); | 360 std::move(saved_form)); |
361 #endif | 361 #endif |
362 } | 362 } |
363 | 363 |
364 void ChromePasswordManagerClient::PasswordWasAutofilled( | 364 void ChromePasswordManagerClient::PasswordWasAutofilled( |
365 const std::map<base::string16, const autofill::PasswordForm*>& best_matches, | 365 const std::map<base::string16, const autofill::PasswordForm*>& best_matches, |
366 const GURL& origin, | 366 const GURL& origin, |
367 const std::vector<const autofill::PasswordForm*>* federated_matches) const { | 367 const std::vector<const autofill::PasswordForm*>* federated_matches) const { |
368 #if !BUILDFLAG(ANDROID_JAVA_UI) | 368 #if !defined(OS_ANDROID) |
369 PasswordsClientUIDelegate* manage_passwords_ui_controller = | 369 PasswordsClientUIDelegate* manage_passwords_ui_controller = |
370 PasswordsClientUIDelegateFromWebContents(web_contents()); | 370 PasswordsClientUIDelegateFromWebContents(web_contents()); |
371 manage_passwords_ui_controller->OnPasswordAutofilled(best_matches, origin, | 371 manage_passwords_ui_controller->OnPasswordAutofilled(best_matches, origin, |
372 federated_matches); | 372 federated_matches); |
373 #endif | 373 #endif |
374 } | 374 } |
375 | 375 |
376 void ChromePasswordManagerClient::HidePasswordGenerationPopup() { | 376 void ChromePasswordManagerClient::HidePasswordGenerationPopup() { |
377 if (popup_controller_) | 377 if (popup_controller_) |
378 popup_controller_->HideAndDestroy(); | 378 popup_controller_->HideAndDestroy(); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 } | 537 } |
538 | 538 |
539 void ChromePasswordManagerClient::PromptUserToEnableAutosigninIfNecessary() { | 539 void ChromePasswordManagerClient::PromptUserToEnableAutosigninIfNecessary() { |
540 if (!password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience( | 540 if (!password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience( |
541 GetPrefs()) || | 541 GetPrefs()) || |
542 !GetPrefs()->GetBoolean( | 542 !GetPrefs()->GetBoolean( |
543 password_manager::prefs::kCredentialsEnableAutosignin) || | 543 password_manager::prefs::kCredentialsEnableAutosignin) || |
544 IsOffTheRecord()) | 544 IsOffTheRecord()) |
545 return; | 545 return; |
546 | 546 |
547 #if BUILDFLAG(ANDROID_JAVA_UI) | 547 #if defined(OS_ANDROID) |
548 // Dialog is deleted by the Java counterpart after user interacts with it. | 548 // Dialog is deleted by the Java counterpart after user interacts with it. |
549 AutoSigninFirstRunDialogAndroid* auto_signin_first_run_dialog = | 549 AutoSigninFirstRunDialogAndroid* auto_signin_first_run_dialog = |
550 new AutoSigninFirstRunDialogAndroid(web_contents()); | 550 new AutoSigninFirstRunDialogAndroid(web_contents()); |
551 auto_signin_first_run_dialog->ShowDialog(); | 551 auto_signin_first_run_dialog->ShowDialog(); |
552 #else | 552 #else |
553 PasswordsClientUIDelegateFromWebContents(web_contents()) | 553 PasswordsClientUIDelegateFromWebContents(web_contents()) |
554 ->OnPromptEnableAutoSignin(); | 554 ->OnPromptEnableAutoSignin(); |
555 #endif | 555 #endif |
556 } | 556 } |
557 | 557 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 ChromePasswordManagerClient::FromWebContents(web_contents); | 636 ChromePasswordManagerClient::FromWebContents(web_contents); |
637 | 637 |
638 // Try to bind to the driver, but if driver is not available for this render | 638 // Try to bind to the driver, but if driver is not available for this render |
639 // frame host, the request will be just dropped. This will cause the message | 639 // frame host, the request will be just dropped. This will cause the message |
640 // pipe to be closed, which will raise a connection error on the peer side. | 640 // pipe to be closed, which will raise a connection error on the peer side. |
641 if (!instance) | 641 if (!instance) |
642 return; | 642 return; |
643 | 643 |
644 instance->credential_manager_impl_.BindRequest(std::move(request)); | 644 instance->credential_manager_impl_.BindRequest(std::move(request)); |
645 } | 645 } |
OLD | NEW |