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