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

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: The others. 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/child_process_security_policy.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;
19 using content::ResourceContext; 20 using content::ResourceContext;
20 21
21 BrowsingDataAppCacheHelper::BrowsingDataAppCacheHelper(Profile* profile) 22 BrowsingDataAppCacheHelper::BrowsingDataAppCacheHelper(Profile* profile)
(...skipping 45 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;
82 content::ChildProcessSecurityPolicy* policy =
83 content::ChildProcessSecurityPolicy::GetInstance();
81 for (InfoByOrigin::iterator origin = origin_map.begin(); 84 for (InfoByOrigin::iterator origin = origin_map.begin();
82 origin != origin_map.end();) { 85 origin != origin_map.end();) {
83 InfoByOrigin::iterator current = origin; 86 InfoByOrigin::iterator current = origin;
84 ++origin; 87 ++origin;
85 if (current->first.SchemeIs(chrome::kExtensionScheme)) 88 if (policy->IsWebSafeScheme(current->first.scheme()))
jochen (gone - plz use gerrit) 2012/04/03 09:41:21 forgot ! ?
Mike West 2012/04/03 14:45:51 Gah.
86 origin_map.erase(current); 89 origin_map.erase(current);
87 } 90 }
88 91
89 BrowserThread::PostTask( 92 BrowserThread::PostTask(
90 BrowserThread::UI, FROM_HERE, 93 BrowserThread::UI, FROM_HERE,
91 base::Bind(&BrowsingDataAppCacheHelper::OnFetchComplete, this, rv)); 94 base::Bind(&BrowsingDataAppCacheHelper::OnFetchComplete, this, rv));
92 return; 95 return;
93 } 96 }
94 97
95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 98 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 15 matching lines...) Expand all
111 CannedBrowsingDataAppCacheHelper* CannedBrowsingDataAppCacheHelper::Clone() { 114 CannedBrowsingDataAppCacheHelper* CannedBrowsingDataAppCacheHelper::Clone() {
112 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
113 CannedBrowsingDataAppCacheHelper* clone = 116 CannedBrowsingDataAppCacheHelper* clone =
114 new CannedBrowsingDataAppCacheHelper(profile_); 117 new CannedBrowsingDataAppCacheHelper(profile_);
115 118
116 clone->info_collection_->infos_by_origin = info_collection_->infos_by_origin; 119 clone->info_collection_->infos_by_origin = info_collection_->infos_by_origin;
117 return clone; 120 return clone;
118 } 121 }
119 122
120 void CannedBrowsingDataAppCacheHelper::AddAppCache(const GURL& manifest_url) { 123 void CannedBrowsingDataAppCacheHelper::AddAppCache(const GURL& manifest_url) {
124 content::ChildProcessSecurityPolicy* policy =
125 content::ChildProcessSecurityPolicy::GetInstance();
126 if (!policy->IsWebSafeScheme(manifest_url.scheme()))
127 return; // Ignore non-websafe schemes.
128
121 typedef std::map<GURL, appcache::AppCacheInfoVector> InfoByOrigin; 129 typedef std::map<GURL, appcache::AppCacheInfoVector> InfoByOrigin;
122 InfoByOrigin& origin_map = info_collection_->infos_by_origin; 130 InfoByOrigin& origin_map = info_collection_->infos_by_origin;
123 appcache::AppCacheInfoVector& appcache_infos_ = 131 appcache::AppCacheInfoVector& appcache_infos_ =
124 origin_map[manifest_url.GetOrigin()]; 132 origin_map[manifest_url.GetOrigin()];
125 133
126 for (appcache::AppCacheInfoVector::iterator 134 for (appcache::AppCacheInfoVector::iterator
127 appcache = appcache_infos_.begin(); appcache != appcache_infos_.end(); 135 appcache = appcache_infos_.begin(); appcache != appcache_infos_.end();
128 ++appcache) { 136 ++appcache) {
129 if (appcache->manifest_url == manifest_url) 137 if (appcache->manifest_url == manifest_url)
130 return; 138 return;
(...skipping 11 matching lines...) Expand all
142 bool CannedBrowsingDataAppCacheHelper::empty() const { 150 bool CannedBrowsingDataAppCacheHelper::empty() const {
143 return info_collection_->infos_by_origin.empty(); 151 return info_collection_->infos_by_origin.empty();
144 } 152 }
145 153
146 void CannedBrowsingDataAppCacheHelper::StartFetching( 154 void CannedBrowsingDataAppCacheHelper::StartFetching(
147 const base::Closure& completion_callback) { 155 const base::Closure& completion_callback) {
148 completion_callback.Run(); 156 completion_callback.Run();
149 } 157 }
150 158
151 CannedBrowsingDataAppCacheHelper::~CannedBrowsingDataAppCacheHelper() {} 159 CannedBrowsingDataAppCacheHelper::~CannedBrowsingDataAppCacheHelper() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698