| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 if (autofill_sync_state_ == DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH && | 128 if (autofill_sync_state_ == DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH && |
| 129 LastLoadWasTransactionalReauthPage()) { | 129 LastLoadWasTransactionalReauthPage()) { |
| 130 sync_credential_was_filtered_ = true; | 130 sync_credential_was_filtered_ = true; |
| 131 return true; | 131 return true; |
| 132 } | 132 } |
| 133 | 133 |
| 134 return false; | 134 return false; |
| 135 } | 135 } |
| 136 | 136 |
| 137 std::string ChromePasswordManagerClient::GetSyncUsername() const { |
| 138 return password_manager_sync_metrics::GetSyncUsername(profile_); |
| 139 } |
| 140 |
| 137 bool ChromePasswordManagerClient::IsSyncAccountCredential( | 141 bool ChromePasswordManagerClient::IsSyncAccountCredential( |
| 138 const std::string& username, const std::string& origin) const { | 142 const std::string& username, const std::string& origin) const { |
| 139 return password_manager_sync_metrics::IsSyncAccountCredential( | 143 return password_manager_sync_metrics::IsSyncAccountCredential( |
| 140 profile_, username, origin); | 144 profile_, username, origin); |
| 141 } | 145 } |
| 142 | 146 |
| 143 void ChromePasswordManagerClient::AutofillResultsComputed() { | 147 void ChromePasswordManagerClient::AutofillResultsComputed() { |
| 144 UMA_HISTOGRAM_BOOLEAN("PasswordManager.SyncCredentialFiltered", | 148 UMA_HISTOGRAM_BOOLEAN("PasswordManager.SyncCredentialFiltered", |
| 145 sync_credential_was_filtered_); | 149 sync_credential_was_filtered_); |
| 146 sync_credential_was_filtered_ = false; | 150 sync_credential_was_filtered_ = false; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 case chrome::VersionInfo::CHANNEL_BETA: | 234 case chrome::VersionInfo::CHANNEL_BETA: |
| 231 enabled_probability = 50; | 235 enabled_probability = 50; |
| 232 break; | 236 break; |
| 233 default: | 237 default: |
| 234 break; | 238 break; |
| 235 } | 239 } |
| 236 } | 240 } |
| 237 return enabled_probability; | 241 return enabled_probability; |
| 238 } | 242 } |
| 239 | 243 |
| 240 bool ChromePasswordManagerClient::IsPasswordSyncEnabled() { | 244 bool ChromePasswordManagerClient::IsPasswordSyncEnabled( |
| 245 password_manager::CustomPassphraseState state) { |
| 241 ProfileSyncService* sync_service = | 246 ProfileSyncService* sync_service = |
| 242 ProfileSyncServiceFactory::GetForProfile(profile_); | 247 ProfileSyncServiceFactory::GetForProfile(profile_); |
| 243 // Don't consider sync enabled if the user has a custom passphrase. See | |
| 244 // crbug.com/358998 for more details. | |
| 245 if (sync_service && | 248 if (sync_service && |
| 246 sync_service->HasSyncSetupCompleted() && | 249 sync_service->HasSyncSetupCompleted() && |
| 247 sync_service->SyncActive() && | 250 sync_service->SyncActive() && |
| 248 !sync_service->IsUsingSecondaryPassphrase()) { | 251 sync_service->GetActiveDataTypes().Has(syncer::PASSWORDS)) { |
| 249 return sync_service->GetActiveDataTypes().Has(syncer::PASSWORDS); | 252 if (sync_service->IsUsingSecondaryPassphrase()) { |
| 253 return state == password_manager::ONLY_CUSTOM_PASSPHRASE; |
| 254 } else { |
| 255 return state == password_manager::WITHOUT_CUSTOM_PASSPHRASE; |
| 256 } |
| 250 } | 257 } |
| 251 return false; | 258 return false; |
| 252 } | 259 } |
| 253 | 260 |
| 254 void ChromePasswordManagerClient::OnLogRouterAvailabilityChanged( | 261 void ChromePasswordManagerClient::OnLogRouterAvailabilityChanged( |
| 255 bool router_can_be_used) { | 262 bool router_can_be_used) { |
| 256 if (can_use_log_router_ == router_can_be_used) | 263 if (can_use_log_router_ == router_can_be_used) |
| 257 return; | 264 return; |
| 258 can_use_log_router_ = router_can_be_used; | 265 can_use_log_router_ = router_can_be_used; |
| 259 | 266 |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 | 488 |
| 482 if (group_name == "DisallowSyncCredentialsForReauth") { | 489 if (group_name == "DisallowSyncCredentialsForReauth") { |
| 483 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; | 490 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; |
| 484 } else if (group_name == "DisallowSyncCredentials") { | 491 } else if (group_name == "DisallowSyncCredentials") { |
| 485 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS; | 492 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS; |
| 486 } else { | 493 } else { |
| 487 // Allow by default. | 494 // Allow by default. |
| 488 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS; | 495 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS; |
| 489 } | 496 } |
| 490 } | 497 } |
| OLD | NEW |