| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/password_manager/core/browser/password_store_factory_util.h
" | 5 #include "components/password_manager/core/browser/password_store_factory_util.h
" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "components/password_manager/core/browser/affiliated_match_helper.h" | 10 #include "components/password_manager/core/browser/affiliated_match_helper.h" |
| 11 #include "components/password_manager/core/browser/affiliation_service.h" | 11 #include "components/password_manager/core/browser/affiliation_service.h" |
| 12 #include "components/password_manager/core/browser/affiliation_utils.h" | 12 #include "components/password_manager/core/browser/affiliation_utils.h" |
| 13 #include "components/password_manager/core/browser/password_manager_constants.h" | 13 #include "components/password_manager/core/browser/password_manager_constants.h" |
| 14 | 14 |
| 15 namespace password_manager { | 15 namespace password_manager { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 bool ShouldAffiliationBasedMatchingBeActive( | 19 bool ShouldAffiliationBasedMatchingBeActive( |
| 20 sync_driver::SyncService* sync_service) { | 20 sync_driver::SyncService* sync_service) { |
| 21 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 21 if (!IsAffiliationBasedMatchingEnabled()) |
| 22 if (!IsAffiliationBasedMatchingEnabled(*command_line)) | |
| 23 return false; | 22 return false; |
| 24 | 23 |
| 25 return sync_service && sync_service->CanSyncStart() && | 24 return sync_service && sync_service->CanSyncStart() && |
| 26 sync_service->IsSyncActive() && | 25 sync_service->IsSyncActive() && |
| 27 sync_service->GetPreferredDataTypes().Has(syncer::PASSWORDS) && | 26 sync_service->GetPreferredDataTypes().Has(syncer::PASSWORDS) && |
| 28 !sync_service->IsUsingSecondaryPassphrase(); | 27 !sync_service->IsUsingSecondaryPassphrase(); |
| 29 } | 28 } |
| 30 | 29 |
| 31 void ActivateAffiliationBasedMatching( | 30 void ActivateAffiliationBasedMatching( |
| 32 PasswordStore* password_store, | 31 PasswordStore* password_store, |
| 33 net::URLRequestContextGetter* request_context_getter, | 32 net::URLRequestContextGetter* request_context_getter, |
| 34 const base::FilePath& db_path, | 33 const base::FilePath& db_path, |
| 35 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner) { | 34 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner) { |
| 36 // The PasswordStore is so far the only consumer of the AffiliationService, | 35 // The PasswordStore is so far the only consumer of the AffiliationService, |
| 37 // therefore the service is owned by the AffiliatedMatchHelper, which in | 36 // therefore the service is owned by the AffiliatedMatchHelper, which in |
| 38 // turn is owned by the PasswordStore. | 37 // turn is owned by the PasswordStore. |
| 39 scoped_ptr<AffiliationService> affiliation_service( | 38 scoped_ptr<AffiliationService> affiliation_service( |
| 40 new AffiliationService(db_thread_runner)); | 39 new AffiliationService(db_thread_runner)); |
| 41 affiliation_service->Initialize(request_context_getter, db_path); | 40 affiliation_service->Initialize(request_context_getter, db_path); |
| 42 scoped_ptr<AffiliatedMatchHelper> affiliated_match_helper( | 41 scoped_ptr<AffiliatedMatchHelper> affiliated_match_helper( |
| 43 new AffiliatedMatchHelper(password_store, | 42 new AffiliatedMatchHelper(password_store, |
| 44 std::move(affiliation_service))); | 43 std::move(affiliation_service))); |
| 45 affiliated_match_helper->Initialize(); | 44 affiliated_match_helper->Initialize(); |
| 46 password_store->SetAffiliatedMatchHelper(std::move(affiliated_match_helper)); | 45 password_store->SetAffiliatedMatchHelper(std::move(affiliated_match_helper)); |
| 47 | 46 |
| 48 password_store->enable_propagating_password_changes_to_web_credentials( | 47 password_store->enable_propagating_password_changes_to_web_credentials( |
| 49 IsPropagatingPasswordChangesToWebCredentialsEnabled( | 48 IsPropagatingPasswordChangesToWebCredentialsEnabled()); |
| 50 *base::CommandLine::ForCurrentProcess())); | |
| 51 } | 49 } |
| 52 | 50 |
| 53 base::FilePath GetAffiliationDatabasePath(const base::FilePath& profile_path) { | 51 base::FilePath GetAffiliationDatabasePath(const base::FilePath& profile_path) { |
| 54 return profile_path.Append(kAffiliationDatabaseFileName); | 52 return profile_path.Append(kAffiliationDatabaseFileName); |
| 55 } | 53 } |
| 56 | 54 |
| 57 } // namespace | 55 } // namespace |
| 58 | 56 |
| 59 void ToggleAffiliationBasedMatchingBasedOnPasswordSyncedState( | 57 void ToggleAffiliationBasedMatchingBasedOnPasswordSyncedState( |
| 60 PasswordStore* password_store, | 58 PasswordStore* password_store, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 91 } | 89 } |
| 92 } | 90 } |
| 93 | 91 |
| 94 scoped_ptr<LoginDatabase> CreateLoginDatabase( | 92 scoped_ptr<LoginDatabase> CreateLoginDatabase( |
| 95 const base::FilePath& profile_path) { | 93 const base::FilePath& profile_path) { |
| 96 base::FilePath login_db_file_path = profile_path.Append(kLoginDataFileName); | 94 base::FilePath login_db_file_path = profile_path.Append(kLoginDataFileName); |
| 97 return make_scoped_ptr(new LoginDatabase(login_db_file_path)); | 95 return make_scoped_ptr(new LoginDatabase(login_db_file_path)); |
| 98 } | 96 } |
| 99 | 97 |
| 100 } // namespace password_manager | 98 } // namespace password_manager |
| OLD | NEW |