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