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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 static bool ran_once = false; | 76 static bool ran_once = false; |
77 if (ran_once) | 77 if (ran_once) |
78 return; | 78 return; |
79 ran_once = true; | 79 ran_once = true; |
80 | 80 |
81 password_manager::PasswordStore* store = client->GetPasswordStore(); | 81 password_manager::PasswordStore* store = client->GetPasswordStore(); |
82 // May be null in tests. | 82 // May be null in tests. |
83 if (store) { | 83 if (store) { |
84 store->ReportMetrics(client->GetSyncUsername(), | 84 store->ReportMetrics(client->GetSyncUsername(), |
85 client->IsPasswordSyncEnabled( | 85 client->GetPasswordSyncState() == |
86 password_manager::ONLY_CUSTOM_PASSPHRASE)); | 86 password_manager::SYNCING_WITH_CUSTOM_PASSPHRASE); |
87 } | 87 } |
88 UMA_HISTOGRAM_BOOLEAN("PasswordManager.Enabled", password_manager_enabled); | 88 UMA_HISTOGRAM_BOOLEAN("PasswordManager.Enabled", password_manager_enabled); |
89 } | 89 } |
90 | 90 |
91 } // namespace | 91 } // namespace |
92 | 92 |
93 // static | 93 // static |
94 void ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient( | 94 void ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient( |
95 content::WebContents* contents, | 95 content::WebContents* contents, |
96 autofill::AutofillClient* autofill_client) { | 96 autofill::AutofillClient* autofill_client) { |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 password_manager::PasswordStore* | 298 password_manager::PasswordStore* |
299 ChromePasswordManagerClient::GetPasswordStore() const { | 299 ChromePasswordManagerClient::GetPasswordStore() const { |
300 // Always use EXPLICIT_ACCESS as the password manager checks IsOffTheRecord | 300 // Always use EXPLICIT_ACCESS as the password manager checks IsOffTheRecord |
301 // itself when it shouldn't access the PasswordStore. | 301 // itself when it shouldn't access the PasswordStore. |
302 // TODO(gcasto): Is is safe to change this to | 302 // TODO(gcasto): Is is safe to change this to |
303 // ServiceAccessType::IMPLICIT_ACCESS? | 303 // ServiceAccessType::IMPLICIT_ACCESS? |
304 return PasswordStoreFactory::GetForProfile( | 304 return PasswordStoreFactory::GetForProfile( |
305 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); | 305 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); |
306 } | 306 } |
307 | 307 |
308 bool ChromePasswordManagerClient::IsPasswordSyncEnabled( | 308 password_manager::PasswordSyncState |
309 password_manager::CustomPassphraseState state) const { | 309 ChromePasswordManagerClient::GetPasswordSyncState() const { |
310 ProfileSyncService* sync_service = | 310 ProfileSyncService* sync_service = |
311 ProfileSyncServiceFactory::GetForProfile(profile_); | 311 ProfileSyncServiceFactory::GetForProfile(profile_); |
312 if (sync_service && sync_service->HasSyncSetupCompleted() && | 312 if (sync_service && sync_service->HasSyncSetupCompleted() && |
313 sync_service->SyncActive() && | 313 sync_service->SyncActive() && |
314 sync_service->GetActiveDataTypes().Has(syncer::PASSWORDS)) { | 314 sync_service->GetActiveDataTypes().Has(syncer::PASSWORDS)) { |
315 if (sync_service->IsUsingSecondaryPassphrase()) { | 315 return sync_service->IsUsingSecondaryPassphrase() |
316 return state == password_manager::ONLY_CUSTOM_PASSPHRASE; | 316 ? password_manager::SYNCING_WITH_CUSTOM_PASSPHRASE |
317 } else { | 317 : password_manager::SYNCING_NORMAL_ENCRYPTION; |
318 return state == password_manager::WITHOUT_CUSTOM_PASSPHRASE; | |
319 } | |
320 } | 318 } |
321 return false; | 319 return password_manager::NOT_SYNCING_PASSWORDS; |
322 } | 320 } |
323 | 321 |
324 void ChromePasswordManagerClient::OnLogRouterAvailabilityChanged( | 322 void ChromePasswordManagerClient::OnLogRouterAvailabilityChanged( |
325 bool router_can_be_used) { | 323 bool router_can_be_used) { |
326 if (can_use_log_router_ == router_can_be_used) | 324 if (can_use_log_router_ == router_can_be_used) |
327 return; | 325 return; |
328 can_use_log_router_ = router_can_be_used; | 326 can_use_log_router_ = router_can_be_used; |
329 | 327 |
330 NotifyRendererOfLoggingAvailability(); | 328 NotifyRendererOfLoggingAvailability(); |
331 } | 329 } |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS; | 584 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS; |
587 } else { | 585 } else { |
588 // Allow by default. | 586 // Allow by default. |
589 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS; | 587 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS; |
590 } | 588 } |
591 } | 589 } |
592 | 590 |
593 const GURL& ChromePasswordManagerClient::GetMainFrameURL() const { | 591 const GURL& ChromePasswordManagerClient::GetMainFrameURL() const { |
594 return web_contents()->GetVisibleURL(); | 592 return web_contents()->GetVisibleURL(); |
595 } | 593 } |
OLD | NEW |