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/extensions/manifest_handlers/sandboxed_page_info.h" | 9 #include "chrome/common/extensions/manifest_handlers/sandboxed_page_info.h" |
10 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 70 |
71 void ExtensionSet::Clear() { | 71 void ExtensionSet::Clear() { |
72 extensions_.clear(); | 72 extensions_.clear(); |
73 } | 73 } |
74 | 74 |
75 std::string ExtensionSet::GetExtensionOrAppIDByURL( | 75 std::string ExtensionSet::GetExtensionOrAppIDByURL( |
76 const ExtensionURLInfo& info) const { | 76 const ExtensionURLInfo& info) const { |
77 DCHECK(!info.origin().isNull()); | 77 DCHECK(!info.origin().isNull()); |
78 | 78 |
79 if (info.url().SchemeIs(extensions::kExtensionScheme)) | 79 if (info.url().SchemeIs(extensions::kExtensionScheme)) |
80 return info.origin().isUnique() ? "" : info.url().host(); | 80 return info.origin().isUnique() ? std::string() : info.url().host(); |
81 | 81 |
82 const Extension* extension = GetExtensionOrAppByURL(info); | 82 const Extension* extension = GetExtensionOrAppByURL(info); |
83 if (!extension) | 83 if (!extension) |
84 return ""; | 84 return std::string(); |
85 | 85 |
86 return extension->id(); | 86 return extension->id(); |
87 } | 87 } |
88 | 88 |
89 const Extension* ExtensionSet::GetExtensionOrAppByURL( | 89 const Extension* ExtensionSet::GetExtensionOrAppByURL( |
90 const ExtensionURLInfo& info) const { | 90 const ExtensionURLInfo& info) const { |
91 // In the common case, the document's origin will correspond to its URL, | 91 // In the common case, the document's origin will correspond to its URL, |
92 // but in some rare cases involving sandboxing, the two will be different. | 92 // but in some rare cases involving sandboxing, the two will be different. |
93 // We catch those cases by checking whether the document's origin is unique. | 93 // We catch those cases by checking whether the document's origin is unique. |
94 // If that's not the case, then we conclude that the document's security | 94 // If that's not the case, then we conclude that the document's security |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 bool ExtensionSet::IsSandboxedPage(const ExtensionURLInfo& info) const { | 168 bool ExtensionSet::IsSandboxedPage(const ExtensionURLInfo& info) const { |
169 if (info.url().SchemeIs(extensions::kExtensionScheme)) { | 169 if (info.url().SchemeIs(extensions::kExtensionScheme)) { |
170 const Extension* extension = GetByID(info.url().host()); | 170 const Extension* extension = GetByID(info.url().host()); |
171 if (extension) { | 171 if (extension) { |
172 return extensions::SandboxedPageInfo::IsSandboxedPage(extension, | 172 return extensions::SandboxedPageInfo::IsSandboxedPage(extension, |
173 info.url().path()); | 173 info.url().path()); |
174 } | 174 } |
175 } | 175 } |
176 return false; | 176 return false; |
177 } | 177 } |
OLD | NEW |