OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 2153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2164 | 2164 |
2165 const Extension* ExtensionService::GetExtensionByWebExtent(const GURL& url) { | 2165 const Extension* ExtensionService::GetExtensionByWebExtent(const GURL& url) { |
2166 for (size_t i = 0; i < extensions_.size(); ++i) { | 2166 for (size_t i = 0; i < extensions_.size(); ++i) { |
2167 if (extensions_[i]->web_extent().MatchesURL(url)) | 2167 if (extensions_[i]->web_extent().MatchesURL(url)) |
2168 return extensions_[i]; | 2168 return extensions_[i]; |
2169 } | 2169 } |
2170 return NULL; | 2170 return NULL; |
2171 } | 2171 } |
2172 | 2172 |
2173 bool ExtensionService::ExtensionBindingsAllowed(const GURL& url) { | 2173 bool ExtensionService::ExtensionBindingsAllowed(const GURL& url) { |
2174 // Allow bindings for all packaged extension. | 2174 // Allow bindings for all packaged extensions. |
2175 if (GetExtensionByURL(url)) | 2175 // Note that GetExtensionByURL may return an Extension for hosted apps |
| 2176 // if the URL came from GetEffectiveURL. |
| 2177 const Extension* extension = GetExtensionByURL(url); |
| 2178 if (extension && extension->GetType() != Extension::TYPE_HOSTED_APP) |
2176 return true; | 2179 return true; |
2177 | 2180 |
2178 // Allow bindings for all component, hosted apps. | 2181 // Allow bindings for all component, hosted apps. |
2179 const Extension* extension = GetExtensionByWebExtent(url); | 2182 if (!extension) |
| 2183 extension = GetExtensionByWebExtent(url); |
2180 return (extension && extension->location() == Extension::COMPONENT); | 2184 return (extension && extension->location() == Extension::COMPONENT); |
2181 } | 2185 } |
2182 | 2186 |
2183 const Extension* ExtensionService::GetExtensionByOverlappingWebExtent( | 2187 const Extension* ExtensionService::GetExtensionByOverlappingWebExtent( |
2184 const URLPatternSet& extent) { | 2188 const URLPatternSet& extent) { |
2185 for (size_t i = 0; i < extensions_.size(); ++i) { | 2189 for (size_t i = 0; i < extensions_.size(); ++i) { |
2186 if (extensions_[i]->web_extent().OverlapsWith(extent)) | 2190 if (extensions_[i]->web_extent().OverlapsWith(extent)) |
2187 return extensions_[i]; | 2191 return extensions_[i]; |
2188 } | 2192 } |
2189 | 2193 |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2431 | 2435 |
2432 ExtensionService::NaClModuleInfoList::iterator | 2436 ExtensionService::NaClModuleInfoList::iterator |
2433 ExtensionService::FindNaClModule(const GURL& url) { | 2437 ExtensionService::FindNaClModule(const GURL& url) { |
2434 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); | 2438 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); |
2435 iter != nacl_module_list_.end(); ++iter) { | 2439 iter != nacl_module_list_.end(); ++iter) { |
2436 if (iter->url == url) | 2440 if (iter->url == url) |
2437 return iter; | 2441 return iter; |
2438 } | 2442 } |
2439 return nacl_module_list_.end(); | 2443 return nacl_module_list_.end(); |
2440 } | 2444 } |
OLD | NEW |