| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "extensions/browser/info_map.h" | 5 #include "extensions/browser/info_map.h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "extensions/browser/content_verifier.h" | 9 #include "extensions/browser/content_verifier.h" |
| 10 #include "extensions/common/constants.h" | 10 #include "extensions/common/constants.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 if (!process_map_.Remove(extension_id, process_id, site_instance_id)) { | 132 if (!process_map_.Remove(extension_id, process_id, site_instance_id)) { |
| 133 NOTREACHED() << "Unknown extension process registration for: " | 133 NOTREACHED() << "Unknown extension process registration for: " |
| 134 << extension_id << "," << process_id << "."; | 134 << extension_id << "," << process_id << "."; |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 | 137 |
| 138 void InfoMap::UnregisterAllExtensionsInProcess(int process_id) { | 138 void InfoMap::UnregisterAllExtensionsInProcess(int process_id) { |
| 139 process_map_.RemoveAllFromProcess(process_id); | 139 process_map_.RemoveAllFromProcess(process_id); |
| 140 } | 140 } |
| 141 | 141 |
| 142 bool InfoMap::SecurityOriginHasAPIPermission( | |
| 143 const GURL& origin, | |
| 144 int process_id, | |
| 145 APIPermission::ID permission) const { | |
| 146 CheckOnValidThread(); | |
| 147 if (origin.SchemeIs(kExtensionScheme)) { | |
| 148 const std::string& id = origin.host(); | |
| 149 const Extension* extension = extensions_.GetByID(id); | |
| 150 return extension && | |
| 151 extension->permissions_data()->HasAPIPermission(permission) && | |
| 152 process_map_.Contains(id, process_id); | |
| 153 } | |
| 154 for (const auto& extension : extensions_) { | |
| 155 if (extension->web_extent().MatchesSecurityOrigin(origin) && | |
| 156 extension->permissions_data()->HasAPIPermission(permission) && | |
| 157 process_map_.Contains(extension->id(), process_id)) { | |
| 158 return true; | |
| 159 } | |
| 160 } | |
| 161 return false; | |
| 162 } | |
| 163 | |
| 164 // This function is security sensitive. Bugs could cause problems that break | 142 // This function is security sensitive. Bugs could cause problems that break |
| 165 // restrictions on local file access or NaCl's validation caching. If you modify | 143 // restrictions on local file access or NaCl's validation caching. If you modify |
| 166 // this function, please get a security review from a NaCl person. | 144 // this function, please get a security review from a NaCl person. |
| 167 bool InfoMap::MapUrlToLocalFilePath(const GURL& file_url, | 145 bool InfoMap::MapUrlToLocalFilePath(const GURL& file_url, |
| 168 bool use_blocking_api, | 146 bool use_blocking_api, |
| 169 base::FilePath* file_path) { | 147 base::FilePath* file_path) { |
| 170 // Check that the URL is recognized by the extension system. | 148 // Check that the URL is recognized by the extension system. |
| 171 const Extension* extension = extensions_.GetExtensionOrAppByURL(file_url); | 149 const Extension* extension = extensions_.GetExtensionOrAppByURL(file_url); |
| 172 if (!extension) | 150 if (!extension) |
| 173 return false; | 151 return false; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 } | 225 } |
| 248 | 226 |
| 249 InfoMap::~InfoMap() { | 227 InfoMap::~InfoMap() { |
| 250 if (quota_service_) { | 228 if (quota_service_) { |
| 251 BrowserThread::DeleteSoon( | 229 BrowserThread::DeleteSoon( |
| 252 BrowserThread::IO, FROM_HERE, quota_service_.release()); | 230 BrowserThread::IO, FROM_HERE, quota_service_.release()); |
| 253 } | 231 } |
| 254 } | 232 } |
| 255 | 233 |
| 256 } // namespace extensions | 234 } // namespace extensions |
| OLD | NEW |