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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 | 128 |
| 129 if (autofill_sync_state_ == DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH && | 129 if (autofill_sync_state_ == DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH && |
| 130 LastLoadWasTransactionalReauthPage()) { | 130 LastLoadWasTransactionalReauthPage()) { |
| 131 sync_credential_was_filtered_ = true; | 131 sync_credential_was_filtered_ = true; |
| 132 return true; | 132 return true; |
| 133 } | 133 } |
| 134 | 134 |
| 135 return false; | 135 return false; |
| 136 } | 136 } |
| 137 | 137 |
| 138 std::string ChromePasswordManagerClient::GetSyncUsername() const { | |
| 139 return password_manager_sync_metrics::GetSyncUsername(profile_); | |
| 140 } | |
| 141 | |
| 138 bool ChromePasswordManagerClient::IsSyncAccountCredential( | 142 bool ChromePasswordManagerClient::IsSyncAccountCredential( |
| 139 const std::string& username, const std::string& origin) const { | 143 const std::string& username, const std::string& origin) const { |
| 140 return password_manager_sync_metrics::IsSyncAccountCredential( | 144 return password_manager_sync_metrics::IsSyncAccountCredential( |
| 141 profile_, username, origin); | 145 profile_, username, origin); |
| 142 } | 146 } |
| 143 | 147 |
| 144 void ChromePasswordManagerClient::AutofillResultsComputed() { | 148 void ChromePasswordManagerClient::AutofillResultsComputed() { |
| 145 UMA_HISTOGRAM_BOOLEAN("PasswordManager.SyncCredentialFiltered", | 149 UMA_HISTOGRAM_BOOLEAN("PasswordManager.SyncCredentialFiltered", |
| 146 sync_credential_was_filtered_); | 150 sync_credential_was_filtered_); |
| 147 sync_credential_was_filtered_ = false; | 151 sync_credential_was_filtered_ = false; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 case chrome::VersionInfo::CHANNEL_BETA: | 240 case chrome::VersionInfo::CHANNEL_BETA: |
| 237 enabled_probability = 50; | 241 enabled_probability = 50; |
| 238 break; | 242 break; |
| 239 default: | 243 default: |
| 240 break; | 244 break; |
| 241 } | 245 } |
| 242 } | 246 } |
| 243 return enabled_probability; | 247 return enabled_probability; |
| 244 } | 248 } |
| 245 | 249 |
| 246 bool ChromePasswordManagerClient::IsPasswordSyncEnabled() { | 250 bool ChromePasswordManagerClient::IsPasswordSyncEnabled( |
| 251 password_manager::CustomPassphraseState state) { | |
| 247 ProfileSyncService* sync_service = | 252 ProfileSyncService* sync_service = |
| 248 ProfileSyncServiceFactory::GetForProfile(profile_); | 253 ProfileSyncServiceFactory::GetForProfile(profile_); |
| 249 // Don't consider sync enabled if the user has a custom passphrase. See | 254 // Don't consider sync enabled if the user has a custom passphrase. See |
| 250 // crbug.com/358998 for more details. | 255 // crbug.com/358998 for more details. |
| 251 if (sync_service && | 256 if (sync_service && |
| 252 sync_service->HasSyncSetupCompleted() && | 257 sync_service->HasSyncSetupCompleted() && |
| 253 sync_service->SyncActive() && | 258 sync_service->SyncActive() && |
| 254 !sync_service->IsUsingSecondaryPassphrase()) { | 259 sync_service->GetActiveDataTypes().Has(syncer::PASSWORDS)) { |
| 255 return sync_service->GetActiveDataTypes().Has(syncer::PASSWORDS); | 260 if (!((state == password_manager::ONLY_CUSTOM_PASSPHRASE_USERS) ^ |
|
vabr (Chromium)
2014/10/13 09:24:18
This is very hard to read, and ^ is a bitwise oper
Garrett Casto
2014/10/13 20:57:56
I actually decided to be even more readable here.
vabr (Chromium)
2014/10/14 07:32:51
The new version looks great. Thanks!
| |
| 261 (sync_service->IsUsingSecondaryPassphrase()))) { | |
| 262 return true; | |
| 263 } | |
| 256 } | 264 } |
| 257 return false; | 265 return false; |
| 258 } | 266 } |
| 259 | 267 |
| 260 void ChromePasswordManagerClient::OnLogRouterAvailabilityChanged( | 268 void ChromePasswordManagerClient::OnLogRouterAvailabilityChanged( |
| 261 bool router_can_be_used) { | 269 bool router_can_be_used) { |
| 262 if (can_use_log_router_ == router_can_be_used) | 270 if (can_use_log_router_ == router_can_be_used) |
| 263 return; | 271 return; |
| 264 can_use_log_router_ = router_can_be_used; | 272 can_use_log_router_ = router_can_be_used; |
| 265 | 273 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 492 | 500 |
| 493 if (group_name == "DisallowSyncCredentialsForReauth") { | 501 if (group_name == "DisallowSyncCredentialsForReauth") { |
| 494 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; | 502 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; |
| 495 } else if (group_name == "DisallowSyncCredentials") { | 503 } else if (group_name == "DisallowSyncCredentials") { |
| 496 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS; | 504 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS; |
| 497 } else { | 505 } else { |
| 498 // Allow by default. | 506 // Allow by default. |
| 499 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS; | 507 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS; |
| 500 } | 508 } |
| 501 } | 509 } |
| OLD | NEW |