summaryrefslogtreecommitdiffstats
path: root/extensions/renderer/extension_injection_host.h
blob: 1b77cacfb206c8781383757aaab346f03b491d56 (plain)
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
// 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.

#ifndef EXTENSIONS_RENDERER_EXTENSION_INJECTION_HOST_H_
#define EXTENSIONS_RENDERER_EXTENSION_INJECTION_HOST_H_

#include "base/memory/ref_counted.h"
#include "extensions/common/extension.h"
#include "extensions/renderer/injection_host.h"

namespace extensions {
class ExtensionSet;

class ExtensionSet;

// A wrapper class that holds an extension and implements the InjectionHost
// interface.
class ExtensionInjectionHost : public InjectionHost {
 public:
  ExtensionInjectionHost(const Extension* extension);
  ~ExtensionInjectionHost() override;

  // Create an ExtensionInjectionHost object. If the extension is gone, returns
  // a null scoped ptr.
  static scoped_ptr<const InjectionHost> Create(const std::string& extension_id,
                                                const ExtensionSet* extensions);

 private:
  // InjectionHost:
  std::string GetContentSecurityPolicy() const override;
  const GURL& url() const override;
  const std::string& name() const override;
  PermissionsData::AccessType CanExecuteOnFrame(
      const GURL& document_url,
      const GURL& top_frame_url,
      int tab_id,
      bool is_declarative) const override;
  bool ShouldNotifyBrowserOfInjection() const override;

  const Extension* extension_;

  DISALLOW_COPY_AND_ASSIGN(ExtensionInjectionHost);
};

}  // namespace extesions

#endif  // EXTENSIONS_RENDERER_EXTENSION_INJECTION_HOST_H_