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

Side by Side Diff: ios/chrome/browser/browsing_data/ios_browsing_data_counter_factory.cc

Issue 2350773002: Add a browsing data counter factory on iOS (Closed)
Patch Set: Addressed comments Created 4 years, 3 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
(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/experimental_flags.h"
18 #include "ios/chrome/browser/history/history_service_factory.h"
19 #include "ios/chrome/browser/history/web_history_service_factory.h"
20 #include "ios/chrome/browser/passwords/ios_chrome_password_store_factory.h"
21 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
22 #include "ios/chrome/browser/web_data_service_factory.h"
23
24 namespace {
25
26 history::WebHistoryService* GetUpdatedWebHistoryService(
27 ios::ChromeBrowserState* browser_state) {
28 return ios::WebHistoryServiceFactory::GetForBrowserState(browser_state);
29 }
30
31 } // namespace
32
33 // static
34 std::unique_ptr<browsing_data::BrowsingDataCounter>
35 IOSBrowsingDataCounterFactory::GetForBrowserStateAndPref(
36 ios::ChromeBrowserState* browser_state,
37 base::StringPiece pref_name) {
38 if (!experimental_flags::IsNewClearBrowsingDataUIEnabled())
39 return nullptr;
40
41 if (pref_name == browsing_data::prefs::kDeleteBrowsingHistory) {
42 return base::MakeUnique<browsing_data::HistoryCounter>(
43 ios::HistoryServiceFactory::GetForBrowserStateIfExists(
44 browser_state, ServiceAccessType::EXPLICIT_ACCESS),
45 base::Bind(&GetUpdatedWebHistoryService,
sdefresne 2016/09/20 11:50:46 nit: Can't you just bind ios::WebHistoryServiceFac
ioanap 2016/09/20 12:43:29 Indeed I can. Thank you!
46 base::Unretained(browser_state)),
47 IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state));
48 }
49
50 if (pref_name == browsing_data::prefs::kDeletePasswords) {
51 return base::MakeUnique<browsing_data::PasswordsCounter>(
52 IOSChromePasswordStoreFactory::GetForBrowserState(
53 browser_state, ServiceAccessType::EXPLICIT_ACCESS));
54 }
55
56 if (pref_name == browsing_data::prefs::kDeleteFormData) {
57 return base::MakeUnique<browsing_data::AutofillCounter>(
58 ios::WebDataServiceFactory::GetAutofillWebDataForBrowserState(
59 browser_state, ServiceAccessType::EXPLICIT_ACCESS));
60 }
61
62 return nullptr;
63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698