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

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

Issue 13994010: Fix ExtensionSpecialStoragePolicy.IsInstalledApp (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments Created 7 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/extensions/extension_special_storage_policy_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) 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 const ExtensionSet* ExtensionSpecialStoragePolicy::ExtensionsProtectingOrigin( 81 const ExtensionSet* ExtensionSpecialStoragePolicy::ExtensionsProtectingOrigin(
82 const GURL& origin) { 82 const GURL& origin) {
83 base::AutoLock locker(lock_); 83 base::AutoLock locker(lock_);
84 return protected_apps_.ExtensionsContaining(origin); 84 return protected_apps_.ExtensionsContaining(origin);
85 } 85 }
86 86
87 void ExtensionSpecialStoragePolicy::GrantRightsForExtension( 87 void ExtensionSpecialStoragePolicy::GrantRightsForExtension(
88 const extensions::Extension* extension) { 88 const extensions::Extension* extension) {
89 DCHECK(extension); 89 DCHECK(extension);
90 if (!NeedsProtection(extension) && 90 if (!(NeedsProtection(extension) ||
91 !extension->HasAPIPermission( 91 extension->HasAPIPermission(APIPermission::kUnlimitedStorage) ||
92 APIPermission::kUnlimitedStorage) && 92 extension->HasAPIPermission(APIPermission::kFileBrowserHandler) ||
93 !extension->HasAPIPermission( 93 extension->is_app())) {
michaeln 2013/04/16 21:14:09 much more readable that way :)
94 APIPermission::kFileBrowserHandler)) {
95 return; 94 return;
96 } 95 }
97 { 96 {
98 base::AutoLock locker(lock_); 97 base::AutoLock locker(lock_);
99 if (NeedsProtection(extension)) 98 if (NeedsProtection(extension))
100 protected_apps_.Add(extension); 99 protected_apps_.Add(extension);
101 // FIXME: Does GrantRightsForExtension imply |extension| is installed? 100 // FIXME: Does GrantRightsForExtension imply |extension| is installed?
102 if (extension->is_app()) 101 if (extension->is_app())
103 installed_apps_.Add(extension); 102 installed_apps_.Add(extension);
104 if (extension->HasAPIPermission(APIPermission::kUnlimitedStorage)) 103 if (extension->HasAPIPermission(APIPermission::kUnlimitedStorage))
105 unlimited_extensions_.Add(extension); 104 unlimited_extensions_.Add(extension);
106 if (extension->HasAPIPermission( 105 if (extension->HasAPIPermission(APIPermission::kFileBrowserHandler))
107 APIPermission::kFileBrowserHandler))
108 file_handler_extensions_.Add(extension); 106 file_handler_extensions_.Add(extension);
109 } 107 }
110 NotifyChanged(); 108 NotifyChanged();
111 } 109 }
112 110
113 void ExtensionSpecialStoragePolicy::RevokeRightsForExtension( 111 void ExtensionSpecialStoragePolicy::RevokeRightsForExtension(
114 const extensions::Extension* extension) { 112 const extensions::Extension* extension) {
115 DCHECK(extension); 113 DCHECK(extension);
116 if (!NeedsProtection(extension) && 114 if (!(NeedsProtection(extension) ||
117 !extension->HasAPIPermission( 115 extension->HasAPIPermission(APIPermission::kUnlimitedStorage) ||
118 APIPermission::kUnlimitedStorage) && 116 extension->HasAPIPermission(APIPermission::kFileBrowserHandler) ||
119 !extension->HasAPIPermission( 117 extension->is_app())) {
120 APIPermission::kFileBrowserHandler)) {
121 return; 118 return;
122 } 119 }
123 { 120 {
124 base::AutoLock locker(lock_); 121 base::AutoLock locker(lock_);
125 if (NeedsProtection(extension)) 122 if (NeedsProtection(extension))
126 protected_apps_.Remove(extension); 123 protected_apps_.Remove(extension);
127 if (extension->is_app()) 124 if (extension->is_app())
128 installed_apps_.Remove(extension); 125 installed_apps_.Remove(extension);
129 if (extension->HasAPIPermission(APIPermission::kUnlimitedStorage)) 126 if (extension->HasAPIPermission(APIPermission::kUnlimitedStorage))
130 unlimited_extensions_.Remove(extension); 127 unlimited_extensions_.Remove(extension);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 202
206 void ExtensionSpecialStoragePolicy::SpecialCollection::Clear() { 203 void ExtensionSpecialStoragePolicy::SpecialCollection::Clear() {
207 ClearCache(); 204 ClearCache();
208 extensions_.Clear(); 205 extensions_.Clear();
209 } 206 }
210 207
211 void ExtensionSpecialStoragePolicy::SpecialCollection::ClearCache() { 208 void ExtensionSpecialStoragePolicy::SpecialCollection::ClearCache() {
212 STLDeleteValues(&cached_results_); 209 STLDeleteValues(&cached_results_);
213 cached_results_.clear(); 210 cached_results_.clear();
214 } 211 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_special_storage_policy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698