Content settings: remove some plugin-related code/resources when... there are no...
[chromium-blink-merge.git] / content / public / browser / browser_ppapi_host.h
blob777b7b07ae51d2a2a64399c9156988b06b356148
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.
5 #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_PPAPI_HOST_H_
6 #define CONTENT_PUBLIC_BROWSER_BROWSER_PPAPI_HOST_H_
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"
15 namespace IPC {
16 class ChannelProxy;
17 struct ChannelHandle;
18 class Sender;
21 namespace ppapi {
22 class PpapiPermissions;
23 namespace host {
24 class PpapiHost;
28 namespace content {
30 // Interface that allows components in the embedder app to talk to the
31 // PpapiHost in the browser process.
33 // There will be one of these objects in the browser per plugin process. It
34 // lives entirely on the I/O thread.
35 class CONTENT_EXPORT BrowserPpapiHost {
36 public:
37 struct OnKeepaliveInstanceStruct {
38 int render_process_id;
39 int render_frame_id;
40 GURL document_url;
42 typedef std::vector<OnKeepaliveInstanceStruct> OnKeepaliveInstanceData;
43 typedef base::Callback<
44 void (const OnKeepaliveInstanceData& instance_data,
45 const base::FilePath& profile_data_directory)>
46 OnKeepaliveCallback;
48 // Creates a browser host and sets up an out-of-process proxy for an external
49 // pepper plugin process.
50 static BrowserPpapiHost* CreateExternalPluginProcess(
51 IPC::Sender* sender,
52 ppapi::PpapiPermissions permissions,
53 base::ProcessHandle plugin_child_process,
54 IPC::ChannelProxy* channel,
55 int render_process_id,
56 int render_view_id,
57 const base::FilePath& profile_directory);
59 virtual ~BrowserPpapiHost() {}
61 // Returns the PpapiHost object.
62 virtual ppapi::host::PpapiHost* GetPpapiHost() = 0;
64 // Returns a reference to the plugin process.
65 virtual const base::Process& GetPluginProcess() const = 0;
67 // Returns true if the given PP_Instance is valid.
68 virtual bool IsValidInstance(PP_Instance instance) const = 0;
70 // Retrieves the process/frame Ids associated with the RenderFrame containing
71 // the given instance and returns true on success. If the instance is
72 // invalid, the ids will be 0 and false will be returned.
74 // When a resource is created, the PP_Instance should already have been
75 // validated, and the resource hosts will be deleted when the resource is
76 // destroyed. So it should not generally be necessary to check for errors
77 // from this function except as a last-minute sanity check if you convert the
78 // IDs to a RenderFrame/ProcessHost on the UI thread.
79 virtual bool GetRenderFrameIDsForInstance(PP_Instance instance,
80 int* render_process_id,
81 int* render_frame_id) const = 0;
83 // Returns the name of the plugin.
84 virtual const std::string& GetPluginName() = 0;
86 // Returns the path of the plugin.
87 virtual const base::FilePath& GetPluginPath() = 0;
89 // Returns the user's profile data directory.
90 virtual const base::FilePath& GetProfileDataDirectory() = 0;
92 // Get the Document/Plugin URLs for the given PP_Instance.
93 virtual GURL GetDocumentURLForInstance(PP_Instance instance) = 0;
94 virtual GURL GetPluginURLForInstance(PP_Instance instance) = 0;
96 // Sets a callback the BrowserPpapiHost will run when the plugin messages
97 // that it is active.
98 virtual void SetOnKeepaliveCallback(const OnKeepaliveCallback& callback) = 0;
101 } // namespace content
103 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_PPAPI_HOST_H_