Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 30 matching lines...) Expand all Loading... | |
| 41 base::AutoLock locker(lock_); | 41 base::AutoLock locker(lock_); |
| 42 return unlimited_extensions_.Contains(origin); | 42 return unlimited_extensions_.Contains(origin); |
| 43 } | 43 } |
| 44 | 44 |
| 45 bool ExtensionSpecialStoragePolicy::IsStorageSessionOnly(const GURL& origin) { | 45 bool ExtensionSpecialStoragePolicy::IsStorageSessionOnly(const GURL& origin) { |
| 46 if (cookie_settings_ == NULL) | 46 if (cookie_settings_ == NULL) |
| 47 return false; | 47 return false; |
| 48 return cookie_settings_->IsCookieSessionOnly(origin); | 48 return cookie_settings_->IsCookieSessionOnly(origin); |
| 49 } | 49 } |
| 50 | 50 |
| 51 bool ExtensionSpecialStoragePolicy::IsInstalledApp(const GURL& origin) { | 51 bool ExtensionSpecialStoragePolicy::IsInstalledApp(const GURL& origin) { |
|
michaeln
2013/04/15 20:59:30
not for this CL but...
This seems like an unfortu
kinuko
2013/04/16 07:20:13
I had the same feeling about layering. Could I cre
kinuko
2013/04/16 07:50:35
Created a new patch for this: https://codereview.c
| |
| 52 return installed_apps_.Contains(origin); | 52 return installed_apps_.Contains(origin); |
| 53 } | 53 } |
| 54 | 54 |
| 55 bool ExtensionSpecialStoragePolicy::HasSessionOnlyOrigins() { | 55 bool ExtensionSpecialStoragePolicy::HasSessionOnlyOrigins() { |
| 56 if (cookie_settings_ == NULL) | 56 if (cookie_settings_ == NULL) |
| 57 return false; | 57 return false; |
| 58 if (cookie_settings_->GetDefaultCookieSetting(NULL) == | 58 if (cookie_settings_->GetDefaultCookieSetting(NULL) == |
| 59 CONTENT_SETTING_SESSION_ONLY) | 59 CONTENT_SETTING_SESSION_ONLY) |
| 60 return true; | 60 return true; |
| 61 ContentSettingsForOneType entries; | 61 ContentSettingsForOneType entries; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 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( |
| 92 APIPermission::kUnlimitedStorage) && | 92 APIPermission::kUnlimitedStorage) && |
| 93 !extension->HasAPIPermission( | 93 !extension->HasAPIPermission( |
| 94 APIPermission::kFileBrowserHandler)) { | 94 APIPermission::kFileBrowserHandler) && |
| 95 !extension->is_app()) { | |
|
asargent_no_longer_on_chrome
2013/04/15 18:43:11
nit: it would be good to keep the order of tests a
kinuko
2013/04/16 07:20:13
Done.
| |
| 95 return; | 96 return; |
| 96 } | 97 } |
| 97 { | 98 { |
| 98 base::AutoLock locker(lock_); | 99 base::AutoLock locker(lock_); |
| 99 if (NeedsProtection(extension)) | 100 if (NeedsProtection(extension)) |
| 100 protected_apps_.Add(extension); | 101 protected_apps_.Add(extension); |
| 101 // FIXME: Does GrantRightsForExtension imply |extension| is installed? | 102 // FIXME: Does GrantRightsForExtension imply |extension| is installed? |
| 102 if (extension->is_app()) | 103 if (extension->is_app()) |
| 103 installed_apps_.Add(extension); | 104 installed_apps_.Add(extension); |
| 104 if (extension->HasAPIPermission(APIPermission::kUnlimitedStorage)) | 105 if (extension->HasAPIPermission(APIPermission::kUnlimitedStorage)) |
| 105 unlimited_extensions_.Add(extension); | 106 unlimited_extensions_.Add(extension); |
| 106 if (extension->HasAPIPermission( | 107 if (extension->HasAPIPermission( |
| 107 APIPermission::kFileBrowserHandler)) | 108 APIPermission::kFileBrowserHandler)) |
| 108 file_handler_extensions_.Add(extension); | 109 file_handler_extensions_.Add(extension); |
| 109 } | 110 } |
| 110 NotifyChanged(); | 111 NotifyChanged(); |
| 111 } | 112 } |
| 112 | 113 |
| 113 void ExtensionSpecialStoragePolicy::RevokeRightsForExtension( | 114 void ExtensionSpecialStoragePolicy::RevokeRightsForExtension( |
| 114 const extensions::Extension* extension) { | 115 const extensions::Extension* extension) { |
| 115 DCHECK(extension); | 116 DCHECK(extension); |
| 116 if (!NeedsProtection(extension) && | 117 if (!NeedsProtection(extension) && |
| 117 !extension->HasAPIPermission( | 118 !extension->HasAPIPermission( |
| 118 APIPermission::kUnlimitedStorage) && | 119 APIPermission::kUnlimitedStorage) && |
| 119 !extension->HasAPIPermission( | 120 !extension->HasAPIPermission( |
| 120 APIPermission::kFileBrowserHandler)) { | 121 APIPermission::kFileBrowserHandler)) { |
|
michaeln
2013/04/15 20:59:30
does the is_app() test need to go here too so the
kinuko
2013/04/16 07:20:13
Good catch, done.
| |
| 121 return; | 122 return; |
| 122 } | 123 } |
| 123 { | 124 { |
| 124 base::AutoLock locker(lock_); | 125 base::AutoLock locker(lock_); |
| 125 if (NeedsProtection(extension)) | 126 if (NeedsProtection(extension)) |
| 126 protected_apps_.Remove(extension); | 127 protected_apps_.Remove(extension); |
| 127 if (extension->is_app()) | 128 if (extension->is_app()) |
| 128 installed_apps_.Remove(extension); | 129 installed_apps_.Remove(extension); |
| 129 if (extension->HasAPIPermission(APIPermission::kUnlimitedStorage)) | 130 if (extension->HasAPIPermission(APIPermission::kUnlimitedStorage)) |
| 130 unlimited_extensions_.Remove(extension); | 131 unlimited_extensions_.Remove(extension); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 | 206 |
| 206 void ExtensionSpecialStoragePolicy::SpecialCollection::Clear() { | 207 void ExtensionSpecialStoragePolicy::SpecialCollection::Clear() { |
| 207 ClearCache(); | 208 ClearCache(); |
| 208 extensions_.Clear(); | 209 extensions_.Clear(); |
| 209 } | 210 } |
| 210 | 211 |
| 211 void ExtensionSpecialStoragePolicy::SpecialCollection::ClearCache() { | 212 void ExtensionSpecialStoragePolicy::SpecialCollection::ClearCache() { |
| 212 STLDeleteValues(&cached_results_); | 213 STLDeleteValues(&cached_results_); |
| 213 cached_results_.clear(); | 214 cached_results_.clear(); |
| 214 } | 215 } |
| OLD | NEW |