pepper_plugin_instance.h revision f2477e01787aa58f445919b809d89e252beef54f
1// Copyright (c) 2013 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#ifndef CONTENT_PUBLIC_RENDERER_PEPPER_PLUGIN_INSTANCE_H_
6#define CONTENT_PUBLIC_RENDERER_PEPPER_PLUGIN_INSTANCE_H_
7
8#include "base/basictypes.h"
9#include "base/process/process_handle.h"
10#include "content/common/content_export.h"
11#include "ppapi/c/pp_resource.h"
12#include "ppapi/c/pp_var.h"
13#include "ppapi/c/private/ppb_instance_private.h"
14
15class GURL;
16
17namespace base {
18class FilePath;
19}
20
21namespace gfx {
22class ImageSkia;
23class Rect;
24}
25
26namespace ppapi {
27class PpapiPermissions;
28class VarTracker;
29struct URLRequestInfoData;
30}
31
32namespace IPC {
33struct ChannelHandle;
34}
35
36namespace blink {
37class WebPluginContainer;
38}
39
40namespace v8 {
41class Isolate;
42}
43
44namespace content {
45class RenderView;
46
47class PepperPluginInstance {
48 public:
49  static CONTENT_EXPORT PepperPluginInstance* Get(PP_Instance instance_id);
50
51  virtual ~PepperPluginInstance() {}
52
53  virtual content::RenderView* GetRenderView() = 0;
54
55  virtual blink::WebPluginContainer* GetContainer() = 0;
56
57  virtual v8::Isolate* GetIsolate() const = 0;
58
59  virtual ppapi::VarTracker* GetVarTracker() = 0;
60
61  virtual const GURL& GetPluginURL() = 0;
62
63  // Returns the location of this module.
64  virtual base::FilePath GetModulePath() = 0;
65
66  // Creates a PPB_ImageData given a Skia image.
67  virtual PP_Resource CreateImage(gfx::ImageSkia* source_image,
68                                  float scale) = 0;
69
70  // Switches this instance with one that uses the out of process IPC proxy.
71  virtual PP_ExternalPluginResult SwitchToOutOfProcessProxy(
72      const base::FilePath& file_path,
73      ppapi::PpapiPermissions permissions,
74      const IPC::ChannelHandle& channel_handle,
75      base::ProcessId plugin_pid,
76      int plugin_child_id) = 0;
77
78  // Set this to true if plugin thinks it will always be on top. This allows us
79  // to use a more optimized painting path in some cases.
80  virtual void SetAlwaysOnTop(bool on_top) = 0;
81
82  // Returns true iff the plugin is a full-page plugin (i.e. not in an iframe
83  // or embedded in a page).
84  virtual bool IsFullPagePlugin() = 0;
85
86  // Switches between fullscreen and normal mode. If |delay_report| is set to
87  // false, it may report the new state through DidChangeView immediately. If
88  // true, it will delay it. When called from the plugin, delay_report should
89  // be true to avoid re-entrancy. Returns true if the switch will be carried
90  // out, because of this call or because a switch was pending already anyway.
91  // Returns false if the switch will not be carried out because fullscreen mode
92  // is disallowed by a preference.
93  virtual bool FlashSetFullscreen(bool fullscreen, bool delay_report) = 0;
94
95  virtual bool IsRectTopmost(const gfx::Rect& rect) = 0;
96
97  virtual int32_t Navigate(const ppapi::URLRequestInfoData& request,
98                           const char* target,
99                           bool from_user_action) = 0;
100
101  // Creates a pending PepperFileRefRendererHost. Returns 0 on failure.
102  virtual int MakePendingFileRefRendererHost(const base::FilePath& path) = 0;
103
104  // Sets a read-only property on the <embed> tag for this plugin instance.
105  virtual void SetEmbedProperty(PP_Var key, PP_Var value) = 0;
106};
107
108}  // namespace content
109
110#endif  // CONTENT_PUBLIC_RENDERER_PEPPER_PLUGIN_INSTANCE_H_
111