| OLD | NEW |
| 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 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "content/browser/renderer_host/pepper/content_browser_pepper_host_facto
ry.h" | 15 #include "content/browser/renderer_host/pepper/content_browser_pepper_host_facto
ry.h" |
| 16 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" | 16 #include "content/browser/renderer_host/pepper/ssl_context_helper.h" |
| 17 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
| 18 #include "content/public/browser/browser_ppapi_host.h" | 18 #include "content/public/browser/browser_ppapi_host.h" |
| 19 #include "content/public/common/process_type.h" | 19 #include "content/public/common/process_type.h" |
| 20 #include "ipc/ipc_channel_proxy.h" | 20 #include "ipc/ipc_channel_proxy.h" |
| 21 #include "ppapi/host/ppapi_host.h" | 21 #include "ppapi/host/ppapi_host.h" |
| 22 | 22 |
| 23 namespace content { | 23 namespace content { |
| 24 | 24 |
| 25 struct PepperRendererInstanceData; | 25 struct PepperRendererInstanceData; |
| 26 | 26 |
| 27 class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost { | 27 class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost { |
| 28 public: | 28 public: |
| 29 // The creator is responsible for calling set_plugin_process_handle as soon | 29 // The creator is responsible for calling set_plugin_process_handle as soon |
| 30 // as it is known (we start the process asynchronously so it won't be known | 30 // as it is known (we start the process asynchronously so it won't be known |
| 31 // when this object is created). | 31 // when this object is created). |
| 32 // |external_plugin| signfies that this is a proxy created for an embedder's | 32 // |external_plugin| signfies that this is a proxy created for an embedder's |
| 33 // plugin, i.e. using BrowserPpapiHost::CreateExternalPluginProcess. | 33 // plugin, i.e. using BrowserPpapiHost::CreateExternalPluginProcess. |
| 34 BrowserPpapiHostImpl( | 34 BrowserPpapiHostImpl( |
| 35 IPC::Sender* sender, | 35 IPC::Sender* sender, |
| 36 const ppapi::PpapiPermissions& permissions, | 36 const ppapi::PpapiPermissions& permissions, |
| 37 const std::string& plugin_name, | 37 const std::string& plugin_name, |
| 38 const base::FilePath& plugin_path, | 38 const base::FilePath& plugin_path, |
| 39 const base::FilePath& profile_data_directory, | 39 const base::FilePath& profile_data_directory, |
| 40 bool external_plugin, | 40 bool external_plugin); |
| 41 // TODO (ygorshenin@): remove this once TCP sockets are | |
| 42 // converted to the new design. | |
| 43 const scoped_refptr<PepperMessageFilter>& pepper_message_filter); | |
| 44 virtual ~BrowserPpapiHostImpl(); | 41 virtual ~BrowserPpapiHostImpl(); |
| 45 | 42 |
| 46 // BrowserPpapiHost. | 43 // BrowserPpapiHost. |
| 47 virtual ppapi::host::PpapiHost* GetPpapiHost() OVERRIDE; | 44 virtual ppapi::host::PpapiHost* GetPpapiHost() OVERRIDE; |
| 48 virtual base::ProcessHandle GetPluginProcessHandle() const OVERRIDE; | 45 virtual base::ProcessHandle GetPluginProcessHandle() const OVERRIDE; |
| 49 virtual bool IsValidInstance(PP_Instance instance) const OVERRIDE; | 46 virtual bool IsValidInstance(PP_Instance instance) const OVERRIDE; |
| 50 virtual bool GetRenderViewIDsForInstance(PP_Instance instance, | 47 virtual bool GetRenderViewIDsForInstance(PP_Instance instance, |
| 51 int* render_process_id, | 48 int* render_process_id, |
| 52 int* render_view_id) const OVERRIDE; | 49 int* render_view_id) const OVERRIDE; |
| 53 virtual const std::string& GetPluginName() OVERRIDE; | 50 virtual const std::string& GetPluginName() OVERRIDE; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 66 // or destroyed. They allow us to maintain a mapping of PP_Instance to data | 63 // or destroyed. They allow us to maintain a mapping of PP_Instance to data |
| 67 // associated with the instance including view IDs in the browser process. | 64 // associated with the instance including view IDs in the browser process. |
| 68 void AddInstance(PP_Instance instance, | 65 void AddInstance(PP_Instance instance, |
| 69 const PepperRendererInstanceData& instance_data); | 66 const PepperRendererInstanceData& instance_data); |
| 70 void DeleteInstance(PP_Instance instance); | 67 void DeleteInstance(PP_Instance instance); |
| 71 | 68 |
| 72 scoped_refptr<IPC::ChannelProxy::MessageFilter> message_filter() { | 69 scoped_refptr<IPC::ChannelProxy::MessageFilter> message_filter() { |
| 73 return message_filter_; | 70 return message_filter_; |
| 74 } | 71 } |
| 75 | 72 |
| 73 const scoped_refptr<SSLContextHelper>& ssl_context_helper() const { |
| 74 return ssl_context_helper_; |
| 75 } |
| 76 |
| 76 private: | 77 private: |
| 77 friend class BrowserPpapiHostTest; | 78 friend class BrowserPpapiHostTest; |
| 78 | 79 |
| 79 // Implementing MessageFilter on BrowserPpapiHostImpl makes it ref-counted, | 80 // Implementing MessageFilter on BrowserPpapiHostImpl makes it ref-counted, |
| 80 // preventing us from returning these to embedders without holding a | 81 // preventing us from returning these to embedders without holding a |
| 81 // reference. To avoid that, define a message filter object. | 82 // reference. To avoid that, define a message filter object. |
| 82 class HostMessageFilter : public IPC::ChannelProxy::MessageFilter { | 83 class HostMessageFilter : public IPC::ChannelProxy::MessageFilter { |
| 83 public: | 84 public: |
| 84 explicit HostMessageFilter(ppapi::host::PpapiHost* ppapi_host) | 85 explicit HostMessageFilter(ppapi::host::PpapiHost* ppapi_host) |
| 85 : ppapi_host_(ppapi_host) {} | 86 : ppapi_host_(ppapi_host) {} |
| (...skipping 11 matching lines...) Expand all Loading... |
| 97 scoped_ptr<ppapi::host::PpapiHost> ppapi_host_; | 98 scoped_ptr<ppapi::host::PpapiHost> ppapi_host_; |
| 98 base::ProcessHandle plugin_process_handle_; | 99 base::ProcessHandle plugin_process_handle_; |
| 99 std::string plugin_name_; | 100 std::string plugin_name_; |
| 100 base::FilePath plugin_path_; | 101 base::FilePath plugin_path_; |
| 101 base::FilePath profile_data_directory_; | 102 base::FilePath profile_data_directory_; |
| 102 | 103 |
| 103 // If true, this is an external plugin, i.e. created by the embedder using | 104 // If true, this is an external plugin, i.e. created by the embedder using |
| 104 // BrowserPpapiHost::CreateExternalPluginProcess. | 105 // BrowserPpapiHost::CreateExternalPluginProcess. |
| 105 bool external_plugin_; | 106 bool external_plugin_; |
| 106 | 107 |
| 108 scoped_refptr<SSLContextHelper> ssl_context_helper_; |
| 109 |
| 107 // Tracks all PP_Instances in this plugin and associated renderer-related | 110 // Tracks all PP_Instances in this plugin and associated renderer-related |
| 108 // data. | 111 // data. |
| 109 typedef std::map<PP_Instance, PepperRendererInstanceData> InstanceMap; | 112 typedef std::map<PP_Instance, PepperRendererInstanceData> InstanceMap; |
| 110 InstanceMap instance_map_; | 113 InstanceMap instance_map_; |
| 111 | 114 |
| 112 scoped_refptr<HostMessageFilter> message_filter_; | 115 scoped_refptr<HostMessageFilter> message_filter_; |
| 113 | 116 |
| 114 DISALLOW_COPY_AND_ASSIGN(BrowserPpapiHostImpl); | 117 DISALLOW_COPY_AND_ASSIGN(BrowserPpapiHostImpl); |
| 115 }; | 118 }; |
| 116 | 119 |
| 117 } // namespace content | 120 } // namespace content |
| 118 | 121 |
| 119 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_IMPL_H_ | 122 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_IMPL_H_ |
| OLD | NEW |