| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 124 |
| 125 if (EnabledForSyncSignin()) | 125 if (EnabledForSyncSignin()) |
| 126 return true; | 126 return true; |
| 127 | 127 |
| 128 // Do not fill nor save password when a user is signing in for sync. This | 128 // Do not fill nor save password when a user is signing in for sync. This |
| 129 // is because users need to remember their password if they are syncing as | 129 // is because users need to remember their password if they are syncing as |
| 130 // this is effectively their master password. | 130 // this is effectively their master password. |
| 131 return entry->GetURL().host() != chrome::kChromeUIChromeSigninHost; | 131 return entry->GetURL().host() != chrome::kChromeUIChromeSigninHost; |
| 132 } | 132 } |
| 133 | 133 |
| 134 bool ChromePasswordManagerClient::ShouldAskUserToSubmitURL() { | 134 bool ChromePasswordManagerClient::ShouldAskUserToSubmitURL(const GURL& url) { |
| 135 return password_manager::urls_collection_experiment::ShouldShowBubble( | 135 return url.is_valid() && !url.is_empty() && url.has_host() && |
| 136 GetPrefs()); | 136 password_manager::urls_collection_experiment::ShouldShowBubble( |
| 137 GetPrefs()); |
| 137 } | 138 } |
| 138 | 139 |
| 139 bool ChromePasswordManagerClient::ShouldFilterAutofillResult( | 140 bool ChromePasswordManagerClient::ShouldFilterAutofillResult( |
| 140 const autofill::PasswordForm& form) { | 141 const autofill::PasswordForm& form) { |
| 141 if (!IsSyncAccountCredential(base::UTF16ToUTF8(form.username_value), | 142 if (!IsSyncAccountCredential(base::UTF16ToUTF8(form.username_value), |
| 142 form.signon_realm)) | 143 form.signon_realm)) |
| 143 return false; | 144 return false; |
| 144 | 145 |
| 145 if (autofill_sync_state_ == DISALLOW_SYNC_CREDENTIALS) { | 146 if (autofill_sync_state_ == DISALLOW_SYNC_CREDENTIALS) { |
| 146 sync_credential_was_filtered_ = true; | 147 sync_credential_was_filtered_ = true; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 160 return password_manager_sync_metrics::GetSyncUsername(profile_); | 161 return password_manager_sync_metrics::GetSyncUsername(profile_); |
| 161 } | 162 } |
| 162 | 163 |
| 163 bool ChromePasswordManagerClient::IsSyncAccountCredential( | 164 bool ChromePasswordManagerClient::IsSyncAccountCredential( |
| 164 const std::string& username, const std::string& origin) const { | 165 const std::string& username, const std::string& origin) const { |
| 165 return password_manager_sync_metrics::IsSyncAccountCredential( | 166 return password_manager_sync_metrics::IsSyncAccountCredential( |
| 166 profile_, username, origin); | 167 profile_, username, origin); |
| 167 } | 168 } |
| 168 | 169 |
| 169 void ChromePasswordManagerClient::AskUserAndMaybeReportURL( | 170 void ChromePasswordManagerClient::AskUserAndMaybeReportURL( |
| 170 const std::string& url) const { | 171 const GURL& url) const { |
| 171 // TODO(melandory) Show bubble which asks user if he wants to report the URL | 172 ManagePasswordsUIController* manage_passwords_ui_controller = |
| 172 // and report URL if needed. | 173 ManagePasswordsUIController::FromWebContents(web_contents()); |
| 174 manage_passwords_ui_controller->OnAskToReportURL(url); |
| 173 } | 175 } |
| 174 | 176 |
| 175 void ChromePasswordManagerClient::AutofillResultsComputed() { | 177 void ChromePasswordManagerClient::AutofillResultsComputed() { |
| 176 UMA_HISTOGRAM_BOOLEAN("PasswordManager.SyncCredentialFiltered", | 178 UMA_HISTOGRAM_BOOLEAN("PasswordManager.SyncCredentialFiltered", |
| 177 sync_credential_was_filtered_); | 179 sync_credential_was_filtered_); |
| 178 sync_credential_was_filtered_ = false; | 180 sync_credential_was_filtered_ = false; |
| 179 } | 181 } |
| 180 | 182 |
| 181 bool ChromePasswordManagerClient::PromptUserToSavePassword( | 183 bool ChromePasswordManagerClient::PromptUserToSavePassword( |
| 182 scoped_ptr<password_manager::PasswordFormManager> form_to_save) { | 184 scoped_ptr<password_manager::PasswordFormManager> form_to_save) { |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 | 542 |
| 541 if (group_name == "DisallowSyncCredentialsForReauth") { | 543 if (group_name == "DisallowSyncCredentialsForReauth") { |
| 542 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; | 544 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; |
| 543 } else if (group_name == "DisallowSyncCredentials") { | 545 } else if (group_name == "DisallowSyncCredentials") { |
| 544 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS; | 546 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS; |
| 545 } else { | 547 } else { |
| 546 // Allow by default. | 548 // Allow by default. |
| 547 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS; | 549 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS; |
| 548 } | 550 } |
| 549 } | 551 } |
| OLD | NEW |