Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: extensions/renderer/extension_consumer.cc

Issue 885493007: Refactoring: de-couple Extensions from "script injection System" [render side] : 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove Host::IsEmpty() and move ExtensionConsumer to extensions/renderer. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_consumer.h"
7
8 namespace extensions {
9
10 ExtensionConsumer::ExtensionConsumer(
11 const scoped_refptr<const Extension>& extension, const HostID& host_id)
12 : Host(host_id),
13 extension_(extension) {
14 }
15
16 ExtensionConsumer::~ExtensionConsumer() {
17 }
18
19 const std::string& ExtensionConsumer::GetContentSecurityPolicy() const {
20 return CSPInfo::GetContentSecurityPolicy(extension_.get());
21 }
22
23 const GURL& ExtensionConsumer::url() const {
24 DCHECK(extension_.get());
Devlin 2015/02/09 17:40:24 Probably better to just move the DCHECK into the c
Xi Han 2015/02/09 23:28:11 Done.
25 return extension_->url();
26 }
27
28 const std::string ExtensionConsumer::name() const {
29 DCHECK(extension_.get());
30 return extension_->name();
31 }
32
33 PermissionsData::AccessType ExtensionConsumer::CanExecuteOnFrame(
34 const GURL& document_url,
35 const GURL& top_frame_url,
36 int tab_id,
37 bool is_declarative) const {
38 // Declarative user scripts use "page access" (from "permissions" section in
39 // manifest) whereas non-declarative user scripts use custom
40 // "content script access" logic.
41 if (is_declarative) {
42 return extension_->permissions_data()->GetPageAccess(
43 extension_.get(),
44 document_url,
45 top_frame_url,
46 tab_id,
47 -1, // no process id
48 NULL /* ignore error */);
Devlin 2015/02/09 17:40:24 nit: prefer nullptr.
Xi Han 2015/02/09 23:28:11 Done.
49 } else {
50 return extension_->permissions_data()->GetContentScriptAccess(
51 extension_.get(),
52 document_url,
53 top_frame_url,
54 tab_id,
55 -1, // no process id
56 NULL /* ignore error */);
57 }
58 }
59
60 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698