Chromium Code Reviews| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 password_manager::switches::kEnableAutomaticPasswordSaving) && | 107 password_manager::switches::kEnableAutomaticPasswordSaving) && |
| 108 chrome::VersionInfo::GetChannel() == | 108 chrome::VersionInfo::GetChannel() == |
| 109 chrome::VersionInfo::CHANNEL_UNKNOWN; | 109 chrome::VersionInfo::CHANNEL_UNKNOWN; |
| 110 } | 110 } |
| 111 | 111 |
| 112 bool ChromePasswordManagerClient::IsPasswordManagerEnabledForCurrentPage() | 112 bool ChromePasswordManagerClient::IsPasswordManagerEnabledForCurrentPage() |
| 113 const { | 113 const { |
| 114 DCHECK(web_contents()); | 114 DCHECK(web_contents()); |
| 115 content::NavigationEntry* entry = | 115 content::NavigationEntry* entry = |
| 116 web_contents()->GetController().GetLastCommittedEntry(); | 116 web_contents()->GetController().GetLastCommittedEntry(); |
| 117 bool is_enabled; | |
|
vabr (Chromium)
2015/03/30 10:58:42
Please initialise to false (which seems to be a sa
melandory
2015/04/07 13:14:13
Done.
| |
| 117 if (!entry) { | 118 if (!entry) { |
| 118 // TODO(gcasto): Determine if fix for crbug.com/388246 is relevant here. | 119 // TODO(gcasto): Determine if fix for crbug.com/388246 is relevant here. |
| 119 return true; | 120 is_enabled = true; |
| 121 } else if (IsURLPasswordWebsiteReauth(entry->GetURL())) { | |
| 122 // Disable the password manager for online password management. | |
| 123 is_enabled = false; | |
| 124 } else if (EnabledForSyncSignin()) { | |
| 125 is_enabled = true; | |
| 126 } else { | |
| 127 // Do not fill nor save password when a user is signing in for sync. This | |
| 128 // is because users need to remember their password if they are syncing as | |
| 129 // this is effectively their master password. | |
| 130 is_enabled = entry->GetURL().host() != chrome::kChromeUIChromeSigninHost; | |
| 120 } | 131 } |
| 121 | 132 if (IsLoggingActive()) { |
| 122 // Disable the password manager for online password management. | 133 password_manager::BrowserSavePasswordProgressLogger logger(this); |
| 123 if (IsURLPasswordWebsiteReauth(entry->GetURL())) | 134 logger.LogBoolean(Logger::STRING_CLIENT_CHECK_PRESENT, is_enabled); |
|
vabr (Chromium)
2015/03/30 10:58:42
nit: The Logger's enum name seems a bit outdated.
melandory
2015/04/07 13:14:12
Done.
| |
| 124 return false; | 135 } |
| 125 | 136 return is_enabled; |
| 126 if (EnabledForSyncSignin()) | |
| 127 return true; | |
| 128 | |
| 129 // Do not fill nor save password when a user is signing in for sync. This | |
| 130 // is because users need to remember their password if they are syncing as | |
| 131 // this is effectively their master password. | |
| 132 return entry->GetURL().host() != chrome::kChromeUIChromeSigninHost; | |
| 133 } | 137 } |
| 134 | 138 |
| 135 bool ChromePasswordManagerClient::ShouldFilterAutofillResult( | 139 bool ChromePasswordManagerClient::ShouldFilterAutofillResult( |
| 136 const autofill::PasswordForm& form) { | 140 const autofill::PasswordForm& form) { |
| 137 if (!IsSyncAccountCredential(base::UTF16ToUTF8(form.username_value), | 141 if (!IsSyncAccountCredential(base::UTF16ToUTF8(form.username_value), |
| 138 form.signon_realm)) | 142 form.signon_realm)) |
| 139 return false; | 143 return false; |
| 140 | 144 |
| 141 if (autofill_sync_state_ == DISALLOW_SYNC_CREDENTIALS) { | 145 if (autofill_sync_state_ == DISALLOW_SYNC_CREDENTIALS) { |
| 142 sync_credential_was_filtered_ = true; | 146 sync_credential_was_filtered_ = true; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 340 logger->LogNumber(Logger::STRING_HTTP_STATUS_CODE, http_status_code); | 344 logger->LogNumber(Logger::STRING_HTTP_STATUS_CODE, http_status_code); |
| 341 | 345 |
| 342 if (http_status_code >= 400 && http_status_code < 600) | 346 if (http_status_code >= 400 && http_status_code < 600) |
| 343 return true; | 347 return true; |
| 344 return false; | 348 return false; |
| 345 } | 349 } |
| 346 | 350 |
| 347 bool ChromePasswordManagerClient::DidLastPageLoadEncounterSSLErrors() const { | 351 bool ChromePasswordManagerClient::DidLastPageLoadEncounterSSLErrors() const { |
| 348 content::NavigationEntry* entry = | 352 content::NavigationEntry* entry = |
| 349 web_contents()->GetController().GetLastCommittedEntry(); | 353 web_contents()->GetController().GetLastCommittedEntry(); |
| 350 if (!entry) | 354 bool ssl_errors; |
|
vabr (Chromium)
2015/03/30 10:58:42
Please initialise to true (which seems to be a saf
melandory
2015/04/07 13:14:12
Done.
| |
| 351 return false; | 355 if (!entry) { |
| 352 | 356 ssl_errors = false; |
| 353 return net::IsCertStatusError(entry->GetSSL().cert_status); | 357 } else { |
| 358 ssl_errors = net::IsCertStatusError(entry->GetSSL().cert_status); | |
| 359 } | |
| 360 if (IsLoggingActive()) { | |
| 361 password_manager::BrowserSavePasswordProgressLogger logger(this); | |
| 362 logger.LogBoolean(Logger::STRING_SSL_ERRORS_PRESENT, ssl_errors); | |
| 363 } | |
| 364 return ssl_errors; | |
| 354 } | 365 } |
| 355 | 366 |
| 356 bool ChromePasswordManagerClient::IsOffTheRecord() const { | 367 bool ChromePasswordManagerClient::IsOffTheRecord() const { |
| 357 return web_contents()->GetBrowserContext()->IsOffTheRecord(); | 368 return web_contents()->GetBrowserContext()->IsOffTheRecord(); |
| 358 } | 369 } |
| 359 | 370 |
| 360 password_manager::PasswordManager* | 371 password_manager::PasswordManager* |
| 361 ChromePasswordManagerClient::GetPasswordManager() { | 372 ChromePasswordManagerClient::GetPasswordManager() { |
| 362 return &password_manager_; | 373 return &password_manager_; |
| 363 } | 374 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 553 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS; | 564 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS; |
| 554 } else { | 565 } else { |
| 555 // Allow by default. | 566 // Allow by default. |
| 556 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS; | 567 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS; |
| 557 } | 568 } |
| 558 } | 569 } |
| 559 | 570 |
| 560 const GURL& ChromePasswordManagerClient::GetMainFrameURL() const { | 571 const GURL& ChromePasswordManagerClient::GetMainFrameURL() const { |
| 561 return web_contents()->GetVisibleURL(); | 572 return web_contents()->GetVisibleURL(); |
| 562 } | 573 } |
| OLD | NEW |