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 "webkit/plugins/ppapi/ppapi_webplugin_impl.h" | 5 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // The plugin delegate may have gone away. | 86 // The plugin delegate may have gone away. |
87 if (!init_data_->delegate) | 87 if (!init_data_->delegate) |
88 return false; | 88 return false; |
89 | 89 |
90 instance_ = init_data_->module->CreateInstance(init_data_->delegate, | 90 instance_ = init_data_->module->CreateInstance(init_data_->delegate, |
91 container, | 91 container, |
92 init_data_->url); | 92 init_data_->url); |
93 if (!instance_) | 93 if (!instance_) |
94 return false; | 94 return false; |
95 | 95 |
96 // Enable script objects for this plugin. | |
97 container->allowScriptObjects(); | |
98 | |
99 bool success = instance_->Initialize(init_data_->arg_names, | 96 bool success = instance_->Initialize(init_data_->arg_names, |
100 init_data_->arg_values, | 97 init_data_->arg_values, |
101 full_frame_); | 98 full_frame_); |
102 if (!success) { | 99 if (!success) { |
103 instance_->Delete(); | 100 instance_->Delete(); |
104 instance_ = NULL; | 101 instance_ = NULL; |
105 | 102 |
106 WebKit::WebPlugin* replacement_plugin = | 103 WebKit::WebPlugin* replacement_plugin = |
107 init_data_->delegate->CreatePluginReplacement( | 104 init_data_->delegate->CreatePluginReplacement( |
108 init_data_->module->path()); | 105 init_data_->module->path()); |
109 if (!replacement_plugin || !replacement_plugin->initialize(container)) | 106 if (!replacement_plugin || !replacement_plugin->initialize(container)) |
110 return false; | 107 return false; |
111 | 108 |
112 container->setPlugin(replacement_plugin); | 109 container->setPlugin(replacement_plugin); |
113 return true; | 110 return true; |
114 } | 111 } |
115 | 112 |
116 init_data_.reset(); | 113 init_data_.reset(); |
117 container_ = container; | 114 container_ = container; |
118 return true; | 115 return true; |
119 } | 116 } |
120 | 117 |
121 void WebPluginImpl::destroy() { | 118 void WebPluginImpl::destroy() { |
122 // Tell |container_| to clear references to this plugin's script objects. | |
123 container_->clearScriptObjects(); | |
124 | |
125 if (instance_) { | 119 if (instance_) { |
126 ::ppapi::PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(instance_object_); | 120 ::ppapi::PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(instance_object_); |
127 instance_object_ = PP_MakeUndefined(); | 121 instance_object_ = PP_MakeUndefined(); |
128 instance_->Delete(); | 122 instance_->Delete(); |
129 instance_ = NULL; | 123 instance_ = NULL; |
130 } | 124 } |
131 | 125 |
132 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 126 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
133 } | 127 } |
134 | 128 |
(...skipping 12 matching lines...) Expand all Loading... |
147 // any non-postMessage calls to it. | 141 // any non-postMessage calls to it. |
148 if (object) { | 142 if (object) { |
149 instance_->message_channel().SetPassthroughObject(object->np_object()); | 143 instance_->message_channel().SetPassthroughObject(object->np_object()); |
150 } | 144 } |
151 NPObject* message_channel_np_object(instance_->message_channel().np_object()); | 145 NPObject* message_channel_np_object(instance_->message_channel().np_object()); |
152 // The object is expected to be retained before it is returned. | 146 // The object is expected to be retained before it is returned. |
153 WebKit::WebBindings::retainObject(message_channel_np_object); | 147 WebKit::WebBindings::retainObject(message_channel_np_object); |
154 return message_channel_np_object; | 148 return message_channel_np_object; |
155 } | 149 } |
156 | 150 |
157 NPP WebPluginImpl::pluginNPP() { | |
158 return instance_->instanceNPP(); | |
159 } | |
160 | |
161 bool WebPluginImpl::getFormValue(WebString& value) { | 151 bool WebPluginImpl::getFormValue(WebString& value) { |
162 return false; | 152 return false; |
163 } | 153 } |
164 | 154 |
165 void WebPluginImpl::paint(WebCanvas* canvas, const WebRect& rect) { | 155 void WebPluginImpl::paint(WebCanvas* canvas, const WebRect& rect) { |
166 if (!instance_->FlashIsFullscreenOrPending()) | 156 if (!instance_->FlashIsFullscreenOrPending()) |
167 instance_->Paint(canvas, plugin_rect_, rect); | 157 instance_->Paint(canvas, plugin_rect_, rect); |
168 } | 158 } |
169 | 159 |
170 void WebPluginImpl::updateGeometry( | 160 void WebPluginImpl::updateGeometry( |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 void WebPluginImpl::rotateView(RotationType type) { | 285 void WebPluginImpl::rotateView(RotationType type) { |
296 instance_->RotateView(type); | 286 instance_->RotateView(type); |
297 } | 287 } |
298 | 288 |
299 bool WebPluginImpl::isPlaceholder() { | 289 bool WebPluginImpl::isPlaceholder() { |
300 return false; | 290 return false; |
301 } | 291 } |
302 | 292 |
303 } // namespace ppapi | 293 } // namespace ppapi |
304 } // namespace webkit | 294 } // namespace webkit |
OLD | NEW |