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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/content_settings/local_shared_objects_container.cc
diff --git a/chrome/browser/content_settings/local_shared_objects_container.cc b/chrome/browser/content_settings/local_shared_objects_container.cc
index e5e59e6f9ec599750d871efb267334d27d7b1470..36c4c12fa1374bab3e49b0f53446f4c067769470 100644
--- a/chrome/browser/content_settings/local_shared_objects_container.cc
+++ b/chrome/browser/content_settings/local_shared_objects_container.cc
@@ -12,6 +12,9 @@
#include "chrome/browser/browsing_data_local_storage_helper.h"
#include "chrome/browser/browsing_data_server_bound_cert_helper.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/url_constants.h"
+#include "googleurl/src/gurl.h"
+#include "net/base/registry_controlled_domain.h"
LocalSharedObjectsContainer::LocalSharedObjectsContainer(Profile* profile)
: appcaches_(new CannedBrowsingDataAppCacheHelper(profile)),
@@ -38,13 +41,135 @@ void LocalSharedObjectsContainer::Reset() {
session_storages_->Reset();
}
-bool LocalSharedObjectsContainer::IsEmpty() const {
- return appcaches_->empty() &&
- cookies_->empty() &&
- databases_->empty() &&
- file_systems_->empty() &&
- indexed_dbs_->empty() &&
- local_storages_->empty() &&
- server_bound_certs_->empty() &&
- session_storages_->empty();
+size_t LocalSharedObjectsContainer::Size() const {
+ size_t count = 0;
+ count += appcaches()->GetAppCacheCount();
+ count += cookies()->GetCookieCount();
+ count += databases()->GetDatabaseCount();
+ count += file_systems()->GetFileSystemCount();
+ count += indexed_dbs()->GetIndexedDBCount();
+ count += local_storages()->GetLocalStorageCount();
+ count += server_bound_certs()->GetCertCount();
+ count += session_storages()->GetLocalStorageCount();
+ return count;
+}
+
+size_t LocalSharedObjectsContainer::GetObjectCountForDomain(
+ const GURL& origin) const {
+ size_t count = 0;
+
+ // 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.
+ typedef CannedBrowsingDataCookieHelper::OriginCookieListMap
+ OriginCookieListMap;
+ const OriginCookieListMap& origin_cookies_list_map =
+ cookies()->origin_cookie_list_map();
+ for (OriginCookieListMap::const_iterator it =
+ origin_cookies_list_map.begin();
+ it != origin_cookies_list_map.end();
+ ++it) {
+ const net::CookieList* cookie_list = it->second;
+ for (net::CookieList::const_iterator cookie = cookie_list->begin();
+ cookie != cookie_list->end();
+ ++cookie) {
+ // Strip leading '.'s.
+ std::string cookie_domain = cookie->Domain();
+ if (cookie_domain[0] == '.')
+ cookie_domain = cookie_domain.substr(1);
+ // The |domain_url| is only created in order to use the SameDomainOrHost
+ // method below. It does not matter which scheme is used as the scheme is
+ // ignored by the SameDomainOrHost method.
+ GURL domain_url(std::string(chrome::kHttpScheme) +
+ chrome::kStandardSchemeSeparator + cookie_domain);
+ if (net::RegistryControlledDomainService::SameDomainOrHost(
+ origin, domain_url)) {
+ ++count;
+ }
+ }
+ }
+
+ // Count local storages for the domain of the given |origin|.
+ const std::set<GURL> local_storage_info =
+ local_storages()->pending_local_storage_info();
+ for (std::set<GURL>::const_iterator it = local_storage_info.begin();
+ it != local_storage_info.end();
+ ++it) {
+ if (net::RegistryControlledDomainService::SameDomainOrHost(
+ origin, *it)) {
+ ++count;
+ }
+ }
+
+ // Count session storages for the domain of the given |origin|.
+ 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.
+ for (std::set<GURL>::const_iterator it = urls.begin();
+ it != urls.end();
+ ++it) {
+ if (net::RegistryControlledDomainService::SameDomainOrHost(
+ origin, *it)) {
+ ++count;
+ }
+ }
+
+ // Count indexed dbs for the domain of the given |origin|.
+ typedef CannedBrowsingDataIndexedDBHelper::PendingIndexedDBInfo IndexedDBInfo;
+ const std::list<IndexedDBInfo>& indexed_db_info =
+ indexed_dbs()->pending_indexed_db_info();
+ for (std::list<IndexedDBInfo>::const_iterator it =
+ indexed_db_info.begin();
+ it != indexed_db_info.end();
+ ++it) {
+ if (net::RegistryControlledDomainService::SameDomainOrHost(
+ origin, it->origin)) {
+ ++count;
+ }
+ }
+
+ // Count filesystems for the domain of the given |origin|.
+ typedef BrowsingDataFileSystemHelper::FileSystemInfo FileSystemInfo;
+ typedef std::list<FileSystemInfo> FileSystemInfoList;
+ const FileSystemInfoList& file_system_info =
+ file_systems()->file_system_info();
+ for (FileSystemInfoList::const_iterator it = file_system_info.begin();
+ it != file_system_info.end();
+ ++it) {
+ if (net::RegistryControlledDomainService::SameDomainOrHost(
+ origin, it->origin)) {
+ ++count;
+ }
+ }
+
+ // Count databases for the domain of the given |origin|.
+ typedef CannedBrowsingDataDatabaseHelper::PendingDatabaseInfo DatabaseInfo;
+ const std::list<DatabaseInfo>& database_list =
+ databases()->pending_database_info();
+ for (std::list<DatabaseInfo>::const_iterator it =
+ database_list.begin();
+ it != database_list.end();
+ ++it) {
+ if (net::RegistryControlledDomainService::SameDomainOrHost(
+ origin, it->origin)) {
+ ++count;
+ }
+ }
+
+ // Count the app caches for the domain of the given |origin|.
+ typedef BrowsingDataAppCacheHelper::OriginAppCacheInfoMap
+ OriginAppCacheInfoMap;
+ const OriginAppCacheInfoMap& map = appcaches()->GetOriginAppCacheInfoMap();
+ for (OriginAppCacheInfoMap::const_iterator it = map.begin();
+ it != map.end();
+ ++it) {
+ const appcache::AppCacheInfoVector& info_vector = it->second;
+ for (appcache::AppCacheInfoVector::const_iterator info =
+ info_vector.begin();
+ info != info_vector.end();
+ ++info) {
+ if (net::RegistryControlledDomainService::SameDomainOrHost(
+ origin, info->manifest_url)) {
+ ++count;
+ }
+ }
+ }
+
+ return count;
}

Powered by Google App Engine
This is Rietveld 408576698