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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 if (!process_map_.Remove(extension_id, process_id, site_instance_id)) { | 122 if (!process_map_.Remove(extension_id, process_id, site_instance_id)) { |
123 NOTREACHED() << "Unknown extension process registration for: " | 123 NOTREACHED() << "Unknown extension process registration for: " |
124 << extension_id << "," << process_id << "."; | 124 << extension_id << "," << process_id << "."; |
125 } | 125 } |
126 } | 126 } |
127 | 127 |
128 void InfoMap::UnregisterAllExtensionsInProcess(int process_id) { | 128 void InfoMap::UnregisterAllExtensionsInProcess(int process_id) { |
129 process_map_.RemoveAllFromProcess(process_id); | 129 process_map_.RemoveAllFromProcess(process_id); |
130 } | 130 } |
131 | 131 |
132 void InfoMap::GetExtensionsWithAPIPermissionForSecurityOrigin( | 132 bool InfoMap::SecurityOriginHasAPIPermission( |
133 const GURL& origin, | 133 const GURL& origin, |
134 int process_id, | 134 int process_id, |
135 APIPermission::ID permission, | 135 APIPermission::ID permission) const { |
136 ExtensionSet* extensions) const { | 136 CheckOnValidThread(); |
137 DCHECK(extensions); | |
138 | 137 |
139 if (origin.SchemeIs(kExtensionScheme)) { | 138 if (origin.SchemeIs(kExtensionScheme)) { |
140 const std::string& id = origin.host(); | 139 const std::string& id = origin.host(); |
141 const Extension* extension = extensions_.GetByID(id); | 140 const Extension* extension = extensions_.GetByID(id); |
142 if (extension && | 141 |
not at google - send to devlin
2015/06/26 14:50:01
Not necessary to change this code to add a blank l
Peter Beverloo
2015/06/29 12:54:21
I removed the blank lines..
| |
143 extension->permissions_data()->HasAPIPermission(permission) && | 142 return extension && |
144 process_map_.Contains(id, process_id)) { | 143 extension->permissions_data()->HasAPIPermission(permission) && |
145 extensions->Insert(extension); | 144 process_map_.Contains(id, process_id); |
146 } | |
147 return; | |
148 } | 145 } |
149 | 146 |
150 ExtensionSet::const_iterator i = extensions_.begin(); | 147 for (const auto& extension : extensions_) { |
151 for (; i != extensions_.end(); ++i) { | 148 if (extension->web_extent().MatchesSecurityOrigin(origin) && |
152 if ((*i)->web_extent().MatchesSecurityOrigin(origin) && | 149 extension->permissions_data()->HasAPIPermission(permission) && |
153 process_map_.Contains((*i)->id(), process_id) && | 150 process_map_.Contains(extension->id(), process_id)) { |
154 (*i)->permissions_data()->HasAPIPermission(permission)) { | 151 return true; |
155 extensions->Insert(*i); | |
156 } | 152 } |
157 } | 153 } |
158 } | |
159 | 154 |
160 bool InfoMap::SecurityOriginHasAPIPermission(const GURL& origin, | 155 return false; |
161 int process_id, | |
162 APIPermission::ID permission) | |
163 const { | |
164 ExtensionSet extensions; | |
165 GetExtensionsWithAPIPermissionForSecurityOrigin( | |
166 origin, process_id, permission, &extensions); | |
167 return !extensions.is_empty(); | |
168 } | 156 } |
169 | 157 |
170 // This function is security sensitive. Bugs could cause problems that break | 158 // This function is security sensitive. Bugs could cause problems that break |
171 // restrictions on local file access or NaCl's validation caching. If you modify | 159 // restrictions on local file access or NaCl's validation caching. If you modify |
172 // this function, please get a security review from a NaCl person. | 160 // this function, please get a security review from a NaCl person. |
173 bool InfoMap::MapUrlToLocalFilePath(const GURL& file_url, | 161 bool InfoMap::MapUrlToLocalFilePath(const GURL& file_url, |
174 bool use_blocking_api, | 162 bool use_blocking_api, |
175 base::FilePath* file_path) { | 163 base::FilePath* file_path) { |
176 // Check that the URL is recognized by the extension system. | 164 // Check that the URL is recognized by the extension system. |
177 const Extension* extension = extensions_.GetExtensionOrAppByURL(file_url); | 165 const Extension* extension = extensions_.GetExtensionOrAppByURL(file_url); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
253 } | 241 } |
254 | 242 |
255 InfoMap::~InfoMap() { | 243 InfoMap::~InfoMap() { |
256 if (quota_service_) { | 244 if (quota_service_) { |
257 BrowserThread::DeleteSoon( | 245 BrowserThread::DeleteSoon( |
258 BrowserThread::IO, FROM_HERE, quota_service_.release()); | 246 BrowserThread::IO, FROM_HERE, quota_service_.release()); |
259 } | 247 } |
260 } | 248 } |
261 | 249 |
262 } // namespace extensions | 250 } // namespace extensions |
OLD | NEW |