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

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

Issue 102103005: Move c/c/e/extension_set to top-level extensions/ (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Move ExtensionSet to extensions namespace Created 7 years 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 bool ExtensionSpecialStoragePolicy::HasIsolatedStorage(const GURL& origin) { 79 bool ExtensionSpecialStoragePolicy::HasIsolatedStorage(const GURL& origin) {
80 base::AutoLock locker(lock_); 80 base::AutoLock locker(lock_);
81 return isolated_extensions_.Contains(origin); 81 return isolated_extensions_.Contains(origin);
82 } 82 }
83 83
84 bool ExtensionSpecialStoragePolicy::NeedsProtection( 84 bool ExtensionSpecialStoragePolicy::NeedsProtection(
85 const extensions::Extension* extension) { 85 const extensions::Extension* extension) {
86 return extension->is_hosted_app() && !extension->from_bookmark(); 86 return extension->is_hosted_app() && !extension->from_bookmark();
87 } 87 }
88 88
89 const ExtensionSet* ExtensionSpecialStoragePolicy::ExtensionsProtectingOrigin( 89 const extensions::ExtensionSet*
90 ExtensionSpecialStoragePolicy::ExtensionsProtectingOrigin(
90 const GURL& origin) { 91 const GURL& origin) {
91 base::AutoLock locker(lock_); 92 base::AutoLock locker(lock_);
92 return protected_apps_.ExtensionsContaining(origin); 93 return protected_apps_.ExtensionsContaining(origin);
93 } 94 }
94 95
95 void ExtensionSpecialStoragePolicy::GrantRightsForExtension( 96 void ExtensionSpecialStoragePolicy::GrantRightsForExtension(
96 const extensions::Extension* extension) { 97 const extensions::Extension* extension) {
97 DCHECK(extension); 98 DCHECK(extension);
98 if (!(NeedsProtection(extension) || 99 if (!(NeedsProtection(extension) ||
99 extension->HasAPIPermission(APIPermission::kUnlimitedStorage) || 100 extension->HasAPIPermission(APIPermission::kUnlimitedStorage) ||
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 223
223 ExtensionSpecialStoragePolicy::SpecialCollection::~SpecialCollection() { 224 ExtensionSpecialStoragePolicy::SpecialCollection::~SpecialCollection() {
224 STLDeleteValues(&cached_results_); 225 STLDeleteValues(&cached_results_);
225 } 226 }
226 227
227 bool ExtensionSpecialStoragePolicy::SpecialCollection::Contains( 228 bool ExtensionSpecialStoragePolicy::SpecialCollection::Contains(
228 const GURL& origin) { 229 const GURL& origin) {
229 return !ExtensionsContaining(origin)->is_empty(); 230 return !ExtensionsContaining(origin)->is_empty();
230 } 231 }
231 232
232 const ExtensionSet* 233 const extensions::ExtensionSet*
233 ExtensionSpecialStoragePolicy::SpecialCollection::ExtensionsContaining( 234 ExtensionSpecialStoragePolicy::SpecialCollection::ExtensionsContaining(
234 const GURL& origin) { 235 const GURL& origin) {
235 CachedResults::const_iterator found = cached_results_.find(origin); 236 CachedResults::const_iterator found = cached_results_.find(origin);
236 if (found != cached_results_.end()) 237 if (found != cached_results_.end())
237 return found->second; 238 return found->second;
238 239
239 ExtensionSet* result = new ExtensionSet(); 240 extensions::ExtensionSet* result = new extensions::ExtensionSet();
240 for (ExtensionSet::const_iterator iter = extensions_.begin(); 241 for (extensions::ExtensionSet::const_iterator iter = extensions_.begin();
241 iter != extensions_.end(); ++iter) { 242 iter != extensions_.end(); ++iter) {
242 if ((*iter)->OverlapsWithOrigin(origin)) 243 if ((*iter)->OverlapsWithOrigin(origin))
243 result->Insert(*iter); 244 result->Insert(*iter);
244 } 245 }
245 cached_results_[origin] = result; 246 cached_results_[origin] = result;
246 return result; 247 return result;
247 } 248 }
248 249
249 bool ExtensionSpecialStoragePolicy::SpecialCollection::ContainsExtension( 250 bool ExtensionSpecialStoragePolicy::SpecialCollection::ContainsExtension(
250 const std::string& extension_id) { 251 const std::string& extension_id) {
(...skipping 14 matching lines...) Expand all
265 266
266 void ExtensionSpecialStoragePolicy::SpecialCollection::Clear() { 267 void ExtensionSpecialStoragePolicy::SpecialCollection::Clear() {
267 ClearCache(); 268 ClearCache();
268 extensions_.Clear(); 269 extensions_.Clear();
269 } 270 }
270 271
271 void ExtensionSpecialStoragePolicy::SpecialCollection::ClearCache() { 272 void ExtensionSpecialStoragePolicy::SpecialCollection::ClearCache() {
272 STLDeleteValues(&cached_results_); 273 STLDeleteValues(&cached_results_);
273 cached_results_.clear(); 274 cached_results_.clear();
274 } 275 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698