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 #include "chrome/renderer/chrome_ppapi_interfaces.h" | 5 #include "chrome/renderer/chrome_ppapi_interfaces.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/rand_util_c.h" | 10 #include "base/rand_util_c.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/common/render_messages.h" | 12 #include "chrome/common/render_messages.h" |
13 #include "chrome/renderer/chrome_ppb_pdf_impl.h" | 13 #include "chrome/renderer/chrome_ppb_pdf_impl.h" |
14 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
15 #include "content/public/renderer/render_thread.h" | 15 #include "content/public/renderer/render_thread.h" |
16 #include "ipc/ipc_sync_message_filter.h" | 16 #include "ipc/ipc_sync_message_filter.h" |
17 #include "ppapi/c/private/ppb_nacl_private.h" | 17 #include "ppapi/c/private/ppb_nacl_private.h" |
18 #include "ppapi/c/private/ppb_pdf.h" | 18 #include "ppapi/c/private/ppb_pdf.h" |
19 #include "webkit/plugins/ppapi/ppapi_interface_factory.h" | 19 #include "webkit/plugins/ppapi/ppapi_interface_factory.h" |
20 | 20 |
21 #if !defined(DISABLE_NACL) | 21 #if !defined(DISABLE_NACL) |
22 #include "native_client/src/shared/imc/nacl_imc.h" | 22 #include "native_client/src/shared/imc/nacl_imc.h" |
23 #include "ppapi/native_client/src/trusted/plugin/nacl_entry_points.h" | 23 #include "ppapi/native_client/src/trusted/plugin/nacl_entry_points.h" |
24 #endif | 24 #endif |
25 | 25 |
| 26 #if defined(OS_WIN) |
| 27 #include "content/public/common/sandbox_init.h" |
| 28 #endif |
| 29 |
26 using content::RenderThread; | 30 using content::RenderThread; |
27 | 31 |
28 namespace chrome { | 32 namespace chrome { |
29 | 33 |
30 #if !defined(DISABLE_NACL) | 34 #if !defined(DISABLE_NACL) |
31 namespace { | 35 namespace { |
32 base::LazyInstance<scoped_refptr<IPC::SyncMessageFilter> > | 36 base::LazyInstance<scoped_refptr<IPC::SyncMessageFilter> > |
33 g_background_thread_sender = LAZY_INSTANCE_INITIALIZER; | 37 g_background_thread_sender = LAZY_INSTANCE_INITIALIZER; |
34 } // namespace | 38 } // namespace |
35 | 39 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 75 |
72 bool Are3DInterfacesDisabled() { | 76 bool Are3DInterfacesDisabled() { |
73 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisable3DAPIs); | 77 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisable3DAPIs); |
74 } | 78 } |
75 | 79 |
76 void EnableBackgroundSelLdrLaunch() { | 80 void EnableBackgroundSelLdrLaunch() { |
77 g_background_thread_sender.Get() = | 81 g_background_thread_sender.Get() = |
78 RenderThread::Get()->GetSyncMessageFilter(); | 82 RenderThread::Get()->GetSyncMessageFilter(); |
79 } | 83 } |
80 | 84 |
| 85 int BrokerDuplicateHandle(void* source_handle, |
| 86 unsigned int process_id, |
| 87 void** target_handle, |
| 88 unsigned int desired_access, |
| 89 unsigned int options) { |
| 90 #if defined(OS_WIN) |
| 91 return content::BrokerDuplicateHandle(source_handle, process_id, |
| 92 target_handle, desired_access, |
| 93 options); |
| 94 #else |
| 95 return 0; |
| 96 #endif |
| 97 } |
| 98 |
81 const PPB_NaCl_Private ppb_nacl = { | 99 const PPB_NaCl_Private ppb_nacl = { |
82 &LaunchSelLdr, | 100 &LaunchSelLdr, |
83 &UrandomFD, | 101 &UrandomFD, |
84 &Are3DInterfacesDisabled, | 102 &Are3DInterfacesDisabled, |
85 &EnableBackgroundSelLdrLaunch, | 103 &EnableBackgroundSelLdrLaunch, |
| 104 &BrokerDuplicateHandle, |
86 }; | 105 }; |
87 | 106 |
88 class PPB_NaCl_Impl { | 107 class PPB_NaCl_Impl { |
89 public: | 108 public: |
90 // Returns a pointer to the interface implementing PPB_NaCl_Private that is | 109 // Returns a pointer to the interface implementing PPB_NaCl_Private that is |
91 // exposed to the plugin. | 110 // exposed to the plugin. |
92 static const PPB_NaCl_Private* GetInterface() { | 111 static const PPB_NaCl_Private* GetInterface() { |
93 return &ppb_nacl; | 112 return &ppb_nacl; |
94 } | 113 } |
95 }; | 114 }; |
96 #endif // DISABLE_NACL | 115 #endif // DISABLE_NACL |
97 | 116 |
98 const void* ChromePPAPIInterfaceFactory(const std::string& interface_name) { | 117 const void* ChromePPAPIInterfaceFactory(const std::string& interface_name) { |
99 #if !defined(DISABLE_NACL) | 118 #if !defined(DISABLE_NACL) |
100 if (interface_name == PPB_NACL_PRIVATE_INTERFACE) | 119 if (interface_name == PPB_NACL_PRIVATE_INTERFACE) |
101 return chrome::PPB_NaCl_Impl::GetInterface(); | 120 return chrome::PPB_NaCl_Impl::GetInterface(); |
102 #endif // DISABLE_NACL | 121 #endif // DISABLE_NACL |
103 if (interface_name == PPB_PDF_INTERFACE) | 122 if (interface_name == PPB_PDF_INTERFACE) |
104 return chrome::PPB_PDF_Impl::GetInterface(); | 123 return chrome::PPB_PDF_Impl::GetInterface(); |
105 return NULL; | 124 return NULL; |
106 } | 125 } |
107 | 126 |
108 } // namespace chrome | 127 } // namespace chrome |
OLD | NEW |