forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension_injection_host.cc
58 lines (49 loc) · 1.7 KB
/
extension_injection_host.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "extensions/common/manifest_handlers/csp_info.h"
#include "extensions/renderer/extension_injection_host.h"
namespace extensions {
ExtensionInjectionHost::ExtensionInjectionHost(
const scoped_refptr<const Extension>& extension)
: InjectionHost(HostID(HostID::EXTENSIONS, extension->id())),
extension_(extension) {
}
ExtensionInjectionHost::~ExtensionInjectionHost() {
}
const std::string& ExtensionInjectionHost::GetContentSecurityPolicy() const {
return CSPInfo::GetContentSecurityPolicy(extension_.get());
}
const GURL& ExtensionInjectionHost::url() const {
return extension_->url();
}
const std::string& ExtensionInjectionHost::name() const {
return extension_->name();
}
PermissionsData::AccessType ExtensionInjectionHost::CanExecuteOnFrame(
const GURL& document_url,
const GURL& top_frame_url,
int tab_id,
bool is_declarative) const {
// Declarative user scripts use "page access" (from "permissions" section in
// manifest) whereas non-declarative user scripts use custom
// "content script access" logic.
if (is_declarative) {
return extension_->permissions_data()->GetPageAccess(
extension_.get(),
document_url,
top_frame_url,
tab_id,
-1, // no process id
nullptr /* ignore error */);
} else {
return extension_->permissions_data()->GetContentScriptAccess(
extension_.get(),
document_url,
top_frame_url,
tab_id,
-1, // no process id
nullptr /* ignore error */);
}
}
} // namespace extensions