| 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" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" | 10 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 } // namespace | 41 } // namespace |
| 42 | 42 |
| 43 // static | 43 // static |
| 44 std::unique_ptr<browsing_data::BrowsingDataCounter> | 44 std::unique_ptr<browsing_data::BrowsingDataCounter> |
| 45 BrowsingDataCounterFactory::GetForProfileAndPref(Profile* profile, | 45 BrowsingDataCounterFactory::GetForProfileAndPref(Profile* profile, |
| 46 const std::string& pref_name) { | 46 const std::string& pref_name) { |
| 47 if (!AreCountersEnabled()) | 47 if (!AreCountersEnabled()) |
| 48 return nullptr; | 48 return nullptr; |
| 49 | 49 |
| 50 if (pref_name == browsing_data::prefs::kDeleteBrowsingHistory || | 50 if (pref_name == browsing_data::prefs::kDeleteBrowsingHistory) { |
| 51 pref_name == browsing_data::prefs::kDeleteBrowsingHistoryBasic) { | |
| 52 return base::MakeUnique<browsing_data::HistoryCounter>( | 51 return base::MakeUnique<browsing_data::HistoryCounter>( |
| 53 HistoryServiceFactory::GetForProfile( | 52 HistoryServiceFactory::GetForProfile( |
| 54 profile, ServiceAccessType::EXPLICIT_ACCESS), | 53 profile, ServiceAccessType::EXPLICIT_ACCESS), |
| 55 base::Bind(&GetUpdatedWebHistoryService, | 54 base::Bind(&GetUpdatedWebHistoryService, |
| 56 base::Unretained(profile)), | 55 base::Unretained(profile)), |
| 57 ProfileSyncServiceFactory::GetForProfile(profile)); | 56 ProfileSyncServiceFactory::GetForProfile(profile)); |
| 58 } | 57 } |
| 58 if (pref_name == browsing_data::prefs::kDeleteBrowsingHistoryBasic) { |
| 59 // The history option on the basic tab doesn't use a counter. |
| 60 return nullptr; |
| 61 } |
| 59 | 62 |
| 60 if (pref_name == browsing_data::prefs::kDeleteCache || | 63 if (pref_name == browsing_data::prefs::kDeleteCache || |
| 61 pref_name == browsing_data::prefs::kDeleteCacheBasic) { | 64 pref_name == browsing_data::prefs::kDeleteCacheBasic) { |
| 62 return base::MakeUnique<CacheCounter>(profile); | 65 return base::MakeUnique<CacheCounter>(profile); |
| 63 } | 66 } |
| 64 | 67 |
| 65 if (pref_name == browsing_data::prefs::kDeleteCookies && | 68 if (pref_name == browsing_data::prefs::kDeleteCookies && |
| 66 IsSiteDataCounterEnabled()) { | 69 IsSiteDataCounterEnabled()) { |
| 67 return base::MakeUnique<SiteDataCounter>(profile); | 70 return base::MakeUnique<SiteDataCounter>(profile); |
| 68 } | 71 } |
| 72 if (pref_name == browsing_data::prefs::kDeleteCookiesBasic) { |
| 73 // The cookies option on the basic tab doesn't use a counter. |
| 74 return nullptr; |
| 75 } |
| 69 | 76 |
| 70 if (pref_name == browsing_data::prefs::kDeletePasswords) { | 77 if (pref_name == browsing_data::prefs::kDeletePasswords) { |
| 71 return base::MakeUnique<browsing_data::PasswordsCounter>( | 78 return base::MakeUnique<browsing_data::PasswordsCounter>( |
| 72 PasswordStoreFactory::GetForProfile( | 79 PasswordStoreFactory::GetForProfile( |
| 73 profile, ServiceAccessType::EXPLICIT_ACCESS)); | 80 profile, ServiceAccessType::EXPLICIT_ACCESS)); |
| 74 } | 81 } |
| 75 | 82 |
| 76 if (pref_name == browsing_data::prefs::kDeleteFormData) { | 83 if (pref_name == browsing_data::prefs::kDeleteFormData) { |
| 77 return base::MakeUnique<browsing_data::AutofillCounter>( | 84 return base::MakeUnique<browsing_data::AutofillCounter>( |
| 78 WebDataServiceFactory::GetAutofillWebDataForProfile( | 85 WebDataServiceFactory::GetAutofillWebDataForProfile( |
| 79 profile, ServiceAccessType::EXPLICIT_ACCESS)); | 86 profile, ServiceAccessType::EXPLICIT_ACCESS)); |
| 80 } | 87 } |
| 81 | 88 |
| 82 if (pref_name == browsing_data::prefs::kDeleteDownloadHistory) | 89 if (pref_name == browsing_data::prefs::kDeleteDownloadHistory) |
| 83 return base::MakeUnique<DownloadsCounter>(profile); | 90 return base::MakeUnique<DownloadsCounter>(profile); |
| 84 | 91 |
| 85 if (pref_name == browsing_data::prefs::kDeleteMediaLicenses) | 92 if (pref_name == browsing_data::prefs::kDeleteMediaLicenses) |
| 86 return base::MakeUnique<MediaLicensesCounter>(profile); | 93 return base::MakeUnique<MediaLicensesCounter>(profile); |
| 87 | 94 |
| 88 #if BUILDFLAG(ENABLE_EXTENSIONS) | 95 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 89 if (pref_name == browsing_data::prefs::kDeleteHostedAppsData) | 96 if (pref_name == browsing_data::prefs::kDeleteHostedAppsData) |
| 90 return base::MakeUnique<HostedAppsCounter>(profile); | 97 return base::MakeUnique<HostedAppsCounter>(profile); |
| 91 #endif | 98 #endif |
| 92 | 99 |
| 93 return nullptr; | 100 return nullptr; |
| 94 } | 101 } |
| OLD | NEW |