| 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 "ppapi/proxy/interface_list.h" | 5 #include "ppapi/proxy/interface_list.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 9 #include "ppapi/c/dev/ppb_alarms_dev.h" | 9 #include "ppapi/c/dev/ppb_alarms_dev.h" |
| 10 #include "ppapi/c/dev/ppb_audio_input_dev.h" | 10 #include "ppapi/c/dev/ppb_audio_input_dev.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 namespace proxy { | 147 namespace proxy { |
| 148 | 148 |
| 149 namespace { | 149 namespace { |
| 150 | 150 |
| 151 template<typename ProxyClass> | 151 template<typename ProxyClass> |
| 152 InterfaceProxy* ProxyFactory(Dispatcher* dispatcher) { | 152 InterfaceProxy* ProxyFactory(Dispatcher* dispatcher) { |
| 153 return new ProxyClass(dispatcher); | 153 return new ProxyClass(dispatcher); |
| 154 } | 154 } |
| 155 | 155 |
| 156 base::LazyInstance<PpapiPermissions> g_process_global_permissions; | 156 base::LazyInstance<PpapiPermissions> g_process_global_permissions; |
| 157 base::LazyInstance<bool> g_supports_dev_channel; | |
| 158 | 157 |
| 159 } // namespace | 158 } // namespace |
| 160 | 159 |
| 161 InterfaceList::InterfaceList() { | 160 InterfaceList::InterfaceList() { |
| 162 memset(id_to_factory_, 0, sizeof(id_to_factory_)); | 161 memset(id_to_factory_, 0, sizeof(id_to_factory_)); |
| 163 | 162 |
| 164 // Register the API factories for each of the API types. This calls AddProxy | 163 // Register the API factories for each of the API types. This calls AddProxy |
| 165 // for each InterfaceProxy type we support. | 164 // for each InterfaceProxy type we support. |
| 166 #define PROXIED_API(api_name) \ | 165 #define PROXIED_API(api_name) \ |
| 167 AddProxy(PROXY_API_ID(api_name), &PROXY_FACTORY_NAME(api_name)); | 166 AddProxy(PROXY_API_ID(api_name), &PROXY_FACTORY_NAME(api_name)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 186 { | 185 { |
| 187 Permission current_required_permission = PERMISSION_PRIVATE; | 186 Permission current_required_permission = PERMISSION_PRIVATE; |
| 188 #include "ppapi/thunk/interfaces_ppb_private.h" | 187 #include "ppapi/thunk/interfaces_ppb_private.h" |
| 189 } | 188 } |
| 190 { | 189 { |
| 191 #if !defined(OS_NACL) | 190 #if !defined(OS_NACL) |
| 192 Permission current_required_permission = PERMISSION_FLASH; | 191 Permission current_required_permission = PERMISSION_FLASH; |
| 193 #include "ppapi/thunk/interfaces_ppb_private_flash.h" | 192 #include "ppapi/thunk/interfaces_ppb_private_flash.h" |
| 194 #endif // !defined(OS_NACL) | 193 #endif // !defined(OS_NACL) |
| 195 } | 194 } |
| 196 | 195 { |
| 197 // TODO(teravest): Add dev channel interfaces here. | 196 // TODO(teravest): These lines should be uncommented when a dev channel |
| 197 // interface is added. They're commented right now because they cause an |
| 198 // unused variable warning. |
| 199 // |
| 200 // Permission current_required_permission = PERMISSION_DEV_CHANNEL; |
| 201 // #include "ppapi/thunk/interfaces_ppb_public_dev_channel.h" |
| 202 } |
| 198 | 203 |
| 199 #undef PROXIED_API | 204 #undef PROXIED_API |
| 200 #undef PROXIED_IFACE | 205 #undef PROXIED_IFACE |
| 201 | 206 |
| 202 // Manually add some special proxies. Some of these don't have interfaces | 207 // Manually add some special proxies. Some of these don't have interfaces |
| 203 // that they support, so aren't covered by the macros above, but have proxies | 208 // that they support, so aren't covered by the macros above, but have proxies |
| 204 // for message routing. Others have different implementations between the | 209 // for message routing. Others have different implementations between the |
| 205 // proxy and the impl and there's no obvious message routing. | 210 // proxy and the impl and there's no obvious message routing. |
| 206 AddProxy(API_ID_RESOURCE_CREATION, &ResourceCreationProxy::Create); | 211 AddProxy(API_ID_RESOURCE_CREATION, &ResourceCreationProxy::Create); |
| 207 AddProxy(API_ID_PPP_CLASS, &PPP_Class_Proxy::Create); | 212 AddProxy(API_ID_PPP_CLASS, &PPP_Class_Proxy::Create); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 221 AddPPB(PPB_OPENGLES2_CHROMIUMENABLEFEATURE_INTERFACE_1_0, | 226 AddPPB(PPB_OPENGLES2_CHROMIUMENABLEFEATURE_INTERFACE_1_0, |
| 222 PPB_OpenGLES2_Shared::GetChromiumEnableFeatureInterface(), | 227 PPB_OpenGLES2_Shared::GetChromiumEnableFeatureInterface(), |
| 223 PERMISSION_NONE); | 228 PERMISSION_NONE); |
| 224 AddPPB(PPB_OPENGLES2_CHROMIUMMAPSUB_INTERFACE_1_0, | 229 AddPPB(PPB_OPENGLES2_CHROMIUMMAPSUB_INTERFACE_1_0, |
| 225 PPB_OpenGLES2_Shared::GetChromiumMapSubInterface(), PERMISSION_NONE); | 230 PPB_OpenGLES2_Shared::GetChromiumMapSubInterface(), PERMISSION_NONE); |
| 226 AddPPB(PPB_OPENGLES2_CHROMIUMMAPSUB_DEV_INTERFACE_1_0, | 231 AddPPB(PPB_OPENGLES2_CHROMIUMMAPSUB_DEV_INTERFACE_1_0, |
| 227 PPB_OpenGLES2_Shared::GetChromiumMapSubInterface(), PERMISSION_NONE); | 232 PPB_OpenGLES2_Shared::GetChromiumMapSubInterface(), PERMISSION_NONE); |
| 228 AddPPB(PPB_OPENGLES2_QUERY_INTERFACE_1_0, | 233 AddPPB(PPB_OPENGLES2_QUERY_INTERFACE_1_0, |
| 229 PPB_OpenGLES2_Shared::GetQueryInterface(), PERMISSION_NONE); | 234 PPB_OpenGLES2_Shared::GetQueryInterface(), PERMISSION_NONE); |
| 230 AddPPB(PPB_VAR_ARRAY_BUFFER_INTERFACE_1_0, | 235 AddPPB(PPB_VAR_ARRAY_BUFFER_INTERFACE_1_0, |
| 231 PPB_Var_Shared::GetVarArrayBufferInterface1_0(), | 236 PPB_Var_Shared::GetVarArrayBufferInterface1_0(), PERMISSION_NONE); |
| 232 PERMISSION_NONE); | |
| 233 AddPPB(PPB_VAR_INTERFACE_1_1, | 237 AddPPB(PPB_VAR_INTERFACE_1_1, |
| 234 PPB_Var_Shared::GetVarInterface1_1(), PERMISSION_NONE); | 238 PPB_Var_Shared::GetVarInterface1_1(), PERMISSION_NONE); |
| 235 AddPPB(PPB_VAR_INTERFACE_1_0, | 239 AddPPB(PPB_VAR_INTERFACE_1_0, |
| 236 PPB_Var_Shared::GetVarInterface1_0(), PERMISSION_NONE); | 240 PPB_Var_Shared::GetVarInterface1_0(), PERMISSION_NONE); |
| 237 | 241 |
| 238 #if !defined(OS_NACL) | 242 #if !defined(OS_NACL) |
| 239 // PPB (browser) interfaces. | 243 // PPB (browser) interfaces. |
| 240 // Do not add more stuff here, they should be added to interface_list*.h | 244 // Do not add more stuff here, they should be added to interface_list*.h |
| 241 // TODO(brettw) remove these. | 245 // TODO(brettw) remove these. |
| 242 AddProxy(API_ID_PPB_INSTANCE_PRIVATE, &ProxyFactory<PPB_Instance_Proxy>); | 246 AddProxy(API_ID_PPB_INSTANCE_PRIVATE, &ProxyFactory<PPB_Instance_Proxy>); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 InterfaceList* InterfaceList::GetInstance() { | 300 InterfaceList* InterfaceList::GetInstance() { |
| 297 return Singleton<InterfaceList>::get(); | 301 return Singleton<InterfaceList>::get(); |
| 298 } | 302 } |
| 299 | 303 |
| 300 // static | 304 // static |
| 301 void InterfaceList::SetProcessGlobalPermissions( | 305 void InterfaceList::SetProcessGlobalPermissions( |
| 302 const PpapiPermissions& permissions) { | 306 const PpapiPermissions& permissions) { |
| 303 g_process_global_permissions.Get() = permissions; | 307 g_process_global_permissions.Get() = permissions; |
| 304 } | 308 } |
| 305 | 309 |
| 306 // static | |
| 307 void InterfaceList::SetSupportsDevChannel( | |
| 308 bool supports_dev_channel) { | |
| 309 g_supports_dev_channel.Get() = supports_dev_channel; | |
| 310 } | |
| 311 | |
| 312 InterfaceProxy::Factory InterfaceList::GetFactoryForID(ApiID id) const { | 310 InterfaceProxy::Factory InterfaceList::GetFactoryForID(ApiID id) const { |
| 313 int index = static_cast<int>(id); | 311 int index = static_cast<int>(id); |
| 314 COMPILE_ASSERT(API_ID_NONE == 0, none_must_be_zero); | 312 COMPILE_ASSERT(API_ID_NONE == 0, none_must_be_zero); |
| 315 if (id <= 0 || id >= API_ID_COUNT) | 313 if (id <= 0 || id >= API_ID_COUNT) |
| 316 return NULL; | 314 return NULL; |
| 317 return id_to_factory_[index]; | 315 return id_to_factory_[index]; |
| 318 } | 316 } |
| 319 | 317 |
| 320 const void* InterfaceList::GetInterfaceForPPB(const std::string& name) const { | 318 const void* InterfaceList::GetInterfaceForPPB(const std::string& name) const { |
| 321 NameToInterfaceInfoMap::const_iterator found = | 319 NameToInterfaceInfoMap::const_iterator found = |
| 322 name_to_browser_info_.find(name); | 320 name_to_browser_info_.find(name); |
| 323 if (found == name_to_browser_info_.end()) | 321 if (found == name_to_browser_info_.end()) |
| 324 return NULL; | 322 return NULL; |
| 325 | 323 |
| 326 // Dev channel checking goes here. | |
| 327 | |
| 328 if (g_process_global_permissions.Get().HasPermission( | 324 if (g_process_global_permissions.Get().HasPermission( |
| 329 found->second.required_permission)) | 325 found->second.required_permission)) |
| 330 return found->second.iface; | 326 return found->second.iface; |
| 331 return NULL; | 327 return NULL; |
| 332 } | 328 } |
| 333 | 329 |
| 334 const void* InterfaceList::GetInterfaceForPPP(const std::string& name) const { | 330 const void* InterfaceList::GetInterfaceForPPP(const std::string& name) const { |
| 335 NameToInterfaceInfoMap::const_iterator found = | 331 NameToInterfaceInfoMap::const_iterator found = |
| 336 name_to_plugin_info_.find(name); | 332 name_to_plugin_info_.find(name); |
| 337 if (found == name_to_plugin_info_.end()) | 333 if (found == name_to_plugin_info_.end()) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 363 } | 359 } |
| 364 | 360 |
| 365 void InterfaceList::AddPPP(const char* name, | 361 void InterfaceList::AddPPP(const char* name, |
| 366 const void* iface) { | 362 const void* iface) { |
| 367 DCHECK(name_to_plugin_info_.find(name) == name_to_plugin_info_.end()); | 363 DCHECK(name_to_plugin_info_.find(name) == name_to_plugin_info_.end()); |
| 368 name_to_plugin_info_[name] = InterfaceInfo(iface, PERMISSION_NONE); | 364 name_to_plugin_info_[name] = InterfaceInfo(iface, PERMISSION_NONE); |
| 369 } | 365 } |
| 370 | 366 |
| 371 } // namespace proxy | 367 } // namespace proxy |
| 372 } // namespace ppapi | 368 } // namespace ppapi |
| OLD | NEW |