Chromium Code Reviews| 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/api/url_handlers/url_handlers_parser.h" | |
| 8 #include "chrome/common/extensions/extension.h" | 9 #include "chrome/common/extensions/extension.h" |
| 10 #include "chrome/common/extensions/extension_manifest_constants.h" | |
| 9 #include "chrome/common/extensions/manifest_handlers/sandboxed_page_info.h" | 11 #include "chrome/common/extensions/manifest_handlers/sandboxed_page_info.h" |
| 10 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
| 11 #include "extensions/common/constants.h" | 13 #include "extensions/common/constants.h" |
| 12 | 14 |
| 13 using WebKit::WebSecurityOrigin; | 15 using WebKit::WebSecurityOrigin; |
| 14 using extensions::Extension; | 16 using extensions::Extension; |
| 15 | 17 |
| 16 ExtensionURLInfo::ExtensionURLInfo(WebSecurityOrigin origin, const GURL& url) | 18 ExtensionURLInfo::ExtensionURLInfo(WebSecurityOrigin origin, const GURL& url) |
| 17 : origin_(origin), | 19 : origin_(origin), |
| 18 url_(url) { | 20 url_(url) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 const extensions::URLPatternSet& extent) const { | 119 const extensions::URLPatternSet& extent) const { |
| 118 for (ExtensionMap::const_iterator iter = extensions_.begin(); | 120 for (ExtensionMap::const_iterator iter = extensions_.begin(); |
| 119 iter != extensions_.end(); ++iter) { | 121 iter != extensions_.end(); ++iter) { |
| 120 if (iter->second->web_extent().OverlapsWith(extent)) | 122 if (iter->second->web_extent().OverlapsWith(extent)) |
| 121 return iter->second.get(); | 123 return iter->second.get(); |
| 122 } | 124 } |
| 123 | 125 |
| 124 return NULL; | 126 return NULL; |
| 125 } | 127 } |
| 126 | 128 |
| 129 const extensions::UrlHandlerInfo* | |
| 130 ExtensionSet::GetHandlingAppForURL(const GURL& url) const { | |
| 131 for (const auto& ext: extensions_) { | |
|
asargent_no_longer_on_chrome
2013/08/14 18:05:12
FYI, we can't use C++11 features, because some pla
sergeygs
2013/08/18 11:40:24
Makes sense. I wasn't sure myself, and consulted t
| |
| 132 if (ext.second->is_app()) { | |
| 133 const std::vector<extensions::UrlHandlerInfo>* handlers = | |
| 134 extensions::UrlHandlers::GetUrlHandlers(ext.second); | |
| 135 if (handlers) { | |
| 136 for (const extensions::UrlHandlerInfo& handler: *handlers) { | |
| 137 if (handler.patterns.MatchesURL(url)) | |
| 138 return &handler; | |
| 139 } | |
| 140 } | |
| 141 } | |
| 142 } | |
| 143 | |
| 144 return NULL; | |
| 145 } | |
| 146 | |
| 127 bool ExtensionSet::InSameExtent(const GURL& old_url, | 147 bool ExtensionSet::InSameExtent(const GURL& old_url, |
| 128 const GURL& new_url) const { | 148 const GURL& new_url) const { |
| 129 return GetExtensionOrAppByURL(ExtensionURLInfo(old_url)) == | 149 return GetExtensionOrAppByURL(ExtensionURLInfo(old_url)) == |
| 130 GetExtensionOrAppByURL(ExtensionURLInfo(new_url)); | 150 GetExtensionOrAppByURL(ExtensionURLInfo(new_url)); |
| 131 } | 151 } |
| 132 | 152 |
| 133 const Extension* ExtensionSet::GetByID(const std::string& id) const { | 153 const Extension* ExtensionSet::GetByID(const std::string& id) const { |
| 134 ExtensionMap::const_iterator i = extensions_.find(id); | 154 ExtensionMap::const_iterator i = extensions_.find(id); |
| 135 if (i != extensions_.end()) | 155 if (i != extensions_.end()) |
| 136 return i->second.get(); | 156 return i->second.get(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 bool ExtensionSet::IsSandboxedPage(const ExtensionURLInfo& info) const { | 188 bool ExtensionSet::IsSandboxedPage(const ExtensionURLInfo& info) const { |
| 169 if (info.url().SchemeIs(extensions::kExtensionScheme)) { | 189 if (info.url().SchemeIs(extensions::kExtensionScheme)) { |
| 170 const Extension* extension = GetByID(info.url().host()); | 190 const Extension* extension = GetByID(info.url().host()); |
| 171 if (extension) { | 191 if (extension) { |
| 172 return extensions::SandboxedPageInfo::IsSandboxedPage(extension, | 192 return extensions::SandboxedPageInfo::IsSandboxedPage(extension, |
| 173 info.url().path()); | 193 info.url().path()); |
| 174 } | 194 } |
| 175 } | 195 } |
| 176 return false; | 196 return false; |
| 177 } | 197 } |
| OLD | NEW |