OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "base/gfx/rect.h" | 5 #include "base/gfx/rect.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "net/base/escape.h" | 10 #include "net/base/escape.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 bool WebPluginImpl::initialize(WebPluginContainer* container) { | 205 bool WebPluginImpl::initialize(WebPluginContainer* container) { |
206 if (!page_delegate_) | 206 if (!page_delegate_) |
207 return false; | 207 return false; |
208 | 208 |
209 std::string actual_mime_type; | 209 std::string actual_mime_type; |
210 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate( | 210 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate( |
211 plugin_url_, mime_type_, &actual_mime_type); | 211 plugin_url_, mime_type_, &actual_mime_type); |
212 if (!plugin_delegate) | 212 if (!plugin_delegate) |
213 return NULL; | 213 return NULL; |
214 | 214 |
| 215 // Set the delegate pointer before Initialize to allow Pepper |
| 216 // plugins to access to delegate functions during initialization. |
| 217 delegate_ = plugin_delegate; |
215 // Set the container before Initialize because the plugin may | 218 // Set the container before Initialize because the plugin may |
216 // synchronously call NPN_GetValue to get its container during its | 219 // synchronously call NPN_GetValue to get its container during its |
217 // initialization. | 220 // initialization. |
218 SetContainer(container); | 221 SetContainer(container); |
219 bool ok = plugin_delegate->Initialize( | 222 bool ok = plugin_delegate->Initialize( |
220 plugin_url_, arg_names_, arg_values_, this, load_manually_); | 223 plugin_url_, arg_names_, arg_values_, this, load_manually_); |
221 if (!ok) { | 224 if (!ok) { |
222 plugin_delegate->PluginDestroyed(); | 225 plugin_delegate->PluginDestroyed(); |
223 return false; | 226 return false; |
224 } | 227 } |
225 | 228 |
226 if (!actual_mime_type.empty()) | 229 if (!actual_mime_type.empty()) |
227 mime_type_ = actual_mime_type; | 230 mime_type_ = actual_mime_type; |
228 delegate_ = plugin_delegate; | |
229 | 231 |
230 return true; | 232 return true; |
231 } | 233 } |
232 | 234 |
233 void WebPluginImpl::destroy() { | 235 void WebPluginImpl::destroy() { |
234 SetContainer(NULL); | 236 SetContainer(NULL); |
235 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 237 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
236 } | 238 } |
237 | 239 |
238 NPObject* WebPluginImpl::scriptableObject() { | 240 NPObject* WebPluginImpl::scriptableObject() { |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1124 WebDevToolsAgent* WebPluginImpl::GetDevToolsAgent() { | 1126 WebDevToolsAgent* WebPluginImpl::GetDevToolsAgent() { |
1125 if (!webframe_) | 1127 if (!webframe_) |
1126 return NULL; | 1128 return NULL; |
1127 WebView* view = webframe_->view(); | 1129 WebView* view = webframe_->view(); |
1128 if (!view) | 1130 if (!view) |
1129 return NULL; | 1131 return NULL; |
1130 return view->devToolsAgent(); | 1132 return view->devToolsAgent(); |
1131 } | 1133 } |
1132 | 1134 |
1133 } // namespace webkit_glue | 1135 } // namespace webkit_glue |
OLD | NEW |