| 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 "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "gfx/rect.h" | 9 #include "gfx/rect.h" |
| 10 #include "net/base/escape.h" | 10 #include "net/base/escape.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 } | 201 } |
| 202 | 202 |
| 203 } // namespace | 203 } // namespace |
| 204 | 204 |
| 205 // WebKit::WebPlugin ---------------------------------------------------------- | 205 // WebKit::WebPlugin ---------------------------------------------------------- |
| 206 | 206 |
| 207 bool WebPluginImpl::initialize(WebPluginContainer* container) { | 207 bool WebPluginImpl::initialize(WebPluginContainer* container) { |
| 208 if (!page_delegate_) | 208 if (!page_delegate_) |
| 209 return false; | 209 return false; |
| 210 | 210 |
| 211 std::string actual_mime_type; | |
| 212 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate( | 211 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate( |
| 213 plugin_url_, mime_type_, &actual_mime_type); | 212 file_path_, mime_type_); |
| 214 if (!plugin_delegate) | 213 if (!plugin_delegate) |
| 215 return NULL; | 214 return false; |
| 216 | 215 |
| 217 // Set the container before Initialize because the plugin may | 216 // Set the container before Initialize because the plugin may |
| 218 // synchronously call NPN_GetValue to get its container during its | 217 // synchronously call NPN_GetValue to get its container during its |
| 219 // initialization. | 218 // initialization. |
| 220 SetContainer(container); | 219 SetContainer(container); |
| 221 bool ok = plugin_delegate->Initialize( | 220 bool ok = plugin_delegate->Initialize( |
| 222 plugin_url_, arg_names_, arg_values_, this, load_manually_); | 221 plugin_url_, arg_names_, arg_values_, this, load_manually_); |
| 223 if (!ok) { | 222 if (!ok) { |
| 224 plugin_delegate->PluginDestroyed(); | 223 plugin_delegate->PluginDestroyed(); |
| 225 return false; | 224 return false; |
| 226 } | 225 } |
| 227 | 226 |
| 228 if (!actual_mime_type.empty()) | |
| 229 mime_type_ = actual_mime_type; | |
| 230 delegate_ = plugin_delegate; | 227 delegate_ = plugin_delegate; |
| 231 | 228 |
| 232 return true; | 229 return true; |
| 233 } | 230 } |
| 234 | 231 |
| 235 void WebPluginImpl::destroy() { | 232 void WebPluginImpl::destroy() { |
| 236 SetContainer(NULL); | 233 SetContainer(NULL); |
| 237 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 234 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 238 } | 235 } |
| 239 | 236 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 | 399 |
| 403 void WebPluginImpl::printEnd() { | 400 void WebPluginImpl::printEnd() { |
| 404 if (delegate_) | 401 if (delegate_) |
| 405 delegate_->PrintEnd(); | 402 delegate_->PrintEnd(); |
| 406 } | 403 } |
| 407 | 404 |
| 408 | 405 |
| 409 // ----------------------------------------------------------------------------- | 406 // ----------------------------------------------------------------------------- |
| 410 | 407 |
| 411 WebPluginImpl::WebPluginImpl( | 408 WebPluginImpl::WebPluginImpl( |
| 412 WebFrame* webframe, const WebPluginParams& params, | 409 WebFrame* webframe, |
| 410 const WebPluginParams& params, |
| 411 const FilePath& file_path, |
| 412 const std::string& mime_type, |
| 413 const base::WeakPtr<WebPluginPageDelegate>& page_delegate) | 413 const base::WeakPtr<WebPluginPageDelegate>& page_delegate) |
| 414 : windowless_(false), | 414 : windowless_(false), |
| 415 window_(gfx::kNullPluginWindow), | 415 window_(gfx::kNullPluginWindow), |
| 416 accepts_input_events_(false), | 416 accepts_input_events_(false), |
| 417 page_delegate_(page_delegate), | 417 page_delegate_(page_delegate), |
| 418 webframe_(webframe), | 418 webframe_(webframe), |
| 419 delegate_(NULL), | 419 delegate_(NULL), |
| 420 container_(NULL), | 420 container_(NULL), |
| 421 plugin_url_(params.url), | 421 plugin_url_(params.url), |
| 422 load_manually_(params.loadManually), | 422 load_manually_(params.loadManually), |
| 423 first_geometry_update_(true), | 423 first_geometry_update_(true), |
| 424 ignore_response_error_(false), | 424 ignore_response_error_(false), |
| 425 mime_type_(params.mimeType.utf8()), | 425 file_path_(file_path), |
| 426 mime_type_(mime_type), |
| 426 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { | 427 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { |
| 427 DCHECK_EQ(params.attributeNames.size(), params.attributeValues.size()); | 428 DCHECK_EQ(params.attributeNames.size(), params.attributeValues.size()); |
| 428 StringToLowerASCII(&mime_type_); | 429 StringToLowerASCII(&mime_type_); |
| 429 | 430 |
| 430 for (size_t i = 0; i < params.attributeNames.size(); ++i) { | 431 for (size_t i = 0; i < params.attributeNames.size(); ++i) { |
| 431 arg_names_.push_back(params.attributeNames[i].utf8()); | 432 arg_names_.push_back(params.attributeNames[i].utf8()); |
| 432 arg_values_.push_back(params.attributeValues[i].utf8()); | 433 arg_values_.push_back(params.attributeValues[i].utf8()); |
| 433 } | 434 } |
| 434 } | 435 } |
| 435 | 436 |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1141 return false; | 1142 return false; |
| 1142 | 1143 |
| 1143 WebPluginContainer* container_widget = container_; | 1144 WebPluginContainer* container_widget = container_; |
| 1144 | 1145 |
| 1145 // Destroy the current plugin instance. | 1146 // Destroy the current plugin instance. |
| 1146 TearDownPluginInstance(loader); | 1147 TearDownPluginInstance(loader); |
| 1147 | 1148 |
| 1148 container_ = container_widget; | 1149 container_ = container_widget; |
| 1149 webframe_ = webframe; | 1150 webframe_ = webframe; |
| 1150 | 1151 |
| 1151 std::string actual_mime_type; | |
| 1152 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate( | 1152 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate( |
| 1153 plugin_url_, mime_type_, &actual_mime_type); | 1153 file_path_, mime_type_); |
| 1154 | 1154 |
| 1155 bool ok = plugin_delegate->Initialize( | 1155 bool ok = plugin_delegate && plugin_delegate->Initialize( |
| 1156 plugin_url_, arg_names_, arg_values_, this, load_manually_); | 1156 plugin_url_, arg_names_, arg_values_, this, load_manually_); |
| 1157 | 1157 |
| 1158 if (!ok) { | 1158 if (!ok) { |
| 1159 container_ = NULL; | 1159 container_ = NULL; |
| 1160 // TODO(iyengar) Should we delete the current plugin instance here? | 1160 // TODO(iyengar) Should we delete the current plugin instance here? |
| 1161 return false; | 1161 return false; |
| 1162 } | 1162 } |
| 1163 | 1163 |
| 1164 mime_type_ = actual_mime_type; | |
| 1165 delegate_ = plugin_delegate; | 1164 delegate_ = plugin_delegate; |
| 1166 | 1165 |
| 1167 // Force a geometry update to occur to ensure that the plugin becomes | 1166 // Force a geometry update to occur to ensure that the plugin becomes |
| 1168 // visible. | 1167 // visible. |
| 1169 container_->reportGeometry(); | 1168 container_->reportGeometry(); |
| 1170 | 1169 |
| 1171 // The plugin move sequences accumulated via DidMove are sent to the browser | 1170 // The plugin move sequences accumulated via DidMove are sent to the browser |
| 1172 // whenever the renderer paints. Force a paint here to ensure that changes | 1171 // whenever the renderer paints. Force a paint here to ensure that changes |
| 1173 // to the plugin window are propagated to the browser. | 1172 // to the plugin window are propagated to the browser. |
| 1174 container_->invalidate(); | 1173 container_->invalidate(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1232 WebDevToolsAgent* WebPluginImpl::GetDevToolsAgent() { | 1231 WebDevToolsAgent* WebPluginImpl::GetDevToolsAgent() { |
| 1233 if (!webframe_) | 1232 if (!webframe_) |
| 1234 return NULL; | 1233 return NULL; |
| 1235 WebView* view = webframe_->view(); | 1234 WebView* view = webframe_->view(); |
| 1236 if (!view) | 1235 if (!view) |
| 1237 return NULL; | 1236 return NULL; |
| 1238 return view->devToolsAgent(); | 1237 return view->devToolsAgent(); |
| 1239 } | 1238 } |
| 1240 | 1239 |
| 1241 } // namespace webkit_glue | 1240 } // namespace webkit_glue |
| OLD | NEW |