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; | |
218 // Set the container before Initialize because the plugin may | 215 // Set the container before Initialize because the plugin may |
219 // synchronously call NPN_GetValue to get its container during its | 216 // synchronously call NPN_GetValue to get its container during its |
220 // initialization. | 217 // initialization. |
221 SetContainer(container); | 218 SetContainer(container); |
222 bool ok = plugin_delegate->Initialize( | 219 bool ok = plugin_delegate->Initialize( |
223 plugin_url_, arg_names_, arg_values_, this, load_manually_); | 220 plugin_url_, arg_names_, arg_values_, this, load_manually_); |
224 if (!ok) { | 221 if (!ok) { |
225 plugin_delegate->PluginDestroyed(); | 222 plugin_delegate->PluginDestroyed(); |
226 return false; | 223 return false; |
227 } | 224 } |
228 | 225 |
229 if (!actual_mime_type.empty()) | 226 if (!actual_mime_type.empty()) |
230 mime_type_ = actual_mime_type; | 227 mime_type_ = actual_mime_type; |
| 228 delegate_ = plugin_delegate; |
231 | 229 |
232 return true; | 230 return true; |
233 } | 231 } |
234 | 232 |
235 void WebPluginImpl::destroy() { | 233 void WebPluginImpl::destroy() { |
236 SetContainer(NULL); | 234 SetContainer(NULL); |
237 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 235 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
238 } | 236 } |
239 | 237 |
240 NPObject* WebPluginImpl::scriptableObject() { | 238 NPObject* WebPluginImpl::scriptableObject() { |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 WebDevToolsAgent* WebPluginImpl::GetDevToolsAgent() { | 1124 WebDevToolsAgent* WebPluginImpl::GetDevToolsAgent() { |
1127 if (!webframe_) | 1125 if (!webframe_) |
1128 return NULL; | 1126 return NULL; |
1129 WebView* view = webframe_->view(); | 1127 WebView* view = webframe_->view(); |
1130 if (!view) | 1128 if (!view) |
1131 return NULL; | 1129 return NULL; |
1132 return view->devToolsAgent(); | 1130 return view->devToolsAgent(); |
1133 } | 1131 } |
1134 | 1132 |
1135 } // namespace webkit_glue | 1133 } // namespace webkit_glue |
OLD | NEW |