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

Side by Side Diff: chrome/browser/content_settings/local_shared_objects_container.cc

Issue 10092013: Display third party cookies and site data counts in the WebsiteSettings UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/content_settings/local_shared_objects_container.h" 5 #include "chrome/browser/content_settings/local_shared_objects_container.h"
6 6
7 #include "chrome/browser/browsing_data_appcache_helper.h" 7 #include "chrome/browser/browsing_data_appcache_helper.h"
8 #include "chrome/browser/browsing_data_cookie_helper.h" 8 #include "chrome/browser/browsing_data_cookie_helper.h"
9 #include "chrome/browser/browsing_data_database_helper.h" 9 #include "chrome/browser/browsing_data_database_helper.h"
10 #include "chrome/browser/browsing_data_file_system_helper.h" 10 #include "chrome/browser/browsing_data_file_system_helper.h"
11 #include "chrome/browser/browsing_data_indexed_db_helper.h" 11 #include "chrome/browser/browsing_data_indexed_db_helper.h"
12 #include "chrome/browser/browsing_data_local_storage_helper.h" 12 #include "chrome/browser/browsing_data_local_storage_helper.h"
13 #include "chrome/browser/browsing_data_server_bound_cert_helper.h" 13 #include "chrome/browser/browsing_data_server_bound_cert_helper.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/common/url_constants.h"
16 #include "googleurl/src/gurl.h"
17 #include "net/base/registry_controlled_domain.h"
15 18
16 LocalSharedObjectsContainer::LocalSharedObjectsContainer(Profile* profile) 19 LocalSharedObjectsContainer::LocalSharedObjectsContainer(Profile* profile)
17 : appcaches_(new CannedBrowsingDataAppCacheHelper(profile)), 20 : appcaches_(new CannedBrowsingDataAppCacheHelper(profile)),
18 cookies_(new CannedBrowsingDataCookieHelper(profile)), 21 cookies_(new CannedBrowsingDataCookieHelper(profile)),
19 databases_(new CannedBrowsingDataDatabaseHelper(profile)), 22 databases_(new CannedBrowsingDataDatabaseHelper(profile)),
20 file_systems_(new CannedBrowsingDataFileSystemHelper(profile)), 23 file_systems_(new CannedBrowsingDataFileSystemHelper(profile)),
21 indexed_dbs_(new CannedBrowsingDataIndexedDBHelper()), 24 indexed_dbs_(new CannedBrowsingDataIndexedDBHelper()),
22 local_storages_(new CannedBrowsingDataLocalStorageHelper(profile)), 25 local_storages_(new CannedBrowsingDataLocalStorageHelper(profile)),
23 server_bound_certs_(new CannedBrowsingDataServerBoundCertHelper()), 26 server_bound_certs_(new CannedBrowsingDataServerBoundCertHelper()),
24 session_storages_(new CannedBrowsingDataLocalStorageHelper(profile)) { 27 session_storages_(new CannedBrowsingDataLocalStorageHelper(profile)) {
25 } 28 }
26 29
27 LocalSharedObjectsContainer::~LocalSharedObjectsContainer() { 30 LocalSharedObjectsContainer::~LocalSharedObjectsContainer() {
28 } 31 }
29 32
30 void LocalSharedObjectsContainer::Reset() { 33 void LocalSharedObjectsContainer::Reset() {
31 appcaches_->Reset(); 34 appcaches_->Reset();
32 cookies_->Reset(); 35 cookies_->Reset();
33 databases_->Reset(); 36 databases_->Reset();
34 file_systems_->Reset(); 37 file_systems_->Reset();
35 indexed_dbs_->Reset(); 38 indexed_dbs_->Reset();
36 local_storages_->Reset(); 39 local_storages_->Reset();
37 server_bound_certs_->Reset(); 40 server_bound_certs_->Reset();
38 session_storages_->Reset(); 41 session_storages_->Reset();
39 } 42 }
40 43
41 bool LocalSharedObjectsContainer::IsEmpty() const { 44 size_t LocalSharedObjectsContainer::Size() const {
42 return appcaches_->empty() && 45 size_t count = 0;
43 cookies_->empty() && 46 count += appcaches()->GetAppCacheCount();
44 databases_->empty() && 47 count += cookies()->GetCookieCount();
45 file_systems_->empty() && 48 count += databases()->GetDatabaseCount();
46 indexed_dbs_->empty() && 49 count += file_systems()->GetFileSystemCount();
47 local_storages_->empty() && 50 count += indexed_dbs()->GetIndexedDBCount();
48 server_bound_certs_->empty() && 51 count += local_storages()->GetLocalStorageCount();
49 session_storages_->empty(); 52 count += server_bound_certs()->GetCertCount();
53 count += session_storages()->GetLocalStorageCount();
54 return count;
50 } 55 }
56
57 size_t LocalSharedObjectsContainer::GetObjectCountForDomain(
58 const GURL& origin) const {
59 size_t count = 0;
60
61 // Count cookies for the domain of the given |origin|.
bauerb at google 2012/04/27 16:12:50 It's actually pretty subtle what "cookies for the
markusheintz_ 2012/05/10 16:32:36 I hope the comment explains this better now.
62 typedef CannedBrowsingDataCookieHelper::OriginCookieListMap
63 OriginCookieListMap;
64 const OriginCookieListMap& origin_cookies_list_map =
65 cookies()->origin_cookie_list_map();
66 for (OriginCookieListMap::const_iterator it =
67 origin_cookies_list_map.begin();
68 it != origin_cookies_list_map.end();
69 ++it) {
70 const net::CookieList* cookie_list = it->second;
71 for (net::CookieList::const_iterator cookie = cookie_list->begin();
72 cookie != cookie_list->end();
73 ++cookie) {
74 // Strip leading '.'s.
75 std::string cookie_domain = cookie->Domain();
76 if (cookie_domain[0] == '.')
77 cookie_domain = cookie_domain.substr(1);
78 // The |domain_url| is only created in order to use the SameDomainOrHost
79 // method below. It does not matter which scheme is used as the scheme is
80 // ignored by the SameDomainOrHost method.
81 GURL domain_url(std::string(chrome::kHttpScheme) +
82 chrome::kStandardSchemeSeparator + cookie_domain);
83 if (net::RegistryControlledDomainService::SameDomainOrHost(
84 origin, domain_url)) {
85 ++count;
86 }
87 }
88 }
89
90 // Count local storages for the domain of the given |origin|.
91 const std::set<GURL> local_storage_info =
92 local_storages()->pending_local_storage_info();
93 for (std::set<GURL>::const_iterator it = local_storage_info.begin();
94 it != local_storage_info.end();
95 ++it) {
96 if (net::RegistryControlledDomainService::SameDomainOrHost(
97 origin, *it)) {
98 ++count;
99 }
100 }
101
102 // Count session storages for the domain of the given |origin|.
103 const std::set<GURL> urls = session_storages()->pending_local_storage_info();
bauerb at google 2012/04/27 16:12:50 Is it on purpose that we only look at pending loca
markusheintz_ 2012/05/10 16:32:36 Fixed.
104 for (std::set<GURL>::const_iterator it = urls.begin();
105 it != urls.end();
106 ++it) {
107 if (net::RegistryControlledDomainService::SameDomainOrHost(
108 origin, *it)) {
109 ++count;
110 }
111 }
112
113 // Count indexed dbs for the domain of the given |origin|.
114 typedef CannedBrowsingDataIndexedDBHelper::PendingIndexedDBInfo IndexedDBInfo;
115 const std::list<IndexedDBInfo>& indexed_db_info =
116 indexed_dbs()->pending_indexed_db_info();
117 for (std::list<IndexedDBInfo>::const_iterator it =
118 indexed_db_info.begin();
119 it != indexed_db_info.end();
120 ++it) {
121 if (net::RegistryControlledDomainService::SameDomainOrHost(
122 origin, it->origin)) {
123 ++count;
124 }
125 }
126
127 // Count filesystems for the domain of the given |origin|.
128 typedef BrowsingDataFileSystemHelper::FileSystemInfo FileSystemInfo;
129 typedef std::list<FileSystemInfo> FileSystemInfoList;
130 const FileSystemInfoList& file_system_info =
131 file_systems()->file_system_info();
132 for (FileSystemInfoList::const_iterator it = file_system_info.begin();
133 it != file_system_info.end();
134 ++it) {
135 if (net::RegistryControlledDomainService::SameDomainOrHost(
136 origin, it->origin)) {
137 ++count;
138 }
139 }
140
141 // Count databases for the domain of the given |origin|.
142 typedef CannedBrowsingDataDatabaseHelper::PendingDatabaseInfo DatabaseInfo;
143 const std::list<DatabaseInfo>& database_list =
144 databases()->pending_database_info();
145 for (std::list<DatabaseInfo>::const_iterator it =
146 database_list.begin();
147 it != database_list.end();
148 ++it) {
149 if (net::RegistryControlledDomainService::SameDomainOrHost(
150 origin, it->origin)) {
151 ++count;
152 }
153 }
154
155 // Count the app caches for the domain of the given |origin|.
156 typedef BrowsingDataAppCacheHelper::OriginAppCacheInfoMap
157 OriginAppCacheInfoMap;
158 const OriginAppCacheInfoMap& map = appcaches()->GetOriginAppCacheInfoMap();
159 for (OriginAppCacheInfoMap::const_iterator it = map.begin();
160 it != map.end();
161 ++it) {
162 const appcache::AppCacheInfoVector& info_vector = it->second;
163 for (appcache::AppCacheInfoVector::const_iterator info =
164 info_vector.begin();
165 info != info_vector.end();
166 ++info) {
167 if (net::RegistryControlledDomainService::SameDomainOrHost(
168 origin, info->manifest_url)) {
169 ++count;
170 }
171 }
172 }
173
174 return count;
175 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698