| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ios/chrome/browser/browsing_data/ios_browsing_data_counter_factory.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" |
| 9 #include "base/memory/ptr_util.h" |
| 10 #include "components/browser_sync/profile_sync_service.h" |
| 11 #include "components/browsing_data/core/counters/autofill_counter.h" |
| 12 #include "components/browsing_data/core/counters/browsing_data_counter.h" |
| 13 #include "components/browsing_data/core/counters/history_counter.h" |
| 14 #include "components/browsing_data/core/counters/passwords_counter.h" |
| 15 #include "components/browsing_data/core/pref_names.h" |
| 16 #include "components/keyed_service/core/service_access_type.h" |
| 17 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 18 #include "ios/chrome/browser/experimental_flags.h" |
| 19 #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/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/web_data_service_factory.h" |
| 24 |
| 25 // static |
| 26 std::unique_ptr<browsing_data::BrowsingDataCounter> |
| 27 IOSBrowsingDataCounterFactory::GetForBrowserStateAndPref( |
| 28 ios::ChromeBrowserState* browser_state, |
| 29 base::StringPiece pref_name) { |
| 30 if (!experimental_flags::IsNewClearBrowsingDataUIEnabled()) |
| 31 return nullptr; |
| 32 |
| 33 if (pref_name == browsing_data::prefs::kDeleteBrowsingHistory) { |
| 34 return base::MakeUnique<browsing_data::HistoryCounter>( |
| 35 ios::HistoryServiceFactory::GetForBrowserStateIfExists( |
| 36 browser_state, ServiceAccessType::EXPLICIT_ACCESS), |
| 37 base::Bind(&ios::WebHistoryServiceFactory::GetForBrowserState, |
| 38 base::Unretained(browser_state)), |
| 39 IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state)); |
| 40 } |
| 41 |
| 42 if (pref_name == browsing_data::prefs::kDeletePasswords) { |
| 43 return base::MakeUnique<browsing_data::PasswordsCounter>( |
| 44 IOSChromePasswordStoreFactory::GetForBrowserState( |
| 45 browser_state, ServiceAccessType::EXPLICIT_ACCESS)); |
| 46 } |
| 47 |
| 48 if (pref_name == browsing_data::prefs::kDeleteFormData) { |
| 49 return base::MakeUnique<browsing_data::AutofillCounter>( |
| 50 ios::WebDataServiceFactory::GetAutofillWebDataForBrowserState( |
| 51 browser_state, ServiceAccessType::EXPLICIT_ACCESS)); |
| 52 } |
| 53 |
| 54 return nullptr; |
| 55 } |
| OLD | NEW |