| 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/common/extensions/extension_set.h" | 5 #include "chrome/common/extensions/extension_set.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/common/extensions/extension.h" | 8 #include "chrome/common/extensions/extension.h" |
| 9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
| 10 | 10 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 const Extension* ExtensionSet::GetByID(const std::string& id) const { | 121 const Extension* ExtensionSet::GetByID(const std::string& id) const { |
| 122 ExtensionMap::const_iterator i = extensions_.find(id); | 122 ExtensionMap::const_iterator i = extensions_.find(id); |
| 123 if (i != extensions_.end()) | 123 if (i != extensions_.end()) |
| 124 return i->second.get(); | 124 return i->second.get(); |
| 125 else | 125 else |
| 126 return NULL; | 126 return NULL; |
| 127 } | 127 } |
| 128 | 128 |
| 129 bool ExtensionSet::ExtensionBindingsAllowed( | 129 bool ExtensionSet::ExtensionBindingsAllowed( |
| 130 const ExtensionURLInfo& info) const { | 130 const ExtensionURLInfo& info) const { |
| 131 if (info.origin().isUnique()) | 131 if (info.origin().isUnique() || IsSandboxedPage(info)) |
| 132 return false; | 132 return false; |
| 133 | 133 |
| 134 if (info.url().SchemeIs(chrome::kExtensionScheme)) | 134 if (info.url().SchemeIs(chrome::kExtensionScheme)) |
| 135 return true; | 135 return true; |
| 136 | 136 |
| 137 ExtensionMap::const_iterator i = extensions_.begin(); | 137 ExtensionMap::const_iterator i = extensions_.begin(); |
| 138 for (; i != extensions_.end(); ++i) { | 138 for (; i != extensions_.end(); ++i) { |
| 139 if (i->second->location() == Extension::COMPONENT && | 139 if (i->second->location() == Extension::COMPONENT && |
| 140 i->second->web_extent().MatchesURL(info.url())) | 140 i->second->web_extent().MatchesURL(info.url())) |
| 141 return true; | 141 return true; |
| 142 } | 142 } |
| 143 | 143 |
| 144 return false; | 144 return false; |
| 145 } | 145 } |
| 146 |
| 147 bool ExtensionSet::IsSandboxedPage(const ExtensionURLInfo& info) const { |
| 148 if (info.origin().isUnique()) |
| 149 return true; |
| 150 |
| 151 if (info.url().SchemeIs(chrome::kExtensionScheme)) { |
| 152 const Extension* extension = GetByID(info.url().host()); |
| 153 if (extension) { |
| 154 return extension->IsSandboxedPage(info.url().path()); |
| 155 } |
| 156 } |
| 157 return false; |
| 158 } |
| OLD | NEW |