| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/extension_injection_host.h" | 5 #include "extensions/renderer/extension_injection_host.h" |
| 6 | 6 |
| 7 #include "content/public/renderer/render_frame.h" | 7 #include "content/public/renderer/render_frame.h" |
| 8 #include "extensions/common/constants.h" | 8 #include "extensions/common/constants.h" |
| 9 #include "extensions/common/extension_set.h" | |
| 10 #include "extensions/common/manifest_handlers/csp_info.h" | 9 #include "extensions/common/manifest_handlers/csp_info.h" |
| 10 #include "extensions/renderer/renderer_extension_registry.h" |
| 11 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 11 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 12 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 12 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 13 | 13 |
| 14 namespace extensions { | 14 namespace extensions { |
| 15 | 15 |
| 16 ExtensionInjectionHost::ExtensionInjectionHost( | 16 ExtensionInjectionHost::ExtensionInjectionHost( |
| 17 const Extension* extension) | 17 const Extension* extension) |
| 18 : InjectionHost(HostID(HostID::EXTENSIONS, extension->id())), | 18 : InjectionHost(HostID(HostID::EXTENSIONS, extension->id())), |
| 19 extension_(extension) { | 19 extension_(extension) { |
| 20 } | 20 } |
| 21 | 21 |
| 22 ExtensionInjectionHost::~ExtensionInjectionHost() { | 22 ExtensionInjectionHost::~ExtensionInjectionHost() { |
| 23 } | 23 } |
| 24 | 24 |
| 25 // static | 25 // static |
| 26 scoped_ptr<const InjectionHost> ExtensionInjectionHost::Create( | 26 scoped_ptr<const InjectionHost> ExtensionInjectionHost::Create( |
| 27 const std::string& extension_id, | 27 const std::string& extension_id) { |
| 28 const ExtensionSet* extensions) { | 28 const Extension* extension = |
| 29 const Extension* extension = extensions->GetByID(extension_id); | 29 RendererExtensionRegistry::Get()->GetByID(extension_id); |
| 30 if (!extension) | 30 if (!extension) |
| 31 return scoped_ptr<const ExtensionInjectionHost>(); | 31 return scoped_ptr<const ExtensionInjectionHost>(); |
| 32 return scoped_ptr<const ExtensionInjectionHost>( | 32 return scoped_ptr<const ExtensionInjectionHost>( |
| 33 new ExtensionInjectionHost(extension)); | 33 new ExtensionInjectionHost(extension)); |
| 34 } | 34 } |
| 35 | 35 |
| 36 std::string ExtensionInjectionHost::GetContentSecurityPolicy() const { | 36 std::string ExtensionInjectionHost::GetContentSecurityPolicy() const { |
| 37 return CSPInfo::GetContentSecurityPolicy(extension_); | 37 return CSPInfo::GetContentSecurityPolicy(extension_); |
| 38 } | 38 } |
| 39 | 39 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 // We notify the browser of any injection if the extension has no withheld | 85 // We notify the browser of any injection if the extension has no withheld |
| 86 // permissions (i.e., the permissions weren't restricted), but would have | 86 // permissions (i.e., the permissions weren't restricted), but would have |
| 87 // otherwise been affected by the scripts-require-action feature. | 87 // otherwise been affected by the scripts-require-action feature. |
| 88 return extension_->permissions_data()->withheld_permissions()->IsEmpty() && | 88 return extension_->permissions_data()->withheld_permissions()->IsEmpty() && |
| 89 PermissionsData::ScriptsMayRequireActionForExtension( | 89 PermissionsData::ScriptsMayRequireActionForExtension( |
| 90 extension_, | 90 extension_, |
| 91 extension_->permissions_data()->active_permissions().get()); | 91 extension_->permissions_data()->active_permissions().get()); |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace extensions | 94 } // namespace extensions |
| OLD | NEW |