| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/renderer/script_context_set.h" | 5 #include "extensions/renderer/script_context_set.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "content/public/common/url_constants.h" | 10 #include "content/public/common/url_constants.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 // security origin is unique yet. | 192 // security origin is unique yet. |
| 193 if (ScriptContext::IsSandboxedPage(url)) | 193 if (ScriptContext::IsSandboxedPage(url)) |
| 194 return Feature::WEB_PAGE_CONTEXT; | 194 return Feature::WEB_PAGE_CONTEXT; |
| 195 | 195 |
| 196 if (extension && active_extension_ids_->count(extension->id()) > 0) { | 196 if (extension && active_extension_ids_->count(extension->id()) > 0) { |
| 197 // |extension| is active in this process, but it could be either a true | 197 // |extension| is active in this process, but it could be either a true |
| 198 // extension process or within the extent of a hosted app. In the latter | 198 // extension process or within the extent of a hosted app. In the latter |
| 199 // case this would usually be considered a (blessed) web page context, | 199 // case this would usually be considered a (blessed) web page context, |
| 200 // unless the extension in question is a component extension, in which case | 200 // unless the extension in question is a component extension, in which case |
| 201 // we cheat and call it blessed. | 201 // we cheat and call it blessed. |
| 202 return (extension->is_hosted_app() && | 202 if (extension->is_hosted_app() && |
| 203 extension->location() != Manifest::COMPONENT) | 203 extension->location() != Manifest::COMPONENT) { |
| 204 ? Feature::BLESSED_WEB_PAGE_CONTEXT | 204 return Feature::BLESSED_WEB_PAGE_CONTEXT; |
| 205 : Feature::BLESSED_EXTENSION_CONTEXT; | 205 } |
| 206 |
| 207 return lock_screen_context_ ? Feature::LOCK_SCREEN_EXTENSION_CONTEXT |
| 208 : Feature::BLESSED_EXTENSION_CONTEXT; |
| 206 } | 209 } |
| 207 | 210 |
| 208 // TODO(kalman): This isUnique() check is wrong, it should be performed as | 211 // TODO(kalman): This isUnique() check is wrong, it should be performed as |
| 209 // part of ScriptContext::IsSandboxedPage(). | 212 // part of ScriptContext::IsSandboxedPage(). |
| 210 if (!origin.IsUnique() && | 213 if (!origin.IsUnique() && |
| 211 RendererExtensionRegistry::Get()->ExtensionBindingsAllowed(url)) { | 214 RendererExtensionRegistry::Get()->ExtensionBindingsAllowed(url)) { |
| 212 if (!extension) // TODO(kalman): when does this happen? | 215 if (!extension) // TODO(kalman): when does this happen? |
| 213 return Feature::UNSPECIFIED_CONTEXT; | 216 return Feature::UNSPECIFIED_CONTEXT; |
| 214 return extension->is_hosted_app() ? Feature::BLESSED_WEB_PAGE_CONTEXT | 217 return extension->is_hosted_app() ? Feature::BLESSED_WEB_PAGE_CONTEXT |
| 215 : Feature::UNBLESSED_EXTENSION_CONTEXT; | 218 : Feature::UNBLESSED_EXTENSION_CONTEXT; |
| 216 } | 219 } |
| 217 | 220 |
| 218 if (!url.is_valid()) | 221 if (!url.is_valid()) |
| 219 return Feature::UNSPECIFIED_CONTEXT; | 222 return Feature::UNSPECIFIED_CONTEXT; |
| 220 | 223 |
| 221 if (url.SchemeIs(content::kChromeUIScheme)) | 224 if (url.SchemeIs(content::kChromeUIScheme)) |
| 222 return Feature::WEBUI_CONTEXT; | 225 return Feature::WEBUI_CONTEXT; |
| 223 | 226 |
| 224 return Feature::WEB_PAGE_CONTEXT; | 227 return Feature::WEB_PAGE_CONTEXT; |
| 225 } | 228 } |
| 226 | 229 |
| 227 } // namespace extensions | 230 } // namespace extensions |
| OLD | NEW |