| 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/browser_plugin/browser_plugin.h" | 5 #include "content/renderer/browser_plugin/browser_plugin.h" |
| 6 | 6 |
| 7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
| 8 #include "base/id_map.h" | 8 #include "base/id_map.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/process.h" | 10 #include "base/process.h" |
| 11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
| 12 #include "base/string_piece.h" | 12 #include "base/string_piece.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "content/common/browser_plugin_messages.h" | 15 #include "content/common/browser_plugin_messages.h" |
| 16 #include "content/public/common/url_constants.h" | 16 #include "content/public/common/url_constants.h" |
| 17 #include "content/renderer/render_view_impl.h" | 17 #include "content/renderer/render_view_impl.h" |
| 18 #include "ipc/ipc_channel_handle.h" | 18 #include "ipc/ipc_channel_handle.h" |
| 19 #include "ppapi/proxy/host_dispatcher.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
| 22 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 23 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 23 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" | 24 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" |
| 24 #include "webkit/plugins/webview_plugin.h" | 25 #include "webkit/plugins/webview_plugin.h" |
| 25 | 26 |
| 26 static int g_next_id = 0; | 27 static int g_next_id = 0; |
| 27 | 28 |
| 28 // The global list of all Browser Plugin Placeholders within a process. | 29 // The global list of all Browser Plugin Placeholders within a process. |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 WebKit::WebPlugin* current_plugin = | 143 WebKit::WebPlugin* current_plugin = |
| 143 plugin_ ? static_cast<WebKit::WebPlugin*>(plugin_) : placeholder_; | 144 plugin_ ? static_cast<WebKit::WebPlugin*>(plugin_) : placeholder_; |
| 144 WebKit::WebPluginContainer* container = current_plugin->container(); | 145 WebKit::WebPluginContainer* container = current_plugin->container(); |
| 145 if (!new_plugin || !new_plugin->initialize(container)) | 146 if (!new_plugin || !new_plugin->initialize(container)) |
| 146 return; | 147 return; |
| 147 | 148 |
| 148 // Clear the container's backing texture ID and the script objects. | 149 // Clear the container's backing texture ID and the script objects. |
| 149 if (plugin_) | 150 if (plugin_) |
| 150 plugin_->instance()->BindGraphics(plugin_->instance()->pp_instance(), 0); | 151 plugin_->instance()->BindGraphics(plugin_->instance()->pp_instance(), 0); |
| 151 | 152 |
| 152 // Inform the browser process of the association between the browser plugin's | 153 PP_Instance instance = new_plugin->instance()->pp_instance(); |
| 153 // instance ID and the pepper channel's PP_Instance identifier. | 154 ppapi::proxy::HostDispatcher* dispatcher = |
| 154 render_view()->Send(new BrowserPluginHostMsg_MapInstance( | 155 ppapi::proxy::HostDispatcher::GetForInstance(instance); |
| 155 render_view()->GetRoutingID(), | 156 DCHECK(dispatcher); |
| 156 id_, | 157 dispatcher->Send(new BrowserPluginMsg_GuestReady(instance, id_)); |
| 157 new_plugin->instance()->pp_instance())); | 158 |
| 158 // TODO(fsamuel): We should delay the swapping out of the current plugin | 159 // TODO(fsamuel): We should delay the swapping out of the current plugin |
| 159 // until after the guest's WebGraphicsContext3D has been initialized. That | 160 // until after the guest's WebGraphicsContext3D has been initialized. That |
| 160 // way, we immediately have something to render onto the screen. | 161 // way, we immediately have something to render onto the screen. |
| 161 container->setPlugin(new_plugin); | 162 container->setPlugin(new_plugin); |
| 162 container->invalidate(); | 163 container->invalidate(); |
| 163 container->reportGeometry(); | 164 container->reportGeometry(); |
| 164 if (plugin_) | 165 if (plugin_) |
| 165 plugin_->destroy(); | 166 plugin_->destroy(); |
| 166 plugin_ = new_plugin; | 167 plugin_ = new_plugin; |
| 167 } | 168 } |
| OLD | NEW |