Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: chrome/browser/browsing_data/browsing_data_counter_factory.cc

Issue 2153863002: Move counters for passwords, history and autofill to components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@separate_build_targets_in_components_bd
Patch Set: Fixed dependencies Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
23 // static 32 // static
24 std::unique_ptr<browsing_data::BrowsingDataCounter> 33 std::unique_ptr<browsing_data::BrowsingDataCounter>
25 BrowsingDataCounterFactory::GetForProfileAndPref(Profile* profile, 34 BrowsingDataCounterFactory::GetForProfileAndPref(Profile* profile,
26 const std::string& pref_name) { 35 const std::string& pref_name) {
27 if (!AreCountersEnabled()) 36 if (!AreCountersEnabled())
28 return nullptr; 37 return nullptr;
29 38
30 if (pref_name == browsing_data::prefs::kDeleteBrowsingHistory) 39 if (pref_name == browsing_data::prefs::kDeleteBrowsingHistory) {
31 return base::MakeUnique<HistoryCounter>(profile); 40 return base::MakeUnique<browsing_data::HistoryCounter>(
41 ProfileSyncServiceFactory::GetForProfile(profile),
42 base::Bind(&BrowsingDataCounterFactory::GetUpdatedWebHistoryService,
43 base::Unretained(profile)),
44 HistoryServiceFactory::GetForProfile(
45 profile, ServiceAccessType::EXPLICIT_ACCESS));
46 }
32 47
33 if (pref_name == browsing_data::prefs::kDeleteCache) 48 if (pref_name == browsing_data::prefs::kDeleteCache)
34 return base::MakeUnique<CacheCounter>(profile); 49 return base::MakeUnique<CacheCounter>(profile);
35 50
36 if (pref_name == browsing_data::prefs::kDeletePasswords) 51 if (pref_name == browsing_data::prefs::kDeletePasswords) {
37 return base::MakeUnique<PasswordsCounter>(profile); 52 return base::MakeUnique<browsing_data::PasswordsCounter>(
53 PasswordStoreFactory::GetForProfile(
54 profile, ServiceAccessType::EXPLICIT_ACCESS));
55 }
38 56
39 if (pref_name == browsing_data::prefs::kDeleteFormData) 57 if (pref_name == browsing_data::prefs::kDeleteFormData) {
40 return base::MakeUnique<AutofillCounter>(profile); 58 return base::MakeUnique<browsing_data::AutofillCounter>(
59 WebDataServiceFactory::GetAutofillWebDataForProfile(
60 profile, ServiceAccessType::EXPLICIT_ACCESS));
61 }
41 62
42 if (pref_name == browsing_data::prefs::kDeleteDownloadHistory) 63 if (pref_name == browsing_data::prefs::kDeleteDownloadHistory)
43 return base::MakeUnique<DownloadsCounter>(profile); 64 return base::MakeUnique<DownloadsCounter>(profile);
44 65
45 if (pref_name == browsing_data::prefs::kDeleteMediaLicenses) 66 if (pref_name == browsing_data::prefs::kDeleteMediaLicenses)
46 return base::MakeUnique<MediaLicensesCounter>(profile); 67 return base::MakeUnique<MediaLicensesCounter>(profile);
47 68
48 #if defined(ENABLE_EXTENSIONS) 69 #if defined(ENABLE_EXTENSIONS)
49 if (pref_name == browsing_data::prefs::kDeleteHostedAppsData) 70 if (pref_name == browsing_data::prefs::kDeleteHostedAppsData)
50 return base::MakeUnique<HostedAppsCounter>(profile); 71 return base::MakeUnique<HostedAppsCounter>(profile);
51 #endif 72 #endif
52 73
53 return nullptr; 74 return nullptr;
54 } 75 }
76
77 // static
78 history::WebHistoryService*
msramek 2016/07/20 13:41:16 Can we move this to an anonymous namespace?
ioanap 2016/07/20 17:50:36 Done.
79 BrowsingDataCounterFactory::GetUpdatedWebHistoryService(Profile* profile) {
80 return WebHistoryServiceFactory::GetForProfile(profile);
81 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698