OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/browsing_data/browsing_data_counter_factory.h" | 5 #include "chrome/browser/browsing_data/browsing_data_counter_factory.h" |
6 | 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" |
7 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
8 #include "chrome/browser/browsing_data/autofill_counter.h" | |
9 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" | 10 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" |
10 #include "chrome/browser/browsing_data/cache_counter.h" | 11 #include "chrome/browser/browsing_data/cache_counter.h" |
11 #include "chrome/browser/browsing_data/downloads_counter.h" | 12 #include "chrome/browser/browsing_data/downloads_counter.h" |
12 #include "chrome/browser/browsing_data/history_counter.h" | |
13 #include "chrome/browser/browsing_data/media_licenses_counter.h" | 13 #include "chrome/browser/browsing_data/media_licenses_counter.h" |
14 #include "chrome/browser/browsing_data/passwords_counter.h" | 14 #include "chrome/browser/history/history_service_factory.h" |
| 15 #include "chrome/browser/history/web_history_service_factory.h" |
| 16 #include "chrome/browser/password_manager/password_store_factory.h" |
15 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 19 #include "chrome/browser/web_data_service_factory.h" |
| 20 #include "components/browsing_data/core/counters/autofill_counter.h" |
16 #include "components/browsing_data/core/counters/browsing_data_counter.h" | 21 #include "components/browsing_data/core/counters/browsing_data_counter.h" |
| 22 #include "components/browsing_data/core/counters/history_counter.h" |
| 23 #include "components/browsing_data/core/counters/passwords_counter.h" |
17 #include "components/browsing_data/core/pref_names.h" | 24 #include "components/browsing_data/core/pref_names.h" |
| 25 #include "components/history/core/browser/web_history_service.h" |
| 26 #include "components/password_manager/core/browser/password_store.h" |
18 | 27 |
19 #if defined(ENABLE_EXTENSIONS) | 28 #if defined(ENABLE_EXTENSIONS) |
20 #include "chrome/browser/browsing_data/hosted_apps_counter.h" | 29 #include "chrome/browser/browsing_data/hosted_apps_counter.h" |
21 #endif | 30 #endif |
22 | 31 |
| 32 namespace { |
| 33 |
| 34 history::WebHistoryService* GetUpdatedWebHistoryService(Profile* profile) { |
| 35 return WebHistoryServiceFactory::GetForProfile(profile); |
| 36 } |
| 37 |
| 38 } // namespace |
| 39 |
23 // static | 40 // static |
24 std::unique_ptr<browsing_data::BrowsingDataCounter> | 41 std::unique_ptr<browsing_data::BrowsingDataCounter> |
25 BrowsingDataCounterFactory::GetForProfileAndPref(Profile* profile, | 42 BrowsingDataCounterFactory::GetForProfileAndPref(Profile* profile, |
26 const std::string& pref_name) { | 43 const std::string& pref_name) { |
27 if (!AreCountersEnabled()) | 44 if (!AreCountersEnabled()) |
28 return nullptr; | 45 return nullptr; |
29 | 46 |
30 if (pref_name == browsing_data::prefs::kDeleteBrowsingHistory) | 47 if (pref_name == browsing_data::prefs::kDeleteBrowsingHistory) { |
31 return base::MakeUnique<HistoryCounter>(profile); | 48 return base::MakeUnique<browsing_data::HistoryCounter>( |
| 49 HistoryServiceFactory::GetForProfile( |
| 50 profile, ServiceAccessType::EXPLICIT_ACCESS), |
| 51 base::Bind(&GetUpdatedWebHistoryService, |
| 52 base::Unretained(profile)), |
| 53 ProfileSyncServiceFactory::GetForProfile(profile)); |
| 54 } |
32 | 55 |
33 if (pref_name == browsing_data::prefs::kDeleteCache) | 56 if (pref_name == browsing_data::prefs::kDeleteCache) |
34 return base::MakeUnique<CacheCounter>(profile); | 57 return base::MakeUnique<CacheCounter>(profile); |
35 | 58 |
36 if (pref_name == browsing_data::prefs::kDeletePasswords) | 59 if (pref_name == browsing_data::prefs::kDeletePasswords) { |
37 return base::MakeUnique<PasswordsCounter>(profile); | 60 return base::MakeUnique<browsing_data::PasswordsCounter>( |
| 61 PasswordStoreFactory::GetForProfile( |
| 62 profile, ServiceAccessType::EXPLICIT_ACCESS)); |
| 63 } |
38 | 64 |
39 if (pref_name == browsing_data::prefs::kDeleteFormData) | 65 if (pref_name == browsing_data::prefs::kDeleteFormData) { |
40 return base::MakeUnique<AutofillCounter>(profile); | 66 return base::MakeUnique<browsing_data::AutofillCounter>( |
| 67 WebDataServiceFactory::GetAutofillWebDataForProfile( |
| 68 profile, ServiceAccessType::EXPLICIT_ACCESS)); |
| 69 } |
41 | 70 |
42 if (pref_name == browsing_data::prefs::kDeleteDownloadHistory) | 71 if (pref_name == browsing_data::prefs::kDeleteDownloadHistory) |
43 return base::MakeUnique<DownloadsCounter>(profile); | 72 return base::MakeUnique<DownloadsCounter>(profile); |
44 | 73 |
45 if (pref_name == browsing_data::prefs::kDeleteMediaLicenses) | 74 if (pref_name == browsing_data::prefs::kDeleteMediaLicenses) |
46 return base::MakeUnique<MediaLicensesCounter>(profile); | 75 return base::MakeUnique<MediaLicensesCounter>(profile); |
47 | 76 |
48 #if defined(ENABLE_EXTENSIONS) | 77 #if defined(ENABLE_EXTENSIONS) |
49 if (pref_name == browsing_data::prefs::kDeleteHostedAppsData) | 78 if (pref_name == browsing_data::prefs::kDeleteHostedAppsData) |
50 return base::MakeUnique<HostedAppsCounter>(profile); | 79 return base::MakeUnique<HostedAppsCounter>(profile); |
51 #endif | 80 #endif |
52 | 81 |
53 return nullptr; | 82 return nullptr; |
54 } | 83 } |
OLD | NEW |