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

Side by Side Diff: chrome/browser/extensions/extension_special_storage_policy.cc

Issue 1782053004: Change how the quota system computes the total poolsize for temporary storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 3 years, 10 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
OLDNEW
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/extensions/extension_special_storage_policy.h" 5 #include "chrome/browser/extensions/extension_special_storage_policy.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 content_capabilities_unlimited_extensions_.GrantsCapabilitiesTo( 107 content_capabilities_unlimited_extensions_.GrantsCapabilitiesTo(
108 origin); 108 origin);
109 } 109 }
110 110
111 bool ExtensionSpecialStoragePolicy::IsStorageSessionOnly(const GURL& origin) { 111 bool ExtensionSpecialStoragePolicy::IsStorageSessionOnly(const GURL& origin) {
112 if (cookie_settings_.get() == NULL) 112 if (cookie_settings_.get() == NULL)
113 return false; 113 return false;
114 return cookie_settings_->IsCookieSessionOnly(origin); 114 return cookie_settings_->IsCookieSessionOnly(origin);
115 } 115 }
116 116
117 bool ExtensionSpecialStoragePolicy::CanQueryDiskSize(const GURL& origin) {
118 base::AutoLock locker(lock_);
119 return installed_apps_.Contains(origin);
120 }
121
122 bool ExtensionSpecialStoragePolicy::HasSessionOnlyOrigins() { 117 bool ExtensionSpecialStoragePolicy::HasSessionOnlyOrigins() {
123 if (cookie_settings_.get() == NULL) 118 if (cookie_settings_.get() == NULL)
124 return false; 119 return false;
125 if (cookie_settings_->GetDefaultCookieSetting(NULL) == 120 if (cookie_settings_->GetDefaultCookieSetting(NULL) ==
126 CONTENT_SETTING_SESSION_ONLY) 121 CONTENT_SETTING_SESSION_ONLY)
127 return true; 122 return true;
128 ContentSettingsForOneType entries; 123 ContentSettingsForOneType entries;
129 cookie_settings_->GetCookieSettings(&entries); 124 cookie_settings_->GetCookieSettings(&entries);
130 for (size_t i = 0; i < entries.size(); ++i) { 125 for (size_t i = 0; i < entries.size(); ++i) {
131 if (entries[i].setting == CONTENT_SETTING_SESSION_ONLY) 126 if (entries[i].setting == CONTENT_SETTING_SESSION_ONLY)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 165
171 if (NeedsProtection(extension) || 166 if (NeedsProtection(extension) ||
172 extension->permissions_data()->HasAPIPermission( 167 extension->permissions_data()->HasAPIPermission(
173 APIPermission::kUnlimitedStorage) || 168 APIPermission::kUnlimitedStorage) ||
174 extension->permissions_data()->HasAPIPermission( 169 extension->permissions_data()->HasAPIPermission(
175 APIPermission::kFileBrowserHandler) || 170 APIPermission::kFileBrowserHandler) ||
176 extensions::AppIsolationInfo::HasIsolatedStorage(extension) || 171 extensions::AppIsolationInfo::HasIsolatedStorage(extension) ||
177 extension->is_app()) { 172 extension->is_app()) {
178 if (NeedsProtection(extension) && protected_apps_.Add(extension)) 173 if (NeedsProtection(extension) && protected_apps_.Add(extension))
179 change_flags |= SpecialStoragePolicy::STORAGE_PROTECTED; 174 change_flags |= SpecialStoragePolicy::STORAGE_PROTECTED;
180 // FIXME: Does GrantRightsForExtension imply |extension| is installed?
181 if (extension->is_app())
182 installed_apps_.Add(extension);
183 175
184 if (extension->permissions_data()->HasAPIPermission( 176 if (extension->permissions_data()->HasAPIPermission(
185 APIPermission::kUnlimitedStorage) && 177 APIPermission::kUnlimitedStorage) &&
186 unlimited_extensions_.Add(extension)) { 178 unlimited_extensions_.Add(extension)) {
187 if (extension->is_hosted_app()) 179 if (extension->is_hosted_app())
188 LogHostedAppUnlimitedStorageUsage(extension, browser_context); 180 LogHostedAppUnlimitedStorageUsage(extension, browser_context);
189 change_flags |= SpecialStoragePolicy::STORAGE_UNLIMITED; 181 change_flags |= SpecialStoragePolicy::STORAGE_UNLIMITED;
190 } 182 }
191 183
192 if (extension->permissions_data()->HasAPIPermission( 184 if (extension->permissions_data()->HasAPIPermission(
(...skipping 25 matching lines...) Expand all
218 if (NeedsProtection(extension) || 210 if (NeedsProtection(extension) ||
219 extension->permissions_data()->HasAPIPermission( 211 extension->permissions_data()->HasAPIPermission(
220 APIPermission::kUnlimitedStorage) || 212 APIPermission::kUnlimitedStorage) ||
221 extension->permissions_data()->HasAPIPermission( 213 extension->permissions_data()->HasAPIPermission(
222 APIPermission::kFileBrowserHandler) || 214 APIPermission::kFileBrowserHandler) ||
223 extensions::AppIsolationInfo::HasIsolatedStorage(extension) || 215 extensions::AppIsolationInfo::HasIsolatedStorage(extension) ||
224 extension->is_app()) { 216 extension->is_app()) {
225 if (NeedsProtection(extension) && protected_apps_.Remove(extension)) 217 if (NeedsProtection(extension) && protected_apps_.Remove(extension))
226 change_flags |= SpecialStoragePolicy::STORAGE_PROTECTED; 218 change_flags |= SpecialStoragePolicy::STORAGE_PROTECTED;
227 219
228 if (extension->is_app())
229 installed_apps_.Remove(extension);
230
231 if (extension->permissions_data()->HasAPIPermission( 220 if (extension->permissions_data()->HasAPIPermission(
232 APIPermission::kUnlimitedStorage) && 221 APIPermission::kUnlimitedStorage) &&
233 unlimited_extensions_.Remove(extension)) 222 unlimited_extensions_.Remove(extension))
234 change_flags |= SpecialStoragePolicy::STORAGE_UNLIMITED; 223 change_flags |= SpecialStoragePolicy::STORAGE_UNLIMITED;
235 224
236 if (extension->permissions_data()->HasAPIPermission( 225 if (extension->permissions_data()->HasAPIPermission(
237 APIPermission::kFileBrowserHandler)) 226 APIPermission::kFileBrowserHandler))
238 file_handler_extensions_.Remove(extension); 227 file_handler_extensions_.Remove(extension);
239 228
240 if (extensions::AppIsolationInfo::HasIsolatedStorage(extension)) 229 if (extensions::AppIsolationInfo::HasIsolatedStorage(extension))
241 isolated_extensions_.Remove(extension); 230 isolated_extensions_.Remove(extension);
242 } 231 }
243 232
244 if (change_flags) { 233 if (change_flags) {
245 NotifyRevoked(Extension::GetBaseURLFromExtensionId(extension->id()), 234 NotifyRevoked(Extension::GetBaseURLFromExtensionId(extension->id()),
246 change_flags); 235 change_flags);
247 } 236 }
248 } 237 }
249 238
250 void ExtensionSpecialStoragePolicy::RevokeRightsForAllExtensions() { 239 void ExtensionSpecialStoragePolicy::RevokeRightsForAllExtensions() {
251 { 240 {
252 base::AutoLock locker(lock_); 241 base::AutoLock locker(lock_);
253 protected_apps_.Clear(); 242 protected_apps_.Clear();
254 installed_apps_.Clear();
255 unlimited_extensions_.Clear(); 243 unlimited_extensions_.Clear();
256 file_handler_extensions_.Clear(); 244 file_handler_extensions_.Clear();
257 isolated_extensions_.Clear(); 245 isolated_extensions_.Clear();
258 content_capabilities_unlimited_extensions_.Clear(); 246 content_capabilities_unlimited_extensions_.Clear();
259 } 247 }
260 248
261 NotifyCleared(); 249 NotifyCleared();
262 } 250 }
263 251
264 void ExtensionSpecialStoragePolicy::NotifyGranted( 252 void ExtensionSpecialStoragePolicy::NotifyGranted(
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 } 343 }
356 344
357 void ExtensionSpecialStoragePolicy::SpecialCollection::Clear() { 345 void ExtensionSpecialStoragePolicy::SpecialCollection::Clear() {
358 ClearCache(); 346 ClearCache();
359 extensions_.Clear(); 347 extensions_.Clear();
360 } 348 }
361 349
362 void ExtensionSpecialStoragePolicy::SpecialCollection::ClearCache() { 350 void ExtensionSpecialStoragePolicy::SpecialCollection::ClearCache() {
363 cached_results_.clear(); 351 cached_results_.clear();
364 } 352 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698