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/common/permissions/permission_set.h" | 5 #include "extensions/common/permissions/permission_set.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // We only need to check our host list to verify access. The host list should | 209 // We only need to check our host list to verify access. The host list should |
210 // already reflect any special rules (such as chrome://favicon, all hosts | 210 // already reflect any special rules (such as chrome://favicon, all hosts |
211 // access, etc.). | 211 // access, etc.). |
212 return scriptable_hosts().MatchesURL(origin); | 212 return scriptable_hosts().MatchesURL(origin); |
213 } | 213 } |
214 | 214 |
215 bool PermissionSet::HasEffectiveAccessToAllHosts() const { | 215 bool PermissionSet::HasEffectiveAccessToAllHosts() const { |
216 // There are two ways this set can have effective access to all hosts: | 216 // There are two ways this set can have effective access to all hosts: |
217 // 1) it has an <all_urls> URL pattern. | 217 // 1) it has an <all_urls> URL pattern. |
218 // 2) it has a named permission with implied full URL access. | 218 // 2) it has a named permission with implied full URL access. |
219 for (URLPatternSet::const_iterator host = effective_hosts().begin(); | 219 if (effective_hosts().MatchesAllURLs()) |
220 host != effective_hosts().end(); ++host) { | 220 return true; |
221 if (host->match_all_urls() || | |
222 (host->match_subdomains() && host->host().empty())) | |
223 return true; | |
224 } | |
225 | 221 |
226 for (APIPermissionSet::const_iterator i = apis().begin(); | 222 for (APIPermissionSet::const_iterator i = apis().begin(); |
227 i != apis().end(); ++i) { | 223 i != apis().end(); ++i) { |
228 if (i->info()->implies_full_url_access()) | 224 if (i->info()->implies_full_url_access()) |
229 return true; | 225 return true; |
230 } | 226 } |
231 return false; | 227 return false; |
232 } | 228 } |
233 | 229 |
234 bool PermissionSet::ShouldWarnAllHosts() const { | 230 bool PermissionSet::ShouldWarnAllHosts() const { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 if (registry_length > 0) { | 303 if (registry_length > 0) { |
308 should_warn_all_hosts_ = WARN_ALL_HOSTS; | 304 should_warn_all_hosts_ = WARN_ALL_HOSTS; |
309 return; | 305 return; |
310 } | 306 } |
311 } | 307 } |
312 | 308 |
313 should_warn_all_hosts_ = DONT_WARN_ALL_HOSTS; | 309 should_warn_all_hosts_ = DONT_WARN_ALL_HOSTS; |
314 } | 310 } |
315 | 311 |
316 } // namespace extensions | 312 } // namespace extensions |
OLD | NEW |