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