| 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 "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 bool ChromePasswordManagerClient::IsAutomaticPasswordSavingEnabled() const { | 86 bool ChromePasswordManagerClient::IsAutomaticPasswordSavingEnabled() const { |
| 87 return CommandLine::ForCurrentProcess()->HasSwitch( | 87 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 88 password_manager::switches::kEnableAutomaticPasswordSaving) && | 88 password_manager::switches::kEnableAutomaticPasswordSaving) && |
| 89 chrome::VersionInfo::GetChannel() == | 89 chrome::VersionInfo::GetChannel() == |
| 90 chrome::VersionInfo::CHANNEL_UNKNOWN; | 90 chrome::VersionInfo::CHANNEL_UNKNOWN; |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool ChromePasswordManagerClient::IsPasswordManagerEnabledForCurrentPage() | 93 bool ChromePasswordManagerClient::IsPasswordManagerEnabledForCurrentPage() |
| 94 const { | 94 const { |
| 95 if (EnabledForSyncSignin()) | |
| 96 return true; | |
| 97 | |
| 98 DCHECK(web_contents()); | 95 DCHECK(web_contents()); |
| 99 content::NavigationEntry* entry = | 96 content::NavigationEntry* entry = |
| 100 web_contents()->GetController().GetLastCommittedEntry(); | 97 web_contents()->GetController().GetLastCommittedEntry(); |
| 101 if (!entry) { | 98 if (!entry) { |
| 102 // TODO(gcasto): Determine if fix for crbug.com/388246 is relevant here. | 99 // TODO(gcasto): Determine if fix for crbug.com/388246 is relevant here. |
| 103 return true; | 100 return true; |
| 104 } | 101 } |
| 102 |
| 103 // Disable the password manager for online password management. |
| 104 if (IsURLPasswordWebsiteReauth(entry->GetURL())) |
| 105 return false; |
| 106 |
| 107 if (EnabledForSyncSignin()) |
| 108 return true; |
| 109 |
| 105 // Do not fill nor save password when a user is signing in for sync. This | 110 // Do not fill nor save password when a user is signing in for sync. This |
| 106 // is because users need to remember their password if they are syncing as | 111 // is because users need to remember their password if they are syncing as |
| 107 // this is effectively their master password. | 112 // this is effectively their master password. |
| 108 return entry->GetURL().host() != chrome::kChromeUIChromeSigninHost; | 113 return entry->GetURL().host() != chrome::kChromeUIChromeSigninHost; |
| 109 } | 114 } |
| 110 | 115 |
| 111 bool ChromePasswordManagerClient::ShouldFilterAutofillResult( | 116 bool ChromePasswordManagerClient::ShouldFilterAutofillResult( |
| 112 const autofill::PasswordForm& form) { | 117 const autofill::PasswordForm& form) { |
| 113 if (!IsSyncAccountCredential(base::UTF16ToUTF8(form.username_value), | 118 if (!IsSyncAccountCredential(base::UTF16ToUTF8(form.username_value), |
| 114 form.signon_realm)) | 119 form.signon_realm)) |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 GaiaUrls::GetInstance()->gaia_url().GetOrigin()) | 401 GaiaUrls::GetInstance()->gaia_url().GetOrigin()) |
| 397 return false; | 402 return false; |
| 398 | 403 |
| 399 // "rart" is the transactional reauth paramter. | 404 // "rart" is the transactional reauth paramter. |
| 400 std::string ignored_value; | 405 std::string ignored_value; |
| 401 return net::GetValueForKeyInQuery(entry->GetURL(), | 406 return net::GetValueForKeyInQuery(entry->GetURL(), |
| 402 "rart", | 407 "rart", |
| 403 &ignored_value); | 408 &ignored_value); |
| 404 } | 409 } |
| 405 | 410 |
| 411 bool ChromePasswordManagerClient::IsURLPasswordWebsiteReauth( |
| 412 const GURL& url) const { |
| 413 if (url.GetOrigin() != GaiaUrls::GetInstance()->gaia_url().GetOrigin()) |
| 414 return false; |
| 415 |
| 416 // "rart" param signals this page is for transactional reauth. |
| 417 std::string param_value; |
| 418 if (!net::GetValueForKeyInQuery(url, "rart", ¶m_value)) |
| 419 return false; |
| 420 |
| 421 // Check the "continue" param to see if this reauth page is for the passwords |
| 422 // website. |
| 423 param_value.clear(); |
| 424 if (!net::GetValueForKeyInQuery(url, "continue", ¶m_value)) |
| 425 return false; |
| 426 |
| 427 return GURL(param_value).host() == |
| 428 GURL(chrome::kPasswordManagerAccountDashboardURL).host(); |
| 429 } |
| 430 |
| 406 bool ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled() { | 431 bool ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled() { |
| 407 #if !defined(USE_AURA) | 432 #if !defined(USE_AURA) |
| 408 return false; | 433 return false; |
| 409 #endif | 434 #endif |
| 410 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 435 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 411 if (command_line->HasSwitch(switches::kDisableSavePasswordBubble)) | 436 if (command_line->HasSwitch(switches::kDisableSavePasswordBubble)) |
| 412 return false; | 437 return false; |
| 413 | 438 |
| 414 if (command_line->HasSwitch(switches::kEnableSavePasswordBubble)) | 439 if (command_line->HasSwitch(switches::kEnableSavePasswordBubble)) |
| 415 return true; | 440 return true; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 | 486 |
| 462 if (group_name == "DisallowSyncCredentialsForReauth") { | 487 if (group_name == "DisallowSyncCredentialsForReauth") { |
| 463 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; | 488 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; |
| 464 } else if (group_name == "DisallowSyncCredentials") { | 489 } else if (group_name == "DisallowSyncCredentials") { |
| 465 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS; | 490 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS; |
| 466 } else { | 491 } else { |
| 467 // Allow by default. | 492 // Allow by default. |
| 468 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS; | 493 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS; |
| 469 } | 494 } |
| 470 } | 495 } |
| OLD | NEW |