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 "content/renderer/pepper/renderer_ppapi_host_impl.h" | 5 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/renderer/pepper/pepper_in_process_resource_creation.h" | 8 #include "content/renderer/pepper/pepper_in_process_resource_creation.h" |
9 #include "content/renderer/pepper/pepper_in_process_router.h" | 9 #include "content/renderer/pepper/pepper_in_process_router.h" |
10 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h" | 10 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 RendererPpapiHostImpl* result = new RendererPpapiHostImpl( | 72 RendererPpapiHostImpl* result = new RendererPpapiHostImpl( |
73 module, permissions); | 73 module, permissions); |
74 | 74 |
75 // Takes ownership of pointer. | 75 // Takes ownership of pointer. |
76 module->SetEmbedderState( | 76 module->SetEmbedderState( |
77 scoped_ptr<webkit::ppapi::PluginModule::EmbedderState>(result)); | 77 scoped_ptr<webkit::ppapi::PluginModule::EmbedderState>(result)); |
78 | 78 |
79 return result; | 79 return result; |
80 } | 80 } |
81 | 81 |
| 82 // static |
| 83 RendererPpapiHostImpl* RendererPpapiHostImpl::GetForPPInstance( |
| 84 PP_Instance pp_instance) { |
| 85 PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance); |
| 86 if (!instance) |
| 87 return NULL; |
| 88 |
| 89 // All modules created by content will have their embedders state be the |
| 90 // host impl. |
| 91 return static_cast<RendererPpapiHostImpl*>( |
| 92 instance->module()->GetEmbedderState()); |
| 93 } |
| 94 |
82 scoped_ptr< ::ppapi::thunk::ResourceCreationAPI> | 95 scoped_ptr< ::ppapi::thunk::ResourceCreationAPI> |
83 RendererPpapiHostImpl::CreateInProcessResourceCreationAPI( | 96 RendererPpapiHostImpl::CreateInProcessResourceCreationAPI( |
84 webkit::ppapi::PluginInstance* instance) { | 97 webkit::ppapi::PluginInstance* instance) { |
85 return scoped_ptr< ::ppapi::thunk::ResourceCreationAPI>( | 98 return scoped_ptr< ::ppapi::thunk::ResourceCreationAPI>( |
86 new PepperInProcessResourceCreation(this, instance)); | 99 new PepperInProcessResourceCreation(this, instance)); |
87 } | 100 } |
88 | 101 |
89 ppapi::host::PpapiHost* RendererPpapiHostImpl::GetPpapiHost() { | 102 ppapi::host::PpapiHost* RendererPpapiHostImpl::GetPpapiHost() { |
90 return ppapi_host_.get(); | 103 return ppapi_host_.get(); |
91 } | 104 } |
(...skipping 30 matching lines...) Expand all Loading... |
122 PP_Instance pp_instance) const { | 135 PP_Instance pp_instance) const { |
123 PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance); | 136 PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance); |
124 if (!instance) | 137 if (!instance) |
125 return NULL; | 138 return NULL; |
126 if (instance->module() != module_) | 139 if (instance->module() != module_) |
127 return NULL; | 140 return NULL; |
128 return instance; | 141 return instance; |
129 } | 142 } |
130 | 143 |
131 } // namespace content | 144 } // namespace content |
OLD | NEW |