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 { | |
not at google - send to devlin
2013/08/19 23:32:24
the name of this method and the thing it returns i
sergeygs
2013/08/29 08:24:42
Done. This whole function has disappeared, replace
| |
131 for (ExtensionMap::const_iterator extIt = extensions_.begin(); | |
132 extIt != extensions_.end(); ++extIt) { | |
not at google - send to devlin
2013/08/19 23:32:24
s/extIt/it/
sergeygs
2013/08/29 08:24:42
Done.
| |
133 if (extIt->second->is_app()) { | |
not at google - send to devlin
2013/08/19 23:32:24
I don't really see the point in checking is_app he
sergeygs
2013/08/29 08:24:42
Done.
| |
134 const std::vector<extensions::UrlHandlerInfo>* handlers = | |
135 extensions::UrlHandlers::GetUrlHandlers(extIt->second); | |
136 if (handlers) { | |
137 for (std::vector<extensions::UrlHandlerInfo>::const_iterator handlerIt = | |
not at google - send to devlin
2013/08/19 23:32:24
add a method to UrlHandlers that does this?
sergeygs
2013/08/29 08:24:42
Done.
| |
138 handlers->begin(); handlerIt != handlers->end(); handlerIt++) { | |
139 if (handlerIt->patterns.MatchesURL(url)) | |
140 return &(*handlerIt); | |
141 } | |
142 } | |
143 } | |
144 } | |
145 | |
146 return NULL; | |
147 } | |
148 | |
127 bool ExtensionSet::InSameExtent(const GURL& old_url, | 149 bool ExtensionSet::InSameExtent(const GURL& old_url, |
128 const GURL& new_url) const { | 150 const GURL& new_url) const { |
129 return GetExtensionOrAppByURL(ExtensionURLInfo(old_url)) == | 151 return GetExtensionOrAppByURL(ExtensionURLInfo(old_url)) == |
130 GetExtensionOrAppByURL(ExtensionURLInfo(new_url)); | 152 GetExtensionOrAppByURL(ExtensionURLInfo(new_url)); |
131 } | 153 } |
132 | 154 |
133 const Extension* ExtensionSet::GetByID(const std::string& id) const { | 155 const Extension* ExtensionSet::GetByID(const std::string& id) const { |
134 ExtensionMap::const_iterator i = extensions_.find(id); | 156 ExtensionMap::const_iterator i = extensions_.find(id); |
135 if (i != extensions_.end()) | 157 if (i != extensions_.end()) |
136 return i->second.get(); | 158 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 { | 190 bool ExtensionSet::IsSandboxedPage(const ExtensionURLInfo& info) const { |
169 if (info.url().SchemeIs(extensions::kExtensionScheme)) { | 191 if (info.url().SchemeIs(extensions::kExtensionScheme)) { |
170 const Extension* extension = GetByID(info.url().host()); | 192 const Extension* extension = GetByID(info.url().host()); |
171 if (extension) { | 193 if (extension) { |
172 return extensions::SandboxedPageInfo::IsSandboxedPage(extension, | 194 return extensions::SandboxedPageInfo::IsSandboxedPage(extension, |
173 info.url().path()); | 195 info.url().path()); |
174 } | 196 } |
175 } | 197 } |
176 return false; | 198 return false; |
177 } | 199 } |
OLD | NEW |