Chromium Code Reviews| Index: chrome/common/extensions/extension_set.cc |
| diff --git a/chrome/common/extensions/extension_set.cc b/chrome/common/extensions/extension_set.cc |
| index 22f0ed22d1f81724be7da91523aa4c758ba8306c..1e4f2b8e47dcca983244e8b45aac5dd99b02466b 100644 |
| --- a/chrome/common/extensions/extension_set.cc |
| +++ b/chrome/common/extensions/extension_set.cc |
| @@ -7,8 +7,11 @@ |
| #include "base/logging.h" |
| #include "chrome/common/extensions/extension.h" |
| #include "chrome/common/url_constants.h" |
| +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h" |
| +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| using WebKit::WebSecurityOrigin; |
| +using WebKit::WebString; |
| using extensions::Extension; |
| ExtensionURLInfo::ExtensionURLInfo(WebSecurityOrigin origin, const GURL& url) |
| @@ -76,13 +79,21 @@ std::string ExtensionSet::GetExtensionOrAppIDByURL( |
| const Extension* ExtensionSet::GetExtensionOrAppByURL( |
| const ExtensionURLInfo& info) const { |
| - // In the common case, the document's origin will correspond to its URL, |
| - // but in some rare cases involving sandboxing, the two will be different. |
| - // We catch those cases by checking whether the document's origin is unique. |
| - // If that's not the case, then we conclude that the document's security |
| - // context is well-described by its URL and proceed to use only the URL. |
| - if (!info.origin().isNull() && info.origin().isUnique()) |
| - return NULL; |
| + if (!info.origin().isNull()) { |
| + // In the common case, the document's origin will correspond to its URL, |
| + // but in some rare cases involving sandboxing, the two will be different. |
| + // We catch those cases by checking whether the document's origin is unique. |
| + if (info.origin().isUnique()) |
| + return NULL; |
| + |
| + // Additionally, the url will initialy be null during a window.open call |
|
Mihai Parparita -not on Chrome
2012/06/21 01:30:11
Adam, you expressed a wish to always use the origi
|
| + // with an extension URL, but the origin will be set correctly. If we have |
| + // an extension host origin, then that should be enough to determine which |
| + // extension we need. |
| + if (info.origin().protocol() == |
| + WebString::fromUTF8(chrome::kExtensionScheme)) |
| + return GetByID(info.origin().host().utf8().data()); |
| + } |
| if (info.url().SchemeIs(chrome::kExtensionScheme)) |
| return GetByID(info.url().host()); |