| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/glue/plugins/pepper_plugin_module.h" | 5 #include "webkit/glue/plugins/pepper_plugin_module.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // FIXME(brettw) do uniquifying of the plugin here like the NPAPI one. | 115 // FIXME(brettw) do uniquifying of the plugin here like the NPAPI one. |
| 116 | 116 |
| 117 scoped_refptr<PluginModule> lib(new PluginModule(filename)); | 117 scoped_refptr<PluginModule> lib(new PluginModule(filename)); |
| 118 if (!lib->Load()) | 118 if (!lib->Load()) |
| 119 lib = NULL; | 119 lib = NULL; |
| 120 return lib; | 120 return lib; |
| 121 } | 121 } |
| 122 | 122 |
| 123 // static | 123 // static |
| 124 PluginModule* PluginModule::FromPPModule(PP_Module module) { | 124 PluginModule* PluginModule::FromPPModule(PP_Module module) { |
| 125 PluginModule* lib = reinterpret_cast<PluginModule*>(module.id); | 125 PluginModule* lib = reinterpret_cast<PluginModule*>(module); |
| 126 if (GetLivePluginSet()->find(lib) == GetLivePluginSet()->end()) | 126 if (GetLivePluginSet()->find(lib) == GetLivePluginSet()->end()) |
| 127 return NULL; // Invalid plugin. | 127 return NULL; // Invalid plugin. |
| 128 return lib; | 128 return lib; |
| 129 } | 129 } |
| 130 | 130 |
| 131 bool PluginModule::Load() { | 131 bool PluginModule::Load() { |
| 132 if (initialized_) | 132 if (initialized_) |
| 133 return true; | 133 return true; |
| 134 initialized_ = true; | 134 initialized_ = true; |
| 135 | 135 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 159 int retval = initialize_module(GetPPModule(), &GetInterface); | 159 int retval = initialize_module(GetPPModule(), &GetInterface); |
| 160 if (retval != 0) { | 160 if (retval != 0) { |
| 161 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval; | 161 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval; |
| 162 return false; | 162 return false; |
| 163 } | 163 } |
| 164 | 164 |
| 165 return true; | 165 return true; |
| 166 } | 166 } |
| 167 | 167 |
| 168 PP_Module PluginModule::GetPPModule() const { | 168 PP_Module PluginModule::GetPPModule() const { |
| 169 PP_Module ret; | 169 return reinterpret_cast<intptr_t>(this); |
| 170 ret.id = reinterpret_cast<intptr_t>(this); | |
| 171 return ret; | |
| 172 } | 170 } |
| 173 | 171 |
| 174 PluginInstance* PluginModule::CreateInstance(PluginDelegate* delegate) { | 172 PluginInstance* PluginModule::CreateInstance(PluginDelegate* delegate) { |
| 175 const PPP_Instance* plugin_instance_interface = | 173 const PPP_Instance* plugin_instance_interface = |
| 176 reinterpret_cast<const PPP_Instance*>(GetPluginInterface( | 174 reinterpret_cast<const PPP_Instance*>(GetPluginInterface( |
| 177 PPP_INSTANCE_INTERFACE)); | 175 PPP_INSTANCE_INTERFACE)); |
| 178 if (!plugin_instance_interface) { | 176 if (!plugin_instance_interface) { |
| 179 LOG(WARNING) << "Plugin doesn't support instance interface, failing."; | 177 LOG(WARNING) << "Plugin doesn't support instance interface, failing."; |
| 180 return NULL; | 178 return NULL; |
| 181 } | 179 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 197 | 195 |
| 198 void PluginModule::InstanceCreated(PluginInstance* instance) { | 196 void PluginModule::InstanceCreated(PluginInstance* instance) { |
| 199 instances_.insert(instance); | 197 instances_.insert(instance); |
| 200 } | 198 } |
| 201 | 199 |
| 202 void PluginModule::InstanceDeleted(PluginInstance* instance) { | 200 void PluginModule::InstanceDeleted(PluginInstance* instance) { |
| 203 instances_.erase(instance); | 201 instances_.erase(instance); |
| 204 } | 202 } |
| 205 | 203 |
| 206 } // namespace pepper | 204 } // namespace pepper |
| OLD | NEW |