OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "extensions/common/manifest_handlers/csp_info.h" | |
6 #include "extensions/renderer/extension_injection_host.h" | |
7 | |
8 namespace extensions { | |
9 | |
10 ExtensionInjectionHost::ExtensionInjectionHost( | |
11 const scoped_refptr<const Extension>& extension) | |
12 : InjectionHost(HostID(HostID::EXTENSIONS, extension->id())), | |
13 extension_(extension) { | |
Devlin
2015/02/11 00:00:48
CHECK(extension_)
Xi Han
2015/02/11 16:00:23
Do you mean CHECK(extension_.get())? Since we alre
Devlin
2015/02/11 20:19:44
Hm. Good point.
| |
14 } | |
15 | |
16 ExtensionInjectionHost::~ExtensionInjectionHost() { | |
17 } | |
18 | |
19 const std::string& ExtensionInjectionHost::GetContentSecurityPolicy() const { | |
20 return CSPInfo::GetContentSecurityPolicy(extension_.get()); | |
21 } | |
22 | |
23 const GURL& ExtensionInjectionHost::url() const { | |
24 return extension_->url(); | |
25 } | |
26 | |
27 const std::string ExtensionInjectionHost::name() const { | |
28 return extension_->name(); | |
29 } | |
30 | |
31 PermissionsData::AccessType ExtensionInjectionHost::CanExecuteOnFrame( | |
32 const GURL& document_url, | |
33 const GURL& top_frame_url, | |
34 int tab_id, | |
35 bool is_declarative) const { | |
36 // Declarative user scripts use "page access" (from "permissions" section in | |
37 // manifest) whereas non-declarative user scripts use custom | |
38 // "content script access" logic. | |
39 if (is_declarative) { | |
40 return extension_->permissions_data()->GetPageAccess( | |
41 extension_.get(), | |
42 document_url, | |
43 top_frame_url, | |
44 tab_id, | |
45 -1, // no process id | |
46 nullptr /* ignore error */); | |
47 } else { | |
48 return extension_->permissions_data()->GetContentScriptAccess( | |
49 extension_.get(), | |
50 document_url, | |
51 top_frame_url, | |
52 tab_id, | |
53 -1, // no process id | |
54 nullptr /* ignore error */); | |
55 } | |
56 } | |
57 | |
58 } // namespace extensions | |
OLD | NEW |