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

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: Removed extra empty line 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
32 namespace {
33 history::WebHistoryService* GetUpdatedWebHistoryService(Profile* profile) {
msramek 2016/07/20 18:26:13 No offset within namespace. Empty lines between th
ioanap 2016/07/21 11:47:36 Done.
34 return WebHistoryServiceFactory::GetForProfile(profile);
35 }
36 }
37
23 // static 38 // static
24 std::unique_ptr<browsing_data::BrowsingDataCounter> 39 std::unique_ptr<browsing_data::BrowsingDataCounter>
25 BrowsingDataCounterFactory::GetForProfileAndPref(Profile* profile, 40 BrowsingDataCounterFactory::GetForProfileAndPref(Profile* profile,
26 const std::string& pref_name) { 41 const std::string& pref_name) {
27 if (!AreCountersEnabled()) 42 if (!AreCountersEnabled())
28 return nullptr; 43 return nullptr;
29 44
30 if (pref_name == browsing_data::prefs::kDeleteBrowsingHistory) 45 if (pref_name == browsing_data::prefs::kDeleteBrowsingHistory) {
31 return base::MakeUnique<HistoryCounter>(profile); 46 return base::MakeUnique<browsing_data::HistoryCounter>(
47 HistoryServiceFactory::GetForProfile(
48 profile, ServiceAccessType::EXPLICIT_ACCESS),
49 base::Bind(&GetUpdatedWebHistoryService,
50 base::Unretained(profile)),
51 ProfileSyncServiceFactory::GetForProfile(profile));
52 }
32 53
33 if (pref_name == browsing_data::prefs::kDeleteCache) 54 if (pref_name == browsing_data::prefs::kDeleteCache)
34 return base::MakeUnique<CacheCounter>(profile); 55 return base::MakeUnique<CacheCounter>(profile);
35 56
36 if (pref_name == browsing_data::prefs::kDeletePasswords) 57 if (pref_name == browsing_data::prefs::kDeletePasswords) {
37 return base::MakeUnique<PasswordsCounter>(profile); 58 return base::MakeUnique<browsing_data::PasswordsCounter>(
59 PasswordStoreFactory::GetForProfile(
60 profile, ServiceAccessType::EXPLICIT_ACCESS));
61 }
38 62
39 if (pref_name == browsing_data::prefs::kDeleteFormData) 63 if (pref_name == browsing_data::prefs::kDeleteFormData) {
40 return base::MakeUnique<AutofillCounter>(profile); 64 return base::MakeUnique<browsing_data::AutofillCounter>(
65 WebDataServiceFactory::GetAutofillWebDataForProfile(
66 profile, ServiceAccessType::EXPLICIT_ACCESS));
67 }
41 68
42 if (pref_name == browsing_data::prefs::kDeleteDownloadHistory) 69 if (pref_name == browsing_data::prefs::kDeleteDownloadHistory)
43 return base::MakeUnique<DownloadsCounter>(profile); 70 return base::MakeUnique<DownloadsCounter>(profile);
44 71
45 if (pref_name == browsing_data::prefs::kDeleteMediaLicenses) 72 if (pref_name == browsing_data::prefs::kDeleteMediaLicenses)
46 return base::MakeUnique<MediaLicensesCounter>(profile); 73 return base::MakeUnique<MediaLicensesCounter>(profile);
47 74
48 #if defined(ENABLE_EXTENSIONS) 75 #if defined(ENABLE_EXTENSIONS)
49 if (pref_name == browsing_data::prefs::kDeleteHostedAppsData) 76 if (pref_name == browsing_data::prefs::kDeleteHostedAppsData)
50 return base::MakeUnique<HostedAppsCounter>(profile); 77 return base::MakeUnique<HostedAppsCounter>(profile);
51 #endif 78 #endif
52 79
53 return nullptr; 80 return nullptr;
54 } 81 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698