Chromium Code Reviews| Index: extensions/renderer/extension_consumer.cc |
| diff --git a/extensions/renderer/extension_consumer.cc b/extensions/renderer/extension_consumer.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5b217de51f9de19618b6a611f115c4d9a05f7b9e |
| --- /dev/null |
| +++ b/extensions/renderer/extension_consumer.cc |
| @@ -0,0 +1,60 @@ |
| +// 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_consumer.h" |
| + |
| +namespace extensions { |
| + |
| +ExtensionConsumer::ExtensionConsumer( |
| + const scoped_refptr<const Extension>& extension, const HostID& host_id) |
| + : Host(host_id), |
| + extension_(extension) { |
| +} |
| + |
| +ExtensionConsumer::~ExtensionConsumer() { |
| +} |
| + |
| +const std::string& ExtensionConsumer::GetContentSecurityPolicy() const { |
| + return CSPInfo::GetContentSecurityPolicy(extension_.get()); |
| +} |
| + |
| +const GURL& ExtensionConsumer::url() const { |
| + 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.
|
| + return extension_->url(); |
| +} |
| + |
| +const std::string ExtensionConsumer::name() const { |
| + DCHECK(extension_.get()); |
| + return extension_->name(); |
| +} |
| + |
| +PermissionsData::AccessType ExtensionConsumer::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 |
| + NULL /* ignore error */); |
|
Devlin
2015/02/09 17:40:24
nit: prefer nullptr.
Xi Han
2015/02/09 23:28:11
Done.
|
| + } else { |
| + return extension_->permissions_data()->GetContentScriptAccess( |
| + extension_.get(), |
| + document_url, |
| + top_frame_url, |
| + tab_id, |
| + -1, // no process id |
| + NULL /* ignore error */); |
| + } |
| +} |
| + |
| +} // namespace extensions |