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

Side by Side Diff: chrome/browser/browsing_data_appcache_helper.cc

Issue 9958107: Limiting the "Cookies and site data" form to "web safe" schemes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: License. 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/browsing_data_appcache_helper_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 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/browsing_data_appcache_helper.h" 5 #include "chrome/browser/browsing_data_appcache_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "chrome/browser/browsing_data_helper.h"
9 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/url_constants.h" 11 #include "chrome/common/url_constants.h"
11 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/resource_context.h" 13 #include "content/public/browser/resource_context.h"
13 #include "webkit/appcache/appcache_database.h" 14 #include "webkit/appcache/appcache_database.h"
14 #include "webkit/appcache/appcache_storage.h" 15 #include "webkit/appcache/appcache_storage.h"
15 16
16 using appcache::AppCacheDatabase; 17 using appcache::AppCacheDatabase;
17 using content::BrowserContext; 18 using content::BrowserContext;
18 using content::BrowserThread; 19 using content::BrowserThread;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 68 }
68 69
69 ResourceContext::GetAppCacheService(resource_context_)->DeleteAppCacheGroup( 70 ResourceContext::GetAppCacheService(resource_context_)->DeleteAppCacheGroup(
70 manifest_url, net::CompletionCallback()); 71 manifest_url, net::CompletionCallback());
71 } 72 }
72 73
73 BrowsingDataAppCacheHelper::~BrowsingDataAppCacheHelper() {} 74 BrowsingDataAppCacheHelper::~BrowsingDataAppCacheHelper() {}
74 75
75 void BrowsingDataAppCacheHelper::OnFetchComplete(int rv) { 76 void BrowsingDataAppCacheHelper::OnFetchComplete(int rv) {
76 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { 77 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) {
77 // Filter out appcache info entries for extensions. Extension state is not 78 // Filter out appcache info entries for non-websafe schemes. Extension state
78 // considered browsing data. 79 // and DevTools, for example, are not considered browsing data.
79 typedef std::map<GURL, appcache::AppCacheInfoVector> InfoByOrigin; 80 typedef std::map<GURL, appcache::AppCacheInfoVector> InfoByOrigin;
80 InfoByOrigin& origin_map = info_collection_->infos_by_origin; 81 InfoByOrigin& origin_map = info_collection_->infos_by_origin;
81 for (InfoByOrigin::iterator origin = origin_map.begin(); 82 for (InfoByOrigin::iterator origin = origin_map.begin();
82 origin != origin_map.end();) { 83 origin != origin_map.end();) {
83 InfoByOrigin::iterator current = origin; 84 InfoByOrigin::iterator current = origin;
84 ++origin; 85 ++origin;
85 if (current->first.SchemeIs(chrome::kExtensionScheme)) 86 if (!BrowsingDataHelper::HasValidScheme(current->first))
86 origin_map.erase(current); 87 origin_map.erase(current);
87 } 88 }
88 89
89 BrowserThread::PostTask( 90 BrowserThread::PostTask(
90 BrowserThread::UI, FROM_HERE, 91 BrowserThread::UI, FROM_HERE,
91 base::Bind(&BrowsingDataAppCacheHelper::OnFetchComplete, this, rv)); 92 base::Bind(&BrowsingDataAppCacheHelper::OnFetchComplete, this, rv));
92 return; 93 return;
93 } 94 }
94 95
95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 15 matching lines...) Expand all
111 CannedBrowsingDataAppCacheHelper* CannedBrowsingDataAppCacheHelper::Clone() { 112 CannedBrowsingDataAppCacheHelper* CannedBrowsingDataAppCacheHelper::Clone() {
112 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 113 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
113 CannedBrowsingDataAppCacheHelper* clone = 114 CannedBrowsingDataAppCacheHelper* clone =
114 new CannedBrowsingDataAppCacheHelper(profile_); 115 new CannedBrowsingDataAppCacheHelper(profile_);
115 116
116 clone->info_collection_->infos_by_origin = info_collection_->infos_by_origin; 117 clone->info_collection_->infos_by_origin = info_collection_->infos_by_origin;
117 return clone; 118 return clone;
118 } 119 }
119 120
120 void CannedBrowsingDataAppCacheHelper::AddAppCache(const GURL& manifest_url) { 121 void CannedBrowsingDataAppCacheHelper::AddAppCache(const GURL& manifest_url) {
122 if (!BrowsingDataHelper::HasValidScheme(manifest_url))
123 return; // Ignore non-websafe schemes.
124
121 typedef std::map<GURL, appcache::AppCacheInfoVector> InfoByOrigin; 125 typedef std::map<GURL, appcache::AppCacheInfoVector> InfoByOrigin;
122 InfoByOrigin& origin_map = info_collection_->infos_by_origin; 126 InfoByOrigin& origin_map = info_collection_->infos_by_origin;
123 appcache::AppCacheInfoVector& appcache_infos_ = 127 appcache::AppCacheInfoVector& appcache_infos_ =
124 origin_map[manifest_url.GetOrigin()]; 128 origin_map[manifest_url.GetOrigin()];
125 129
126 for (appcache::AppCacheInfoVector::iterator 130 for (appcache::AppCacheInfoVector::iterator
127 appcache = appcache_infos_.begin(); appcache != appcache_infos_.end(); 131 appcache = appcache_infos_.begin(); appcache != appcache_infos_.end();
128 ++appcache) { 132 ++appcache) {
129 if (appcache->manifest_url == manifest_url) 133 if (appcache->manifest_url == manifest_url)
130 return; 134 return;
(...skipping 11 matching lines...) Expand all
142 bool CannedBrowsingDataAppCacheHelper::empty() const { 146 bool CannedBrowsingDataAppCacheHelper::empty() const {
143 return info_collection_->infos_by_origin.empty(); 147 return info_collection_->infos_by_origin.empty();
144 } 148 }
145 149
146 void CannedBrowsingDataAppCacheHelper::StartFetching( 150 void CannedBrowsingDataAppCacheHelper::StartFetching(
147 const base::Closure& completion_callback) { 151 const base::Closure& completion_callback) {
148 completion_callback.Run(); 152 completion_callback.Run();
149 } 153 }
150 154
151 CannedBrowsingDataAppCacheHelper::~CannedBrowsingDataAppCacheHelper() {} 155 CannedBrowsingDataAppCacheHelper::~CannedBrowsingDataAppCacheHelper() {}
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/browsing_data_appcache_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698