Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: content/browser/renderer_host/pepper/browser_ppapi_host_impl.h

Issue 11316316: Implement an IsAllowed function in the pepper PPB_Broker_Trusted API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_IMPL_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_IMPL_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_IMPL_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "content/browser/renderer_host/pepper/content_browser_pepper_host_facto ry.h" 12 #include "content/browser/renderer_host/pepper/content_browser_pepper_host_facto ry.h"
13 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
14 #include "content/public/browser/browser_ppapi_host.h" 14 #include "content/public/browser/browser_ppapi_host.h"
15 #include "ipc/ipc_channel_proxy.h" 15 #include "ipc/ipc_channel_proxy.h"
16 #include "ppapi/host/ppapi_host.h" 16 #include "ppapi/host/ppapi_host.h"
17 17
18 namespace content { 18 namespace content {
19 19
20 struct PepperRendererInstanceData;
21
20 class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost { 22 class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost {
21 public: 23 public:
22 // The creator is responsible for calling set_plugin_process_handle as soon 24 // The creator is responsible for calling set_plugin_process_handle as soon
23 // as it is known (we start the process asynchronously so it won't be known 25 // as it is known (we start the process asynchronously so it won't be known
24 // when this object is created). 26 // when this object is created).
25 BrowserPpapiHostImpl(IPC::Sender* sender, 27 BrowserPpapiHostImpl(IPC::Sender* sender,
26 const ppapi::PpapiPermissions& permissions); 28 const ppapi::PpapiPermissions& permissions);
27 virtual ~BrowserPpapiHostImpl(); 29 virtual ~BrowserPpapiHostImpl();
28 30
29 // BrowserPpapiHost. 31 // BrowserPpapiHost.
30 virtual ppapi::host::PpapiHost* GetPpapiHost() OVERRIDE; 32 virtual ppapi::host::PpapiHost* GetPpapiHost() OVERRIDE;
31 virtual base::ProcessHandle GetPluginProcessHandle() const OVERRIDE; 33 virtual base::ProcessHandle GetPluginProcessHandle() const OVERRIDE;
32 virtual bool IsValidInstance(PP_Instance instance) const OVERRIDE; 34 virtual bool IsValidInstance(PP_Instance instance) const OVERRIDE;
33 virtual bool GetRenderViewIDsForInstance(PP_Instance instance, 35 virtual bool GetRenderViewIDsForInstance(PP_Instance instance,
34 int* render_process_id, 36 int* render_process_id,
35 int* render_view_id) const OVERRIDE; 37 int* render_view_id) const OVERRIDE;
38 virtual GURL GetDocumentURLForInstance(PP_Instance instance) OVERRIDE;
39 virtual GURL GetPluginURLForInstance(PP_Instance instance) OVERRIDE;
36 40
37 void set_plugin_process_handle(base::ProcessHandle handle) { 41 void set_plugin_process_handle(base::ProcessHandle handle) {
38 plugin_process_handle_ = handle; 42 plugin_process_handle_ = handle;
39 } 43 }
40 44
41 // These two functions are notifications that an instance has been created 45 // These two functions are notifications that an instance has been created
42 // or destroyed. They allow us to maintain a mapping of PP_Instance to view 46 // or destroyed. They allow us to maintain a mapping of PP_Instance to data
43 // IDs in the browser process. 47 // associated with the instance including view IDs in the browser process.
44 void AddInstanceForView(PP_Instance instance, 48 void AddInstance(PP_Instance instance,
45 int render_process_id, 49 const PepperRendererInstanceData& instance_data);
46 int render_view_id); 50 void DeleteInstance(PP_Instance instance);
47 void DeleteInstanceForView(PP_Instance instance);
48 51
49 scoped_refptr<IPC::ChannelProxy::MessageFilter> message_filter() { 52 scoped_refptr<IPC::ChannelProxy::MessageFilter> message_filter() {
50 return message_filter_; 53 return message_filter_;
51 } 54 }
52 55
53 private: 56 private:
54 friend class BrowserPpapiHostTest; 57 friend class BrowserPpapiHostTest;
55 58
56 struct RenderViewIDs {
57 int process_id;
58 int view_id;
59 };
60 typedef std::map<PP_Instance, RenderViewIDs> InstanceToViewMap;
61
62 // Implementing MessageFilter on BrowserPpapiHostImpl makes it ref-counted, 59 // Implementing MessageFilter on BrowserPpapiHostImpl makes it ref-counted,
63 // preventing us from returning these to embedders without holding a 60 // preventing us from returning these to embedders without holding a
64 // reference. To avoid that, define a message filter object. 61 // reference. To avoid that, define a message filter object.
65 class HostMessageFilter : public IPC::ChannelProxy::MessageFilter { 62 class HostMessageFilter : public IPC::ChannelProxy::MessageFilter {
66 public: 63 public:
67 explicit HostMessageFilter(ppapi::host::PpapiHost* ppapi_host) 64 explicit HostMessageFilter(ppapi::host::PpapiHost* ppapi_host)
68 : ppapi_host_(ppapi_host) {} 65 : ppapi_host_(ppapi_host) {}
69 // IPC::ChannelProxy::MessageFilter. 66 // IPC::ChannelProxy::MessageFilter.
70 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 67 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
71 68
72 void OnHostDestroyed(); 69 void OnHostDestroyed();
73 70
74 private: 71 private:
75 virtual ~HostMessageFilter() {} 72 virtual ~HostMessageFilter() {}
76 73
77 ppapi::host::PpapiHost* ppapi_host_; 74 ppapi::host::PpapiHost* ppapi_host_;
78 }; 75 };
79 76
80 ppapi::host::PpapiHost ppapi_host_; 77 ppapi::host::PpapiHost ppapi_host_;
81 base::ProcessHandle plugin_process_handle_; 78 base::ProcessHandle plugin_process_handle_;
82 79
83 // Tracks all PP_Instances in this plugin and maps them to 80 // Tracks all PP_Instances in this plugin and associated renderer-related
84 // RenderProcess/RenderView IDs. 81 // data.
85 InstanceToViewMap instance_to_view_; 82 typedef std::map<PP_Instance, PepperRendererInstanceData> InstanceMap;
83 InstanceMap instance_map_;
86 84
87 scoped_refptr<HostMessageFilter> message_filter_; 85 scoped_refptr<HostMessageFilter> message_filter_;
88 86
89 DISALLOW_COPY_AND_ASSIGN(BrowserPpapiHostImpl); 87 DISALLOW_COPY_AND_ASSIGN(BrowserPpapiHostImpl);
90 }; 88 };
91 89
92 } // namespace content 90 } // namespace content
93 91
94 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_IMPL_H_ 92 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698