OLD | NEW |
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/browsing_data_appcache_helper.h" | 7 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" |
8 #include "chrome/browser/browsing_data/browsing_data_cache_storage_helper.h" | 8 #include "chrome/browser/browsing_data/browsing_data_cache_storage_helper.h" |
9 #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h" | 9 #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h" |
10 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" | 10 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 count += cache_storages()->GetCacheStorageCount(); | 68 count += cache_storages()->GetCacheStorageCount(); |
69 count += session_storages()->GetLocalStorageCount(); | 69 count += session_storages()->GetLocalStorageCount(); |
70 return count; | 70 return count; |
71 } | 71 } |
72 | 72 |
73 size_t LocalSharedObjectsContainer::GetObjectCountForDomain( | 73 size_t LocalSharedObjectsContainer::GetObjectCountForDomain( |
74 const GURL& origin) const { | 74 const GURL& origin) const { |
75 size_t count = 0; | 75 size_t count = 0; |
76 | 76 |
77 // Count all cookies that have the same domain as the provided |origin|. This | 77 // Count all cookies that have the same domain as the provided |origin|. This |
78 // means count all cookies that has been set by a host that is not considered | 78 // means count all cookies that have been set by a host that is not considered |
79 // to be a third party regarding the domain of the provided |origin|. | 79 // to be a third party regarding the domain of the provided |origin|. E.g. if |
80 // E.g. if the origin is "http://foo.com" then all cookies with domain foo.com
, | 80 // the origin is "http://foo.com" then all cookies with domain foo.com, |
81 // a.foo.com, b.a.foo.com or *.foo.com will be counted. | 81 // a.foo.com, b.a.foo.com or *.foo.com will be counted. |
82 typedef CannedBrowsingDataCookieHelper::OriginCookieSetMap OriginCookieSetMap; | 82 typedef CannedBrowsingDataCookieHelper::OriginCookieSetMap OriginCookieSetMap; |
83 const OriginCookieSetMap& origin_cookies_set_map = | 83 const OriginCookieSetMap& origin_cookies_set_map = |
84 cookies()->origin_cookie_set_map(); | 84 cookies()->origin_cookie_set_map(); |
85 for (OriginCookieSetMap::const_iterator it = origin_cookies_set_map.begin(); | 85 for (OriginCookieSetMap::const_iterator it = origin_cookies_set_map.begin(); |
86 it != origin_cookies_set_map.end(); | 86 it != origin_cookies_set_map.end(); |
87 ++it) { | 87 ++it) { |
88 const canonical_cookie::CookieHashSet* cookie_list = it->second; | 88 const canonical_cookie::CookieHashSet* cookie_list = it->second; |
89 for (canonical_cookie::CookieHashSet::const_iterator cookie = | 89 for (canonical_cookie::CookieHashSet::const_iterator cookie = |
90 cookie_list->begin(); | 90 cookie_list->begin(); |
91 cookie != cookie_list->end(); | 91 cookie != cookie_list->end(); |
92 ++cookie) { | 92 ++cookie) { |
93 // Strip leading '.'s. | 93 // Strip leading '.'s. |
94 std::string cookie_domain = cookie->Domain(); | 94 std::string cookie_domain = cookie->Domain(); |
95 if (cookie_domain[0] == '.') | 95 if (cookie_domain[0] == '.') |
96 cookie_domain = cookie_domain.substr(1); | 96 cookie_domain = cookie_domain.substr(1); |
97 // The |domain_url| is only created in order to use the | 97 // The |domain_url| is only created in order to use the |
98 // SameDomainOrHost method below. It does not matter which scheme is | 98 // SameDomainOrHost method below. It does not matter which scheme is |
99 // used as the scheme is ignored by the SameDomainOrHost method. | 99 // used as the scheme is ignored by the SameDomainOrHost method. |
100 GURL domain_url(std::string(url::kHttpScheme) + | 100 GURL domain_url(std::string(url::kHttpScheme) + |
101 url::kStandardSchemeSeparator + cookie_domain); | 101 url::kStandardSchemeSeparator + cookie_domain); |
102 if (SameDomainOrHost(origin, domain_url)) | 102 |
| 103 if (origin.SchemeIsHTTPOrHTTPS() && SameDomainOrHost(origin, domain_url)) |
103 ++count; | 104 ++count; |
104 } | 105 } |
105 } | 106 } |
106 | 107 |
107 // Count local storages for the domain of the given |origin|. | 108 // Count local storages for the domain of the given |origin|. |
108 const std::set<GURL> local_storage_info = | 109 const std::set<GURL> local_storage_info = |
109 local_storages()->GetLocalStorageInfo(); | 110 local_storages()->GetLocalStorageInfo(); |
110 for (std::set<GURL>::const_iterator it = local_storage_info.begin(); | 111 for (std::set<GURL>::const_iterator it = local_storage_info.begin(); |
111 it != local_storage_info.end(); | 112 it != local_storage_info.end(); |
112 ++it) { | 113 ++it) { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 218 |
218 scoped_ptr<CookiesTreeModel> | 219 scoped_ptr<CookiesTreeModel> |
219 LocalSharedObjectsContainer::CreateCookiesTreeModel() const { | 220 LocalSharedObjectsContainer::CreateCookiesTreeModel() const { |
220 LocalDataContainer* container = new LocalDataContainer( | 221 LocalDataContainer* container = new LocalDataContainer( |
221 cookies(), databases(), local_storages(), session_storages(), appcaches(), | 222 cookies(), databases(), local_storages(), session_storages(), appcaches(), |
222 indexed_dbs(), file_systems(), NULL, channel_ids(), service_workers(), | 223 indexed_dbs(), file_systems(), NULL, channel_ids(), service_workers(), |
223 cache_storages(), NULL); | 224 cache_storages(), NULL); |
224 | 225 |
225 return make_scoped_ptr(new CookiesTreeModel(container, NULL, true)); | 226 return make_scoped_ptr(new CookiesTreeModel(container, NULL, true)); |
226 } | 227 } |
OLD | NEW |