| 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_cookie_helper.h" | 8 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
| 9 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" | 9 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" |
| 10 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" | 10 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" |
| 11 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" | 11 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" |
| 12 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" | 12 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
| 13 #include "chrome/browser/browsing_data/browsing_data_server_bound_cert_helper.h" | 13 #include "chrome/browser/browsing_data/browsing_data_server_bound_cert_helper.h" |
| 14 #include "chrome/browser/browsing_data/cookies_tree_model.h" | 14 #include "chrome/browser/browsing_data/cookies_tree_model.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "content/public/common/url_constants.h" | 16 #include "content/public/common/url_constants.h" |
| 17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
| 18 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 18 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 19 #include "net/cookies/canonical_cookie.h" | 19 #include "net/cookies/canonical_cookie.h" |
| 20 | 20 |
| 21 namespace { |
| 22 |
| 23 // Helper wrapper for net::registry_controlled_domains::SameDomainOrHost |
| 24 // which always excludes private registries. |
| 25 bool SamePublicDomainOrHost(const GURL& gurl1, const GURL& gurl2) { |
| 26 return net::registry_controlled_domains::SameDomainOrHost( |
| 27 gurl1, |
| 28 gurl2, |
| 29 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); |
| 30 } |
| 31 |
| 32 } |
| 33 |
| 21 LocalSharedObjectsContainer::LocalSharedObjectsContainer(Profile* profile) | 34 LocalSharedObjectsContainer::LocalSharedObjectsContainer(Profile* profile) |
| 22 : appcaches_(new CannedBrowsingDataAppCacheHelper(profile)), | 35 : appcaches_(new CannedBrowsingDataAppCacheHelper(profile)), |
| 23 cookies_(new CannedBrowsingDataCookieHelper( | 36 cookies_(new CannedBrowsingDataCookieHelper( |
| 24 profile->GetRequestContext())), | 37 profile->GetRequestContext())), |
| 25 databases_(new CannedBrowsingDataDatabaseHelper(profile)), | 38 databases_(new CannedBrowsingDataDatabaseHelper(profile)), |
| 26 file_systems_(new CannedBrowsingDataFileSystemHelper(profile)), | 39 file_systems_(new CannedBrowsingDataFileSystemHelper(profile)), |
| 27 indexed_dbs_(new CannedBrowsingDataIndexedDBHelper()), | 40 indexed_dbs_(new CannedBrowsingDataIndexedDBHelper()), |
| 28 local_storages_(new CannedBrowsingDataLocalStorageHelper(profile)), | 41 local_storages_(new CannedBrowsingDataLocalStorageHelper(profile)), |
| 29 server_bound_certs_(new CannedBrowsingDataServerBoundCertHelper()), | 42 server_bound_certs_(new CannedBrowsingDataServerBoundCertHelper()), |
| 30 session_storages_(new CannedBrowsingDataLocalStorageHelper(profile)) { | 43 session_storages_(new CannedBrowsingDataLocalStorageHelper(profile)) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 it != origin_cookies_list_map.end(); | 88 it != origin_cookies_list_map.end(); |
| 76 ++it) { | 89 ++it) { |
| 77 const net::CookieList* cookie_list = it->second; | 90 const net::CookieList* cookie_list = it->second; |
| 78 for (net::CookieList::const_iterator cookie = cookie_list->begin(); | 91 for (net::CookieList::const_iterator cookie = cookie_list->begin(); |
| 79 cookie != cookie_list->end(); | 92 cookie != cookie_list->end(); |
| 80 ++cookie) { | 93 ++cookie) { |
| 81 // Strip leading '.'s. | 94 // Strip leading '.'s. |
| 82 std::string cookie_domain = cookie->Domain(); | 95 std::string cookie_domain = cookie->Domain(); |
| 83 if (cookie_domain[0] == '.') | 96 if (cookie_domain[0] == '.') |
| 84 cookie_domain = cookie_domain.substr(1); | 97 cookie_domain = cookie_domain.substr(1); |
| 85 // The |domain_url| is only created in order to use the SameDomainOrHost | 98 // The |domain_url| is only created in order to use the |
| 86 // method below. It does not matter which scheme is used as the scheme is | 99 // SamePublicDomainOrHost method below. It does not matter which scheme is |
| 87 // ignored by the SameDomainOrHost method. | 100 // used as the scheme is ignored by the SamePublicDomainOrHost method. |
| 88 GURL domain_url(std::string(chrome::kHttpScheme) + | 101 GURL domain_url(std::string(chrome::kHttpScheme) + |
| 89 content::kStandardSchemeSeparator + cookie_domain); | 102 content::kStandardSchemeSeparator + cookie_domain); |
| 90 if (net::RegistryControlledDomainService::SameDomainOrHost( | 103 if (SamePublicDomainOrHost(origin, domain_url)) |
| 91 origin, domain_url)) { | |
| 92 ++count; | 104 ++count; |
| 93 } | |
| 94 } | 105 } |
| 95 } | 106 } |
| 96 | 107 |
| 97 // Count local storages for the domain of the given |origin|. | 108 // Count local storages for the domain of the given |origin|. |
| 98 const std::set<GURL> local_storage_info = | 109 const std::set<GURL> local_storage_info = |
| 99 local_storages()->GetLocalStorageInfo(); | 110 local_storages()->GetLocalStorageInfo(); |
| 100 for (std::set<GURL>::const_iterator it = local_storage_info.begin(); | 111 for (std::set<GURL>::const_iterator it = local_storage_info.begin(); |
| 101 it != local_storage_info.end(); | 112 it != local_storage_info.end(); |
| 102 ++it) { | 113 ++it) { |
| 103 if (net::RegistryControlledDomainService::SameDomainOrHost( | 114 if (SamePublicDomainOrHost(origin, *it)) |
| 104 origin, *it)) { | |
| 105 ++count; | 115 ++count; |
| 106 } | |
| 107 } | 116 } |
| 108 | 117 |
| 109 // Count session storages for the domain of the given |origin|. | 118 // Count session storages for the domain of the given |origin|. |
| 110 const std::set<GURL> urls = session_storages()->GetLocalStorageInfo(); | 119 const std::set<GURL> urls = session_storages()->GetLocalStorageInfo(); |
| 111 for (std::set<GURL>::const_iterator it = urls.begin(); | 120 for (std::set<GURL>::const_iterator it = urls.begin(); |
| 112 it != urls.end(); | 121 it != urls.end(); |
| 113 ++it) { | 122 ++it) { |
| 114 if (net::RegistryControlledDomainService::SameDomainOrHost( | 123 if (SamePublicDomainOrHost(origin, *it)) |
| 115 origin, *it)) { | |
| 116 ++count; | 124 ++count; |
| 117 } | |
| 118 } | 125 } |
| 119 | 126 |
| 120 // Count indexed dbs for the domain of the given |origin|. | 127 // Count indexed dbs for the domain of the given |origin|. |
| 121 typedef CannedBrowsingDataIndexedDBHelper::PendingIndexedDBInfo IndexedDBInfo; | 128 typedef CannedBrowsingDataIndexedDBHelper::PendingIndexedDBInfo IndexedDBInfo; |
| 122 const std::set<IndexedDBInfo>& indexed_db_info = | 129 const std::set<IndexedDBInfo>& indexed_db_info = |
| 123 indexed_dbs()->GetIndexedDBInfo(); | 130 indexed_dbs()->GetIndexedDBInfo(); |
| 124 for (std::set<IndexedDBInfo>::const_iterator it = | 131 for (std::set<IndexedDBInfo>::const_iterator it = |
| 125 indexed_db_info.begin(); | 132 indexed_db_info.begin(); |
| 126 it != indexed_db_info.end(); | 133 it != indexed_db_info.end(); |
| 127 ++it) { | 134 ++it) { |
| 128 if (net::RegistryControlledDomainService::SameDomainOrHost( | 135 if (SamePublicDomainOrHost(origin, it->origin)) |
| 129 origin, it->origin)) { | |
| 130 ++count; | 136 ++count; |
| 131 } | |
| 132 } | 137 } |
| 133 | 138 |
| 134 // Count filesystems for the domain of the given |origin|. | 139 // Count filesystems for the domain of the given |origin|. |
| 135 typedef BrowsingDataFileSystemHelper::FileSystemInfo FileSystemInfo; | 140 typedef BrowsingDataFileSystemHelper::FileSystemInfo FileSystemInfo; |
| 136 typedef std::list<FileSystemInfo> FileSystemInfoList; | 141 typedef std::list<FileSystemInfo> FileSystemInfoList; |
| 137 const FileSystemInfoList& file_system_info = | 142 const FileSystemInfoList& file_system_info = |
| 138 file_systems()->GetFileSystemInfo(); | 143 file_systems()->GetFileSystemInfo(); |
| 139 for (FileSystemInfoList::const_iterator it = file_system_info.begin(); | 144 for (FileSystemInfoList::const_iterator it = file_system_info.begin(); |
| 140 it != file_system_info.end(); | 145 it != file_system_info.end(); |
| 141 ++it) { | 146 ++it) { |
| 142 if (net::RegistryControlledDomainService::SameDomainOrHost( | 147 if (SamePublicDomainOrHost(origin, it->origin)) |
| 143 origin, it->origin)) { | |
| 144 ++count; | 148 ++count; |
| 145 } | |
| 146 } | 149 } |
| 147 | 150 |
| 148 // Count databases for the domain of the given |origin|. | 151 // Count databases for the domain of the given |origin|. |
| 149 typedef CannedBrowsingDataDatabaseHelper::PendingDatabaseInfo DatabaseInfo; | 152 typedef CannedBrowsingDataDatabaseHelper::PendingDatabaseInfo DatabaseInfo; |
| 150 const std::set<DatabaseInfo>& database_list = | 153 const std::set<DatabaseInfo>& database_list = |
| 151 databases()->GetPendingDatabaseInfo(); | 154 databases()->GetPendingDatabaseInfo(); |
| 152 for (std::set<DatabaseInfo>::const_iterator it = | 155 for (std::set<DatabaseInfo>::const_iterator it = |
| 153 database_list.begin(); | 156 database_list.begin(); |
| 154 it != database_list.end(); | 157 it != database_list.end(); |
| 155 ++it) { | 158 ++it) { |
| 156 if (net::RegistryControlledDomainService::SameDomainOrHost( | 159 if (SamePublicDomainOrHost(origin, it->origin)) |
| 157 origin, it->origin)) { | |
| 158 ++count; | 160 ++count; |
| 159 } | |
| 160 } | 161 } |
| 161 | 162 |
| 162 // Count the AppCache manifest files for the domain of the given |origin|. | 163 // Count the AppCache manifest files for the domain of the given |origin|. |
| 163 typedef BrowsingDataAppCacheHelper::OriginAppCacheInfoMap | 164 typedef BrowsingDataAppCacheHelper::OriginAppCacheInfoMap |
| 164 OriginAppCacheInfoMap; | 165 OriginAppCacheInfoMap; |
| 165 const OriginAppCacheInfoMap& map = appcaches()->GetOriginAppCacheInfoMap(); | 166 const OriginAppCacheInfoMap& map = appcaches()->GetOriginAppCacheInfoMap(); |
| 166 for (OriginAppCacheInfoMap::const_iterator it = map.begin(); | 167 for (OriginAppCacheInfoMap::const_iterator it = map.begin(); |
| 167 it != map.end(); | 168 it != map.end(); |
| 168 ++it) { | 169 ++it) { |
| 169 const appcache::AppCacheInfoVector& info_vector = it->second; | 170 const appcache::AppCacheInfoVector& info_vector = it->second; |
| 170 for (appcache::AppCacheInfoVector::const_iterator info = | 171 for (appcache::AppCacheInfoVector::const_iterator info = |
| 171 info_vector.begin(); | 172 info_vector.begin(); |
| 172 info != info_vector.end(); | 173 info != info_vector.end(); |
| 173 ++info) { | 174 ++info) { |
| 174 if (net::RegistryControlledDomainService::SameDomainOrHost( | 175 if (SamePublicDomainOrHost(origin, info->manifest_url)) |
| 175 origin, info->manifest_url)) { | |
| 176 ++count; | 176 ++count; |
| 177 } | |
| 178 } | 177 } |
| 179 } | 178 } |
| 180 | 179 |
| 181 return count; | 180 return count; |
| 182 } | 181 } |
| 183 | 182 |
| 184 scoped_ptr<CookiesTreeModel> | 183 scoped_ptr<CookiesTreeModel> |
| 185 LocalSharedObjectsContainer::CreateCookiesTreeModel() const { | 184 LocalSharedObjectsContainer::CreateCookiesTreeModel() const { |
| 186 LocalDataContainer* container = new LocalDataContainer( | 185 LocalDataContainer* container = new LocalDataContainer( |
| 187 cookies()->Clone(), | 186 cookies()->Clone(), |
| 188 databases()->Clone(), | 187 databases()->Clone(), |
| 189 local_storages()->Clone(), | 188 local_storages()->Clone(), |
| 190 session_storages()->Clone(), | 189 session_storages()->Clone(), |
| 191 appcaches()->Clone(), | 190 appcaches()->Clone(), |
| 192 indexed_dbs()->Clone(), | 191 indexed_dbs()->Clone(), |
| 193 file_systems()->Clone(), | 192 file_systems()->Clone(), |
| 194 NULL, | 193 NULL, |
| 195 server_bound_certs()->Clone(), | 194 server_bound_certs()->Clone(), |
| 196 NULL); | 195 NULL); |
| 197 | 196 |
| 198 return make_scoped_ptr(new CookiesTreeModel(container, NULL, true)); | 197 return make_scoped_ptr(new CookiesTreeModel(container, NULL, true)); |
| 199 } | 198 } |
| OLD | NEW |