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 "ios/chrome/browser/browsing_data/ios_browsing_data_counter_factory.h" | 5 #include "ios/chrome/browser/browsing_data/ios_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 "components/browser_sync/profile_sync_service.h" | 10 #include "components/browser_sync/profile_sync_service.h" |
11 #include "components/browsing_data/core/counters/autofill_counter.h" | 11 #include "components/browsing_data/core/counters/autofill_counter.h" |
12 #include "components/browsing_data/core/counters/browsing_data_counter.h" | 12 #include "components/browsing_data/core/counters/browsing_data_counter.h" |
13 #include "components/browsing_data/core/counters/history_counter.h" | 13 #include "components/browsing_data/core/counters/history_counter.h" |
14 #include "components/browsing_data/core/counters/passwords_counter.h" | 14 #include "components/browsing_data/core/counters/passwords_counter.h" |
15 #include "components/browsing_data/core/pref_names.h" | 15 #include "components/browsing_data/core/pref_names.h" |
16 #include "components/keyed_service/core/service_access_type.h" | 16 #include "components/keyed_service/core/service_access_type.h" |
17 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 17 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 18 #include "ios/chrome/browser/browsing_data/cache_counter.h" |
18 #include "ios/chrome/browser/experimental_flags.h" | 19 #include "ios/chrome/browser/experimental_flags.h" |
19 #include "ios/chrome/browser/history/history_service_factory.h" | 20 #include "ios/chrome/browser/history/history_service_factory.h" |
20 #include "ios/chrome/browser/history/web_history_service_factory.h" | 21 #include "ios/chrome/browser/history/web_history_service_factory.h" |
21 #include "ios/chrome/browser/passwords/ios_chrome_password_store_factory.h" | 22 #include "ios/chrome/browser/passwords/ios_chrome_password_store_factory.h" |
22 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h" | 23 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h" |
23 #include "ios/chrome/browser/web_data_service_factory.h" | 24 #include "ios/chrome/browser/web_data_service_factory.h" |
24 | 25 |
25 // static | 26 // static |
26 std::unique_ptr<browsing_data::BrowsingDataCounter> | 27 std::unique_ptr<browsing_data::BrowsingDataCounter> |
27 IOSBrowsingDataCounterFactory::GetForBrowserStateAndPref( | 28 IOSBrowsingDataCounterFactory::GetForBrowserStateAndPref( |
28 ios::ChromeBrowserState* browser_state, | 29 ios::ChromeBrowserState* browser_state, |
29 base::StringPiece pref_name) { | 30 base::StringPiece pref_name) { |
30 if (!experimental_flags::IsNewClearBrowsingDataUIEnabled()) | 31 if (!experimental_flags::IsNewClearBrowsingDataUIEnabled()) |
31 return nullptr; | 32 return nullptr; |
32 | 33 |
33 if (pref_name == browsing_data::prefs::kDeleteBrowsingHistory) { | 34 if (pref_name == browsing_data::prefs::kDeleteBrowsingHistory) { |
34 return base::MakeUnique<browsing_data::HistoryCounter>( | 35 return base::MakeUnique<browsing_data::HistoryCounter>( |
35 ios::HistoryServiceFactory::GetForBrowserStateIfExists( | 36 ios::HistoryServiceFactory::GetForBrowserStateIfExists( |
36 browser_state, ServiceAccessType::EXPLICIT_ACCESS), | 37 browser_state, ServiceAccessType::EXPLICIT_ACCESS), |
37 base::Bind(&ios::WebHistoryServiceFactory::GetForBrowserState, | 38 base::Bind(&ios::WebHistoryServiceFactory::GetForBrowserState, |
38 base::Unretained(browser_state)), | 39 base::Unretained(browser_state)), |
39 IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state)); | 40 IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state)); |
40 } | 41 } |
41 | 42 |
| 43 if (pref_name == browsing_data::prefs::kDeleteCache) |
| 44 return base::MakeUnique<CacheCounter>(browser_state); |
| 45 |
42 if (pref_name == browsing_data::prefs::kDeletePasswords) { | 46 if (pref_name == browsing_data::prefs::kDeletePasswords) { |
43 return base::MakeUnique<browsing_data::PasswordsCounter>( | 47 return base::MakeUnique<browsing_data::PasswordsCounter>( |
44 IOSChromePasswordStoreFactory::GetForBrowserState( | 48 IOSChromePasswordStoreFactory::GetForBrowserState( |
45 browser_state, ServiceAccessType::EXPLICIT_ACCESS)); | 49 browser_state, ServiceAccessType::EXPLICIT_ACCESS)); |
46 } | 50 } |
47 | 51 |
48 if (pref_name == browsing_data::prefs::kDeleteFormData) { | 52 if (pref_name == browsing_data::prefs::kDeleteFormData) { |
49 return base::MakeUnique<browsing_data::AutofillCounter>( | 53 return base::MakeUnique<browsing_data::AutofillCounter>( |
50 ios::WebDataServiceFactory::GetAutofillWebDataForBrowserState( | 54 ios::WebDataServiceFactory::GetAutofillWebDataForBrowserState( |
51 browser_state, ServiceAccessType::EXPLICIT_ACCESS)); | 55 browser_state, ServiceAccessType::EXPLICIT_ACCESS)); |
52 } | 56 } |
53 | 57 |
54 return nullptr; | 58 return nullptr; |
55 } | 59 } |
OLD | NEW |