1 // Copyright (c) 2012 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_BROWSER_BROWSER_PPAPI_HOST_H_ 6 #define CONTENT_PUBLIC_BROWSER_BROWSER_PPAPI_HOST_H_ 7 8 #include "base/callback_forward.h" 9 #include "base/process/process.h" 10 #include "content/common/content_export.h" 11 #include "content/public/browser/render_view_host.h" 12 #include "ppapi/c/pp_instance.h" 13 #include "url/gurl.h" 14 15 namespace IPC { 16 class ChannelProxy; 17 struct ChannelHandle; 18 class Sender; 19 } 20 21 namespace net { 22 class HostResolver; 23 } 24 25 namespace ppapi { 26 class PpapiPermissions; 27 namespace host { 28 class PpapiHost; 29 } 30 } 31 32 namespace content { 33 34 // Interface that allows components in the embedder app to talk to the 35 // PpapiHost in the browser process. 36 // 37 // There will be one of these objects in the browser per plugin process. It 38 // lives entirely on the I/O thread. 39 class CONTENT_EXPORT BrowserPpapiHost { 40 public: 41 // Creates a browser host and sets up an out-of-process proxy for an external 42 // pepper plugin process. 43 static BrowserPpapiHost* CreateExternalPluginProcess( 44 IPC::Sender* sender, 45 ppapi::PpapiPermissions permissions, 46 base::ProcessHandle plugin_child_process, 47 IPC::ChannelProxy* channel, 48 net::HostResolver* host_resolver, 49 int render_process_id, 50 int render_view_id, 51 const base::FilePath& profile_directory); 52 53 virtual ~BrowserPpapiHost() {} 54 55 // Returns the PpapiHost object. 56 virtual ppapi::host::PpapiHost* GetPpapiHost() = 0; 57 58 // Returns the handle to the plugin process. 59 virtual base::ProcessHandle GetPluginProcessHandle() const = 0; 60 61 // Returns true if the given PP_Instance is valid. 62 virtual bool IsValidInstance(PP_Instance instance) const = 0; 63 64 // Retrieves the process/view Ids associated with the RenderView containing 65 // the given instance and returns true on success. If the instance is 66 // invalid, the ids will be 0 and false will be returned. 67 // 68 // When a resource is created, the PP_Instance should already have been 69 // validated, and the resource hosts will be deleted when the resource is 70 // destroyed. So it should not generally be necessary to check for errors 71 // from this function except as a last-minute sanity check if you convert the 72 // IDs to a RenderView/ProcessHost on the UI thread. 73 virtual bool GetRenderViewIDsForInstance(PP_Instance instance, 74 int* render_process_id, 75 int* render_view_id) const = 0; 76 77 // Returns the name of the plugin. 78 virtual const std::string& GetPluginName() = 0; 79 80 // Returns the path of the plugin. 81 virtual const base::FilePath& GetPluginPath() = 0; 82 83 // Returns the user's profile data directory. 84 virtual const base::FilePath& GetProfileDataDirectory() = 0; 85 86 // Get the Document/Plugin URLs for the given PP_Instance. 87 virtual GURL GetDocumentURLForInstance(PP_Instance instance) = 0; 88 virtual GURL GetPluginURLForInstance(PP_Instance instance) = 0; 89 }; 90 91 } // namespace content 92 93 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_PPAPI_HOST_H_ 94