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

Side by Side Diff: components/browsing_data/core/counters/site_settings_counter.cc

Issue 2816723002: Add "Site Settings" option to Clear Browsing Data on Android (Closed)
Patch Set: fix deps Created 3 years, 7 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 2017 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 "components/browsing_data/core/counters/site_settings_counter.h"
6
7 #include <set>
8 #include "components/browsing_data/core/pref_names.h"
9 #include "components/content_settings/core/browser/content_settings_registry.h"
10 #include "components/content_settings/core/common/content_settings_pattern.h"
11
12 namespace browsing_data {
13
14 SiteSettingsCounter::SiteSettingsCounter(HostContentSettingsMap* map)
15 : map_(map) {
16 DCHECK(map_);
17 }
18
19 SiteSettingsCounter::~SiteSettingsCounter() {}
20
21 void SiteSettingsCounter::OnInitialized() {}
22
23 const char* SiteSettingsCounter::GetPrefName() const {
24 return browsing_data::prefs::kDeleteSiteSettings;
25 }
26
27 void SiteSettingsCounter::Count() {
28 std::set<ContentSettingsPattern> patterns;
29 base::Time period_start = GetPeriodStart();
30 auto* registry = content_settings::ContentSettingsRegistry::GetInstance();
31 for (const content_settings::ContentSettingsInfo* info : *registry) {
32 ContentSettingsType type = info->website_settings_info()->type();
33 ContentSettingsForOneType content_settings_list;
34 map_->GetSettingsForOneType(type, content_settings::ResourceIdentifier(),
35 &content_settings_list);
36 for (const auto& content_setting : content_settings_list) {
37 if (content_setting.source == "preference") {
38 base::Time last_modified = map_->GetSettingLastModifiedDate(
39 content_setting.primary_pattern, content_setting.secondary_pattern,
40 type);
41 if (last_modified >= period_start) {
42 patterns.insert(content_setting.primary_pattern);
43 }
44 }
45 }
46 }
47 ReportResult(patterns.size());
48 }
49
50 } // namespace browsing_data
OLDNEW
« no previous file with comments | « components/browsing_data/core/counters/site_settings_counter.h ('k') | components/browsing_data/core/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698