| OLD | NEW |
| 1 // Copyright (c) 2006-2008 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 "config.h" | |
| 6 | |
| 7 #include "Document.h" | |
| 8 #include "DocumentLoader.h" | |
| 9 #include "FormState.h" | |
| 10 #include "Frame.h" | |
| 11 #include "FrameLoader.h" | |
| 12 #include "FrameLoadRequest.h" | |
| 13 #include "HTMLFormElement.h" | |
| 14 #include "KURL.h" | |
| 15 #include "PlatformString.h" | |
| 16 #include "ResourceResponse.h" | |
| 17 #include "ScriptController.h" | |
| 18 #include "ScriptValue.h" | |
| 19 #include "Widget.h" | |
| 20 | |
| 21 #undef LOG | |
| 22 #include "base/gfx/rect.h" | 5 #include "base/gfx/rect.h" |
| 23 #include "base/logging.h" | 6 #include "base/logging.h" |
| 24 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 25 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 26 #include "net/base/escape.h" | 9 #include "net/base/escape.h" |
| 10 #include "skia/ext/platform_canvas.h" |
| 11 #if defined(OS_WIN) |
| 12 #include "webkit/activex_shim/activex_shared.h" |
| 13 #endif |
| 27 #include "webkit/api/public/WebConsoleMessage.h" | 14 #include "webkit/api/public/WebConsoleMessage.h" |
| 15 #include "webkit/api/public/WebCString.h" |
| 28 #include "webkit/api/public/WebCursorInfo.h" | 16 #include "webkit/api/public/WebCursorInfo.h" |
| 29 #include "webkit/api/public/WebData.h" | 17 #include "webkit/api/public/WebData.h" |
| 18 #include "webkit/api/public/WebFrame.h" |
| 30 #include "webkit/api/public/WebHTTPBody.h" | 19 #include "webkit/api/public/WebHTTPBody.h" |
| 31 #include "webkit/api/public/WebHTTPHeaderVisitor.h" | 20 #include "webkit/api/public/WebHTTPHeaderVisitor.h" |
| 32 #include "webkit/api/public/WebInputEvent.h" | 21 #include "webkit/api/public/WebInputEvent.h" |
| 33 #include "webkit/api/public/WebKit.h" | 22 #include "webkit/api/public/WebKit.h" |
| 34 #include "webkit/api/public/WebKitClient.h" | 23 #include "webkit/api/public/WebKitClient.h" |
| 24 #include "webkit/api/public/WebPluginContainer.h" |
| 25 #include "webkit/api/public/WebPluginParams.h" |
| 35 #include "webkit/api/public/WebRect.h" | 26 #include "webkit/api/public/WebRect.h" |
| 36 #include "webkit/api/public/WebString.h" | |
| 37 #include "webkit/api/public/WebURL.h" | 27 #include "webkit/api/public/WebURL.h" |
| 38 #include "webkit/api/public/WebURLLoader.h" | 28 #include "webkit/api/public/WebURLLoader.h" |
| 39 #include "webkit/api/public/WebURLLoaderClient.h" | 29 #include "webkit/api/public/WebURLLoaderClient.h" |
| 40 #include "webkit/api/public/WebURLResponse.h" | 30 #include "webkit/api/public/WebURLResponse.h" |
| 41 #include "webkit/api/public/WebVector.h" | |
| 42 #include "webkit/api/src/WebPluginContainerImpl.h" | |
| 43 #include "webkit/glue/chrome_client_impl.h" | |
| 44 #include "webkit/glue/glue_util.h" | |
| 45 #include "webkit/glue/multipart_response_delegate.h" | 31 #include "webkit/glue/multipart_response_delegate.h" |
| 46 #include "webkit/glue/webkit_glue.h" | |
| 47 #include "webkit/glue/webplugin_impl.h" | 32 #include "webkit/glue/webplugin_impl.h" |
| 48 #include "webkit/glue/plugins/plugin_host.h" | 33 #include "webkit/glue/plugins/plugin_host.h" |
| 49 #include "webkit/glue/plugins/plugin_instance.h" | 34 #include "webkit/glue/plugins/plugin_instance.h" |
| 50 #include "webkit/glue/webplugin_delegate.h" | 35 #include "webkit/glue/webplugin_delegate.h" |
| 51 #include "webkit/glue/webview_impl.h" | 36 #include "webkit/glue/webplugin_page_delegate.h" |
| 37 #include "webkit/glue/webview.h" |
| 52 #include "googleurl/src/gurl.h" | 38 #include "googleurl/src/gurl.h" |
| 53 | 39 |
| 54 using WebKit::WebCanvas; | 40 using WebKit::WebCanvas; |
| 55 using WebKit::WebConsoleMessage; | 41 using WebKit::WebConsoleMessage; |
| 42 using WebKit::WebCString; |
| 56 using WebKit::WebCursorInfo; | 43 using WebKit::WebCursorInfo; |
| 57 using WebKit::WebData; | 44 using WebKit::WebData; |
| 58 using WebKit::WebDataSource; | 45 using WebKit::WebDataSource; |
| 59 using WebKit::WebFrame; | 46 using WebKit::WebFrame; |
| 60 using WebKit::WebHTTPBody; | 47 using WebKit::WebHTTPBody; |
| 61 using WebKit::WebHTTPHeaderVisitor; | 48 using WebKit::WebHTTPHeaderVisitor; |
| 62 using WebKit::WebInputEvent; | 49 using WebKit::WebInputEvent; |
| 63 using WebKit::WebKeyboardEvent; | 50 using WebKit::WebKeyboardEvent; |
| 64 using WebKit::WebMouseEvent; | 51 using WebKit::WebMouseEvent; |
| 65 using WebKit::WebPluginContainer; | 52 using WebKit::WebPluginContainer; |
| 66 using WebKit::WebPluginContainerImpl; | 53 using WebKit::WebPluginParams; |
| 67 using WebKit::WebRect; | 54 using WebKit::WebRect; |
| 68 using WebKit::WebString; | 55 using WebKit::WebString; |
| 69 using WebKit::WebURL; | 56 using WebKit::WebURL; |
| 70 using WebKit::WebURLError; | 57 using WebKit::WebURLError; |
| 71 using WebKit::WebURLLoader; | 58 using WebKit::WebURLLoader; |
| 72 using WebKit::WebURLLoaderClient; | 59 using WebKit::WebURLLoaderClient; |
| 73 using WebKit::WebURLRequest; | 60 using WebKit::WebURLRequest; |
| 74 using WebKit::WebURLResponse; | 61 using WebKit::WebURLResponse; |
| 75 using WebKit::WebVector; | 62 using WebKit::WebVector; |
| 76 using webkit_glue::MultipartResponseDelegate; | 63 using webkit_glue::MultipartResponseDelegate; |
| 77 | 64 |
| 65 namespace webkit_glue { |
| 78 namespace { | 66 namespace { |
| 79 | 67 |
| 80 // This class handles individual multipart responses. It is instantiated when | 68 // This class handles individual multipart responses. It is instantiated when |
| 81 // we receive HTTP status code 206 in the HTTP response. This indicates | 69 // we receive HTTP status code 206 in the HTTP response. This indicates |
| 82 // that the response could have multiple parts each separated by a boundary | 70 // that the response could have multiple parts each separated by a boundary |
| 83 // specified in the response header. | 71 // specified in the response header. |
| 84 class MultiPartResponseClient : public WebURLLoaderClient { | 72 class MultiPartResponseClient : public WebURLLoaderClient { |
| 85 public: | 73 public: |
| 86 MultiPartResponseClient(WebPluginResourceClient* resource_client) | 74 MultiPartResponseClient(WebPluginResourceClient* resource_client) |
| 87 : resource_client_(resource_client) { | 75 : resource_client_(resource_client) { |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 WebString content_encoding = | 190 WebString content_encoding = |
| 203 response.httpHeaderField(WebString::fromUTF8("Content-Encoding")); | 191 response.httpHeaderField(WebString::fromUTF8("Content-Encoding")); |
| 204 if (!content_encoding.isNull() && | 192 if (!content_encoding.isNull() && |
| 205 !EqualsASCII(content_encoding, "identity")) { | 193 !EqualsASCII(content_encoding, "identity")) { |
| 206 // Don't send the compressed content length to the plugin, which only | 194 // Don't send the compressed content length to the plugin, which only |
| 207 // cares about the decoded length. | 195 // cares about the decoded length. |
| 208 response_info->expected_length = 0; | 196 response_info->expected_length = 0; |
| 209 } | 197 } |
| 210 } | 198 } |
| 211 | 199 |
| 200 // Utility function to convert a vector to an array of char*'s. |
| 201 // Caller is responsible to free memory with DeleteArray(). |
| 202 static char** ToArray(const WebVector<WebString>& input) { |
| 203 char** array = new char*[input.size() + 1]; |
| 204 size_t index; |
| 205 for (index = 0; index < input.size(); ++index) { |
| 206 const WebCString& src = input[index].utf8(); |
| 207 array[index] = new char[src.length() + 1]; |
| 208 base::strlcpy(array[index], src.data(), src.length() + 1); |
| 209 array[index][src.length()] = '\0'; |
| 210 } |
| 211 array[index] = 0; |
| 212 return array; |
| 213 } |
| 214 |
| 215 static void DeleteArray(char** array) { |
| 216 char** ptr = array; |
| 217 while (*ptr) { |
| 218 delete[] *ptr; |
| 219 ++ptr; |
| 220 } |
| 221 delete[] array; |
| 222 } |
| 223 |
| 212 } // namespace | 224 } // namespace |
| 213 | 225 |
| 214 PassRefPtr<WebCore::Widget> WebPluginImpl::Create( | 226 // WebKit::WebPlugin ---------------------------------------------------------- |
| 215 const GURL& url, | |
| 216 char** argn, | |
| 217 char** argv, | |
| 218 int argc, | |
| 219 WebCore::HTMLPlugInElement* element, | |
| 220 WebFrameImpl* frame, | |
| 221 WebPluginDelegate* delegate, | |
| 222 bool load_manually, | |
| 223 const std::string& mime_type) { | |
| 224 // NOTE: frame contains element | |
| 225 | 227 |
| 226 WebPluginImpl* webplugin = new WebPluginImpl( | 228 bool WebPluginImpl::initialize(WebPluginContainer* container) { |
| 227 frame, delegate, url, load_manually, mime_type, argc, argn, argv); | 229 if (!page_delegate_) |
| 230 return false; |
| 228 | 231 |
| 229 if (!delegate->Initialize(url, argn, argv, argc, webplugin, load_manually)) { | 232 // Get the classid and version from attributes of the object. |
| 230 delegate->PluginDestroyed(); | 233 std::string combined_clsid; |
| 231 delete webplugin; | 234 #if defined(OS_WIN) |
| 235 std::string clsid, version; |
| 236 if (activex_shim::IsMimeTypeActiveX(mime_type_)) { |
| 237 for (size_t i = 0; i < arg_count_; i++) { |
| 238 const char* param_name = arg_names_[i]; |
| 239 const char* param_value = arg_values_[i]; |
| 240 if (base::strcasecmp(param_name, "classid") == 0) { |
| 241 activex_shim::GetClsidFromClassidAttribute(param_value, &clsid); |
| 242 } else if (base::strcasecmp(param_name, "codebase") == 0) { |
| 243 version = activex_shim::GetVersionFromCodebaseAttribute(param_value); |
| 244 } |
| 245 } |
| 246 |
| 247 // Attempt to map this clsid to a known NPAPI mime type if possible, failing |
| 248 // which we attempt to load the activex shim for the clsid. |
| 249 if (!activex_shim::GetMimeTypeForClsid(clsid, &mime_type_)) { |
| 250 // We need to pass the combined clsid + version to PluginsList, so that it |
| 251 // would detect if the requested version is installed. If not, it needs |
| 252 // to use the default plugin to update the control. |
| 253 if (!version.empty()) |
| 254 combined_clsid = clsid + "#" + version; |
| 255 else |
| 256 combined_clsid = clsid; |
| 257 } |
| 258 } |
| 259 #endif |
| 260 |
| 261 std::string actual_mime_type; |
| 262 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate( |
| 263 plugin_url_, mime_type_, combined_clsid, &actual_mime_type); |
| 264 if (!plugin_delegate) |
| 232 return NULL; | 265 return NULL; |
| 266 |
| 267 bool ok = plugin_delegate->Initialize( |
| 268 plugin_url_, arg_names_, arg_values_, arg_count_, this, load_manually_); |
| 269 if (!ok) { |
| 270 plugin_delegate->PluginDestroyed(); |
| 271 return false; |
| 233 } | 272 } |
| 234 | 273 |
| 235 PassRefPtr<WebPluginContainerImpl> container = | 274 if (!actual_mime_type.empty()) |
| 236 WebPluginContainerImpl::create(element, webplugin); | 275 mime_type_ = actual_mime_type; |
| 237 webplugin->SetContainer(container.get()); | 276 delegate_ = plugin_delegate; |
| 238 return container; | 277 |
| 278 SetContainer(container); |
| 279 return true; |
| 239 } | 280 } |
| 240 | 281 |
| 241 WebPluginImpl::WebPluginImpl(WebFrameImpl* webframe, | |
| 242 WebPluginDelegate* delegate, | |
| 243 const GURL& plugin_url, | |
| 244 bool load_manually, | |
| 245 const std::string& mime_type, | |
| 246 int arg_count, | |
| 247 char** arg_names, | |
| 248 char** arg_values) | |
| 249 : windowless_(false), | |
| 250 window_(NULL), | |
| 251 webframe_(webframe), | |
| 252 delegate_(delegate), | |
| 253 container_(NULL), | |
| 254 plugin_url_(plugin_url), | |
| 255 load_manually_(load_manually), | |
| 256 first_geometry_update_(true), | |
| 257 ignore_response_error_(false), | |
| 258 mime_type_(mime_type), | |
| 259 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { | |
| 260 | |
| 261 ArrayToVector(arg_count, arg_names, &arg_names_); | |
| 262 ArrayToVector(arg_count, arg_values, &arg_values_); | |
| 263 } | |
| 264 | |
| 265 // WebKit::WebPlugin ----------------------------------------------------------- | |
| 266 | |
| 267 void WebPluginImpl::destroy() { | 282 void WebPluginImpl::destroy() { |
| 268 SetContainer(NULL); | 283 SetContainer(NULL); |
| 269 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 284 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 270 } | 285 } |
| 271 | 286 |
| 272 NPObject* WebPluginImpl::scriptableObject() { | 287 NPObject* WebPluginImpl::scriptableObject() { |
| 273 return delegate_->GetPluginScriptableObject(); | 288 return delegate_->GetPluginScriptableObject(); |
| 274 } | 289 } |
| 275 | 290 |
| 276 void WebPluginImpl::paint(WebCanvas* canvas, const WebRect& paint_rect) { | 291 void WebPluginImpl::paint(WebCanvas* canvas, const WebRect& paint_rect) { |
| 277 // Note that |context| is only used when in windowless mode. | 292 // Note that |context| is only used when in windowless mode. |
| 278 #if WEBKIT_USING_SKIA | 293 #if WEBKIT_USING_SKIA |
| 279 gfx::NativeDrawingContext context = canvas->beginPlatformPaint(); | 294 gfx::NativeDrawingContext context = canvas->beginPlatformPaint(); |
| 280 #elif WEBKIT_USING_CG | 295 #elif WEBKIT_USING_CG |
| 281 gfx::NativeDrawingContext context = canvas; | 296 gfx::NativeDrawingContext context = canvas; |
| 282 #endif | 297 #endif |
| 283 | 298 |
| 284 delegate_->Paint(context, paint_rect); | 299 delegate_->Paint(context, paint_rect); |
| 285 | 300 |
| 286 #if WEBKIT_USING_SKIA | 301 #if WEBKIT_USING_SKIA |
| 287 canvas->endPlatformPaint(); | 302 canvas->endPlatformPaint(); |
| 288 #endif | 303 #endif |
| 289 } | 304 } |
| 290 | 305 |
| 291 void WebPluginImpl::updateGeometry( | 306 void WebPluginImpl::updateGeometry( |
| 292 const WebRect& window_rect, const WebRect& clip_rect, | 307 const WebRect& window_rect, const WebRect& clip_rect, |
| 293 const WebVector<WebRect>& cutout_rects, bool is_visible) { | 308 const WebVector<WebRect>& cutout_rects, bool is_visible) { |
| 294 if (window_) { | 309 if (window_ && page_delegate_) { |
| 295 WebViewDelegate* view_delegate = GetWebViewDelegate(); | 310 // Notify the window hosting the plugin (the WebViewDelegate) that |
| 296 if (view_delegate) { | 311 // it needs to adjust the plugin, so that all the HWNDs can be moved |
| 297 // Notify the window hosting the plugin (the WebViewDelegate) that | 312 // at the same time. |
| 298 // it needs to adjust the plugin, so that all the HWNDs can be moved | 313 WebPluginGeometry move; |
| 299 // at the same time. | 314 move.window = window_; |
| 300 WebPluginGeometry move; | 315 move.window_rect = window_rect; |
| 301 move.window = window_; | 316 move.clip_rect = clip_rect; |
| 302 move.window_rect = window_rect; | 317 for (size_t i = 0; i < cutout_rects.size(); ++i) |
| 303 move.clip_rect = clip_rect; | 318 move.cutout_rects.push_back(cutout_rects[i]); |
| 304 for (size_t i = 0; i < cutout_rects.size(); ++i) | 319 move.rects_valid = true; |
| 305 move.cutout_rects.push_back(cutout_rects[i]); | 320 move.visible = is_visible; |
| 306 move.rects_valid = true; | |
| 307 move.visible = is_visible; | |
| 308 | 321 |
| 309 view_delegate->DidMovePlugin(move); | 322 page_delegate_->DidMovePlugin(move); |
| 310 } | |
| 311 } | 323 } |
| 312 | 324 |
| 313 if (first_geometry_update_ || window_rect != window_rect_ || | 325 if (first_geometry_update_ || window_rect != window_rect_ || |
| 314 clip_rect != clip_rect_) { | 326 clip_rect != clip_rect_) { |
| 315 window_rect_ = window_rect; | 327 window_rect_ = window_rect; |
| 316 clip_rect_ = clip_rect; | 328 clip_rect_ = clip_rect; |
| 317 // Notify the plugin that its parameters have changed. | 329 // Notify the plugin that its parameters have changed. |
| 318 delegate_->UpdateGeometry(window_rect_, clip_rect_); | 330 delegate_->UpdateGeometry(window_rect_, clip_rect_); |
| 319 | 331 |
| 320 // Initiate a download on the plugin url. This should be done for the | 332 // Initiate a download on the plugin url. This should be done for the |
| (...skipping 15 matching lines...) Expand all Loading... |
| 336 } | 348 } |
| 337 } | 349 } |
| 338 } | 350 } |
| 339 | 351 |
| 340 void WebPluginImpl::updateFocus(bool focused) { | 352 void WebPluginImpl::updateFocus(bool focused) { |
| 341 if (focused && windowless_) | 353 if (focused && windowless_) |
| 342 delegate_->SetFocus(); | 354 delegate_->SetFocus(); |
| 343 } | 355 } |
| 344 | 356 |
| 345 void WebPluginImpl::updateVisibility(bool visible) { | 357 void WebPluginImpl::updateVisibility(bool visible) { |
| 346 if (!window_) | 358 if (!window_ || !page_delegate_) |
| 347 return; | |
| 348 | |
| 349 WebViewDelegate* view_delegate = GetWebViewDelegate(); | |
| 350 if (!view_delegate) | |
| 351 return; | 359 return; |
| 352 | 360 |
| 353 WebPluginGeometry move; | 361 WebPluginGeometry move; |
| 354 move.window = window_; | 362 move.window = window_; |
| 355 move.window_rect = gfx::Rect(); | 363 move.window_rect = gfx::Rect(); |
| 356 move.clip_rect = gfx::Rect(); | 364 move.clip_rect = gfx::Rect(); |
| 357 move.rects_valid = false; | 365 move.rects_valid = false; |
| 358 move.visible = visible; | 366 move.visible = visible; |
| 359 | 367 |
| 360 view_delegate->DidMovePlugin(move); | 368 page_delegate_->DidMovePlugin(move); |
| 361 } | 369 } |
| 362 | 370 |
| 363 bool WebPluginImpl::acceptsInputEvents() { | 371 bool WebPluginImpl::acceptsInputEvents() { |
| 364 return windowless_; | 372 return windowless_; |
| 365 } | 373 } |
| 366 | 374 |
| 367 bool WebPluginImpl::handleInputEvent( | 375 bool WebPluginImpl::handleInputEvent( |
| 368 const WebInputEvent& event, WebCursorInfo& cursor_info) { | 376 const WebInputEvent& event, WebCursorInfo& cursor_info) { |
| 369 return delegate_->HandleInputEvent(event, &cursor_info); | 377 return delegate_->HandleInputEvent(event, &cursor_info); |
| 370 } | 378 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 const WebURL& url, void* notify_data, const WebURLError& error) { | 416 const WebURL& url, void* notify_data, const WebURLError& error) { |
| 409 // TODO(darin): Map net::ERR_ABORTED to NPRES_USER_BREAK? | 417 // TODO(darin): Map net::ERR_ABORTED to NPRES_USER_BREAK? |
| 410 if (delegate_) { | 418 if (delegate_) { |
| 411 delegate_->DidFinishLoadWithReason( | 419 delegate_->DidFinishLoadWithReason( |
| 412 url, NPRES_NETWORK_ERR, reinterpret_cast<intptr_t>(notify_data)); | 420 url, NPRES_NETWORK_ERR, reinterpret_cast<intptr_t>(notify_data)); |
| 413 } | 421 } |
| 414 } | 422 } |
| 415 | 423 |
| 416 // ----------------------------------------------------------------------------- | 424 // ----------------------------------------------------------------------------- |
| 417 | 425 |
| 418 WebPluginImpl::~WebPluginImpl() { | 426 WebPluginImpl::WebPluginImpl( |
| 427 WebFrame* webframe, const WebPluginParams& params, |
| 428 const base::WeakPtr<WebPluginPageDelegate>& page_delegate) |
| 429 : windowless_(false), |
| 430 window_(NULL), |
| 431 page_delegate_(page_delegate), |
| 432 webframe_(webframe), |
| 433 delegate_(NULL), |
| 434 container_(NULL), |
| 435 plugin_url_(params.url), |
| 436 load_manually_(params.loadManually), |
| 437 first_geometry_update_(true), |
| 438 ignore_response_error_(false), |
| 439 mime_type_(params.mimeType.utf8()), |
| 440 arg_names_(ToArray(params.attributeNames)), |
| 441 arg_values_(ToArray(params.attributeValues)), |
| 442 arg_count_(params.attributeNames.size()), |
| 443 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { |
| 444 DCHECK_EQ(params.attributeNames.size(), params.attributeValues.size()); |
| 445 StringToLowerASCII(&mime_type_); |
| 419 } | 446 } |
| 420 | 447 |
| 448 WebPluginImpl::~WebPluginImpl() { |
| 449 if (arg_names_) |
| 450 DeleteArray(arg_names_); |
| 451 if (arg_values_) |
| 452 DeleteArray(arg_values_); |
| 453 } |
| 421 | 454 |
| 422 void WebPluginImpl::SetWindow(gfx::PluginWindowHandle window) { | 455 void WebPluginImpl::SetWindow(gfx::PluginWindowHandle window) { |
| 423 if (window) { | 456 if (window) { |
| 424 DCHECK(!windowless_); // Make sure not called twice. | 457 DCHECK(!windowless_); // Make sure not called twice. |
| 425 window_ = window; | 458 window_ = window; |
| 426 WebViewDelegate* view_delegate = GetWebViewDelegate(); | 459 if (page_delegate_) { |
| 427 if (view_delegate) { | |
| 428 // Tell the view delegate that the plugin window was created, so that it | 460 // Tell the view delegate that the plugin window was created, so that it |
| 429 // can create necessary container widgets. | 461 // can create necessary container widgets. |
| 430 view_delegate->CreatedPluginWindow(window); | 462 page_delegate_->CreatedPluginWindow(window); |
| 431 } | 463 } |
| 432 } else { | 464 } else { |
| 433 DCHECK(!window_); // Make sure not called twice. | 465 DCHECK(!window_); // Make sure not called twice. |
| 434 windowless_ = true; | 466 windowless_ = true; |
| 435 } | 467 } |
| 436 } | 468 } |
| 437 | 469 |
| 438 void WebPluginImpl::WillDestroyWindow(gfx::PluginWindowHandle window) { | 470 void WebPluginImpl::WillDestroyWindow(gfx::PluginWindowHandle window) { |
| 439 DCHECK_EQ(window, window_); | 471 DCHECK_EQ(window, window_); |
| 440 window_ = NULL; | 472 window_ = NULL; |
| 441 WebViewDelegate* view_delegate = GetWebViewDelegate(); | 473 if (page_delegate_) |
| 442 if (!view_delegate) | 474 page_delegate_->WillDestroyPluginWindow(window); |
| 443 return; | |
| 444 view_delegate->WillDestroyPluginWindow(window); | |
| 445 } | 475 } |
| 446 | 476 |
| 447 GURL WebPluginImpl::CompleteURL(const char* url) { | 477 GURL WebPluginImpl::CompleteURL(const char* url) { |
| 448 if (!webframe_) { | 478 if (!webframe_) { |
| 449 NOTREACHED(); | 479 NOTREACHED(); |
| 450 return GURL(); | 480 return GURL(); |
| 451 } | 481 } |
| 452 // TODO(darin): Is conversion from UTF8 correct here? | 482 // TODO(darin): Is conversion from UTF8 correct here? |
| 453 return webframe_->completeURL(WebString::fromUTF8(url)); | 483 return webframe_->completeURL(WebString::fromUTF8(url)); |
| 454 } | 484 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 468 | 498 |
| 469 bool WebPluginImpl::SetPostData(WebURLRequest* request, | 499 bool WebPluginImpl::SetPostData(WebURLRequest* request, |
| 470 const char *buf, | 500 const char *buf, |
| 471 uint32 length) { | 501 uint32 length) { |
| 472 std::vector<std::string> names; | 502 std::vector<std::string> names; |
| 473 std::vector<std::string> values; | 503 std::vector<std::string> values; |
| 474 std::vector<char> body; | 504 std::vector<char> body; |
| 475 bool rv = NPAPI::PluginHost::SetPostData(buf, length, &names, &values, &body); | 505 bool rv = NPAPI::PluginHost::SetPostData(buf, length, &names, &values, &body); |
| 476 | 506 |
| 477 for (size_t i = 0; i < names.size(); ++i) { | 507 for (size_t i = 0; i < names.size(); ++i) { |
| 478 request->addHTTPHeaderField(webkit_glue::StdStringToWebString(names[i]), | 508 request->addHTTPHeaderField(WebString::fromUTF8(names[i]), |
| 479 webkit_glue::StdStringToWebString(values[i])); | 509 WebString::fromUTF8(values[i])); |
| 480 } | 510 } |
| 481 | 511 |
| 482 WebString content_type_header = WebString::fromUTF8("Content-Type"); | 512 WebString content_type_header = WebString::fromUTF8("Content-Type"); |
| 483 const WebString& content_type = | 513 const WebString& content_type = |
| 484 request->httpHeaderField(content_type_header); | 514 request->httpHeaderField(content_type_header); |
| 485 if (content_type.isEmpty()) { | 515 if (content_type.isEmpty()) { |
| 486 request->setHTTPHeaderField( | 516 request->setHTTPHeaderField( |
| 487 content_type_header, | 517 content_type_header, |
| 488 WebString::fromUTF8("application/x-www-form-urlencoded")); | 518 WebString::fromUTF8("application/x-www-form-urlencoded")); |
| 489 } | 519 } |
| 490 | 520 |
| 491 WebHTTPBody http_body; | 521 WebHTTPBody http_body; |
| 492 if (body.size()) { | 522 if (body.size()) { |
| 493 http_body.initialize(); | 523 http_body.initialize(); |
| 494 http_body.appendData(WebData(&body[0], body.size())); | 524 http_body.appendData(WebData(&body[0], body.size())); |
| 495 } | 525 } |
| 496 request->setHTTPBody(http_body); | 526 request->setHTTPBody(http_body); |
| 497 | 527 |
| 498 return rv; | 528 return rv; |
| 499 } | 529 } |
| 500 | 530 |
| 501 RoutingStatus WebPluginImpl::RouteToFrame(const char *method, | 531 WebPluginImpl::RoutingStatus WebPluginImpl::RouteToFrame( |
| 502 bool is_javascript_url, | 532 const char *method, |
| 503 const char* target, unsigned int len, | 533 bool is_javascript_url, |
| 504 const char* buf, bool is_file_data, | 534 const char* target, |
| 505 bool notify_needed, | 535 unsigned int len, |
| 506 intptr_t notify_data, | 536 const char* buf, |
| 507 const char* url, GURL* unused) { | 537 bool is_file_data, |
| 538 bool notify_needed, |
| 539 intptr_t notify_data, |
| 540 const char* url) { |
| 508 // If there is no target, there is nothing to do | 541 // If there is no target, there is nothing to do |
| 509 if (!target) | 542 if (!target) |
| 510 return NOT_ROUTED; | 543 return NOT_ROUTED; |
| 511 | 544 |
| 512 // This could happen if the WebPluginContainer was already deleted. | 545 // This could happen if the WebPluginContainer was already deleted. |
| 513 if (!webframe_) | 546 if (!webframe_) |
| 514 return NOT_ROUTED; | 547 return NOT_ROUTED; |
| 515 | 548 |
| 516 WebString target_str = WebString::fromUTF8(target); | 549 WebString target_str = WebString::fromUTF8(target); |
| 517 | 550 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 url, policy_url, WebString::fromUTF8(cookie)); | 620 url, policy_url, WebString::fromUTF8(cookie)); |
| 588 } | 621 } |
| 589 | 622 |
| 590 std::string WebPluginImpl::GetCookies(const GURL& url, const GURL& policy_url) { | 623 std::string WebPluginImpl::GetCookies(const GURL& url, const GURL& policy_url) { |
| 591 return UTF16ToUTF8(WebKit::webKitClient()->cookies(url, policy_url)); | 624 return UTF16ToUTF8(WebKit::webKitClient()->cookies(url, policy_url)); |
| 592 } | 625 } |
| 593 | 626 |
| 594 void WebPluginImpl::ShowModalHTMLDialog(const GURL& url, int width, int height, | 627 void WebPluginImpl::ShowModalHTMLDialog(const GURL& url, int width, int height, |
| 595 const std::string& json_arguments, | 628 const std::string& json_arguments, |
| 596 std::string* json_retval) { | 629 std::string* json_retval) { |
| 597 WebViewDelegate* view_delegate = GetWebViewDelegate(); | 630 if (page_delegate_) { |
| 598 if (view_delegate) { | 631 page_delegate_->ShowModalHTMLDialogForPlugin( |
| 599 view_delegate->ShowModalHTMLDialog( | 632 url, gfx::Size(width, height), json_arguments, json_retval); |
| 600 url, width, height, json_arguments, json_retval); | |
| 601 } | 633 } |
| 602 } | 634 } |
| 603 | 635 |
| 604 void WebPluginImpl::OnMissingPluginStatus(int status) { | 636 void WebPluginImpl::OnMissingPluginStatus(int status) { |
| 605 NOTREACHED(); | 637 NOTREACHED(); |
| 606 } | 638 } |
| 607 | 639 |
| 608 void WebPluginImpl::Invalidate() { | 640 void WebPluginImpl::Invalidate() { |
| 609 if (container_) | 641 if (container_) |
| 610 container_->invalidate(); | 642 container_->invalidate(); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 } | 792 } |
| 761 | 793 |
| 762 void WebPluginImpl::didFinishLoading(WebURLLoader* loader) { | 794 void WebPluginImpl::didFinishLoading(WebURLLoader* loader) { |
| 763 ClientInfo* client_info = GetClientInfoFromLoader(loader); | 795 ClientInfo* client_info = GetClientInfoFromLoader(loader); |
| 764 if (client_info && client_info->client) { | 796 if (client_info && client_info->client) { |
| 765 MultiPartResponseHandlerMap::iterator index = | 797 MultiPartResponseHandlerMap::iterator index = |
| 766 multi_part_response_map_.find(client_info->client); | 798 multi_part_response_map_.find(client_info->client); |
| 767 if (index != multi_part_response_map_.end()) { | 799 if (index != multi_part_response_map_.end()) { |
| 768 delete (*index).second; | 800 delete (*index).second; |
| 769 multi_part_response_map_.erase(index); | 801 multi_part_response_map_.erase(index); |
| 770 | 802 if (page_delegate_) |
| 771 WebView* webview = webframe_->GetWebViewImpl(); | 803 page_delegate_->DidStopLoadingForPlugin(); |
| 772 webview->GetDelegate()->DidStopLoading(webview); | |
| 773 } | 804 } |
| 774 loader->setDefersLoading(true); | 805 loader->setDefersLoading(true); |
| 775 WebPluginResourceClient* resource_client = client_info->client; | 806 WebPluginResourceClient* resource_client = client_info->client; |
| 776 // The ClientInfo can get deleted in the call to DidFinishLoading below. | 807 // The ClientInfo can get deleted in the call to DidFinishLoading below. |
| 777 // It is not safe to access this structure after that. | 808 // It is not safe to access this structure after that. |
| 778 client_info->client = NULL; | 809 client_info->client = NULL; |
| 779 resource_client->DidFinishLoading(); | 810 resource_client->DidFinishLoading(); |
| 780 } | 811 } |
| 781 } | 812 } |
| 782 | 813 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 800 void WebPluginImpl::RemoveClient(WebURLLoader* loader) { | 831 void WebPluginImpl::RemoveClient(WebURLLoader* loader) { |
| 801 for (size_t i = 0; i < clients_.size(); ++i) { | 832 for (size_t i = 0; i < clients_.size(); ++i) { |
| 802 if (clients_[i].loader.get() == loader) { | 833 if (clients_[i].loader.get() == loader) { |
| 803 RemoveClient(i); | 834 RemoveClient(i); |
| 804 return; | 835 return; |
| 805 } | 836 } |
| 806 } | 837 } |
| 807 } | 838 } |
| 808 | 839 |
| 809 void WebPluginImpl::SetContainer(WebPluginContainer* container) { | 840 void WebPluginImpl::SetContainer(WebPluginContainer* container) { |
| 810 if (container == NULL) { | 841 if (!container) |
| 811 TearDownPluginInstance(NULL); | 842 TearDownPluginInstance(NULL); |
| 812 } | |
| 813 container_ = container; | 843 container_ = container; |
| 814 } | 844 } |
| 815 | 845 |
| 816 void WebPluginImpl::HandleURLRequest(const char *method, | 846 void WebPluginImpl::HandleURLRequest(const char *method, |
| 817 bool is_javascript_url, | 847 bool is_javascript_url, |
| 818 const char* target, unsigned int len, | 848 const char* target, unsigned int len, |
| 819 const char* buf, bool is_file_data, | 849 const char* buf, bool is_file_data, |
| 820 bool notify, const char* url, | 850 bool notify, const char* url, |
| 821 intptr_t notify_data, bool popups_allowed)
{ | 851 intptr_t notify_data, bool popups_allowed)
{ |
| 822 HandleURLRequestInternal(method, is_javascript_url, target, len, buf, | 852 HandleURLRequestInternal(method, is_javascript_url, target, len, buf, |
| 823 is_file_data, notify, url, notify_data, | 853 is_file_data, notify, url, notify_data, |
| 824 popups_allowed, true); | 854 popups_allowed, true); |
| 825 } | 855 } |
| 826 | 856 |
| 827 void WebPluginImpl::HandleURLRequestInternal( | 857 void WebPluginImpl::HandleURLRequestInternal( |
| 828 const char *method, bool is_javascript_url, const char* target, | 858 const char *method, bool is_javascript_url, const char* target, |
| 829 unsigned int len, const char* buf, bool is_file_data, bool notify, | 859 unsigned int len, const char* buf, bool is_file_data, bool notify, |
| 830 const char* url, intptr_t notify_data, bool popups_allowed, | 860 const char* url, intptr_t notify_data, bool popups_allowed, |
| 831 bool use_plugin_src_as_referrer) { | 861 bool use_plugin_src_as_referrer) { |
| 832 // For this request, we either route the output to a frame | 862 // For this request, we either route the output to a frame |
| 833 // because a target has been specified, or we handle the request | 863 // because a target has been specified, or we handle the request |
| 834 // here, i.e. by executing the script if it is a javascript url | 864 // here, i.e. by executing the script if it is a javascript url |
| 835 // or by initiating a download on the URL, etc. There is one special | 865 // or by initiating a download on the URL, etc. There is one special |
| 836 // case in that the request is a javascript url and the target is "_self", | 866 // case in that the request is a javascript url and the target is "_self", |
| 837 // in which case we route the output to the plugin rather than routing it | 867 // in which case we route the output to the plugin rather than routing it |
| 838 // to the plugin's frame. | 868 // to the plugin's frame. |
| 839 GURL complete_url; | 869 RoutingStatus routing_status = |
| 840 int routing_status = RouteToFrame(method, is_javascript_url, target, len, | 870 RouteToFrame(method, is_javascript_url, target, len, buf, is_file_data, |
| 841 buf, is_file_data, notify, notify_data, | 871 notify, notify_data, url); |
| 842 url, &complete_url); | |
| 843 if (routing_status == ROUTED) | 872 if (routing_status == ROUTED) |
| 844 return; | 873 return; |
| 845 | 874 |
| 846 if (is_javascript_url) { | 875 if (is_javascript_url) { |
| 847 GURL gurl(url); | 876 GURL gurl(url); |
| 848 WebString result = container_->executeScriptURL(gurl, popups_allowed); | 877 WebString result = container_->executeScriptURL(gurl, popups_allowed); |
| 849 | 878 |
| 850 // delegate_ could be NULL because executeScript caused the container to | 879 // delegate_ could be NULL because executeScript caused the container to |
| 851 // be deleted. | 880 // be deleted. |
| 852 if (delegate_) { | 881 if (delegate_) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 info.loader.reset(WebKit::webKitClient()->createURLLoader()); | 953 info.loader.reset(WebKit::webKitClient()->createURLLoader()); |
| 925 if (!info.loader.get()) | 954 if (!info.loader.get()) |
| 926 return false; | 955 return false; |
| 927 info.loader->loadAsynchronously(info.request, this); | 956 info.loader->loadAsynchronously(info.request, this); |
| 928 | 957 |
| 929 clients_.push_back(info); | 958 clients_.push_back(info); |
| 930 return true; | 959 return true; |
| 931 } | 960 } |
| 932 | 961 |
| 933 void WebPluginImpl::CancelDocumentLoad() { | 962 void WebPluginImpl::CancelDocumentLoad() { |
| 934 if (frame()->loader()->activeDocumentLoader()) { | 963 if (webframe_) { |
| 935 ignore_response_error_ = true; | 964 ignore_response_error_ = true; |
| 936 frame()->loader()->activeDocumentLoader()->stopLoading(); | 965 webframe_->stopLoading(); |
| 937 } | 966 } |
| 938 } | 967 } |
| 939 | 968 |
| 940 void WebPluginImpl::InitiateHTTPRangeRequest(const char* url, | 969 void WebPluginImpl::InitiateHTTPRangeRequest(const char* url, |
| 941 const char* range_info, | 970 const char* range_info, |
| 942 intptr_t existing_stream, | 971 intptr_t existing_stream, |
| 943 bool notify_needed, | 972 bool notify_needed, |
| 944 intptr_t notify_data) { | 973 intptr_t notify_data) { |
| 945 int resource_id = GetNextResourceId(); | 974 int resource_id = GetNextResourceId(); |
| 946 GURL complete_url = CompleteURL(url); | 975 GURL complete_url = CompleteURL(url); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 | 1010 |
| 982 void WebPluginImpl::HandleHttpMultipartResponse( | 1011 void WebPluginImpl::HandleHttpMultipartResponse( |
| 983 const WebURLResponse& response, WebPluginResourceClient* client) { | 1012 const WebURLResponse& response, WebPluginResourceClient* client) { |
| 984 std::string multipart_boundary; | 1013 std::string multipart_boundary; |
| 985 if (!MultipartResponseDelegate::ReadMultipartBoundary( | 1014 if (!MultipartResponseDelegate::ReadMultipartBoundary( |
| 986 response, &multipart_boundary)) { | 1015 response, &multipart_boundary)) { |
| 987 NOTREACHED(); | 1016 NOTREACHED(); |
| 988 return; | 1017 return; |
| 989 } | 1018 } |
| 990 | 1019 |
| 991 WebView* webview = webframe_->GetWebViewImpl(); | 1020 if (page_delegate_) |
| 992 webview->GetDelegate()->DidStartLoading(webview); | 1021 page_delegate_->DidStartLoadingForPlugin(); |
| 993 | 1022 |
| 994 MultiPartResponseClient* multi_part_response_client = | 1023 MultiPartResponseClient* multi_part_response_client = |
| 995 new MultiPartResponseClient(client); | 1024 new MultiPartResponseClient(client); |
| 996 | 1025 |
| 997 MultipartResponseDelegate* multi_part_response_handler = | 1026 MultipartResponseDelegate* multi_part_response_handler = |
| 998 new MultipartResponseDelegate(multi_part_response_client, NULL, | 1027 new MultipartResponseDelegate(multi_part_response_client, NULL, |
| 999 response, | 1028 response, |
| 1000 multipart_boundary); | 1029 multipart_boundary); |
| 1001 multi_part_response_map_[client] = multi_part_response_handler; | 1030 multi_part_response_map_[client] = multi_part_response_handler; |
| 1002 } | 1031 } |
| 1003 | 1032 |
| 1004 bool WebPluginImpl::ReinitializePluginForResponse( | 1033 bool WebPluginImpl::ReinitializePluginForResponse( |
| 1005 WebURLLoader* loader) { | 1034 WebURLLoader* loader) { |
| 1006 WebFrameImpl* webframe = webframe_; | 1035 WebFrame* webframe = webframe_; |
| 1007 if (!webframe) | 1036 if (!webframe) |
| 1008 return false; | 1037 return false; |
| 1009 | 1038 |
| 1010 WebViewImpl* webview = webframe->GetWebViewImpl(); | 1039 WebView* webview = webframe->view(); |
| 1011 if (!webview) | 1040 if (!webview) |
| 1012 return false; | 1041 return false; |
| 1013 | 1042 |
| 1014 WebPluginContainer* container_widget = container_; | 1043 WebPluginContainer* container_widget = container_; |
| 1015 | 1044 |
| 1016 // Destroy the current plugin instance. | 1045 // Destroy the current plugin instance. |
| 1017 TearDownPluginInstance(loader); | 1046 TearDownPluginInstance(loader); |
| 1018 | 1047 |
| 1019 container_ = container_widget; | 1048 container_ = container_widget; |
| 1020 webframe_ = webframe; | 1049 webframe_ = webframe; |
| 1021 | 1050 |
| 1022 WebViewDelegate* webview_delegate = webview->GetDelegate(); | |
| 1023 std::string actual_mime_type; | 1051 std::string actual_mime_type; |
| 1024 WebPluginDelegate* plugin_delegate = | 1052 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate( |
| 1025 webview_delegate->CreatePluginDelegate(webview, plugin_url_, | 1053 plugin_url_, mime_type_, std::string(), &actual_mime_type); |
| 1026 mime_type_, std::string(), | |
| 1027 &actual_mime_type); | |
| 1028 | 1054 |
| 1029 char** arg_names = new char*[arg_names_.size()]; | 1055 bool ok = plugin_delegate->Initialize( |
| 1030 char** arg_values = new char*[arg_values_.size()]; | 1056 plugin_url_, arg_names_, arg_values_, arg_count_, this, load_manually_); |
| 1031 | 1057 |
| 1032 for (unsigned int index = 0; index < arg_names_.size(); ++index) { | 1058 if (!ok) { |
| 1033 arg_names[index] = const_cast<char*>(arg_names_[index].c_str()); | |
| 1034 arg_values[index] = const_cast<char*>(arg_values_[index].c_str()); | |
| 1035 } | |
| 1036 | |
| 1037 bool init_ok = plugin_delegate->Initialize(plugin_url_, arg_names, | |
| 1038 arg_values, arg_names_.size(), | |
| 1039 this, load_manually_); | |
| 1040 delete[] arg_names; | |
| 1041 delete[] arg_values; | |
| 1042 | |
| 1043 if (!init_ok) { | |
| 1044 container_ = NULL; | 1059 container_ = NULL; |
| 1045 // TODO(iyengar) Should we delete the current plugin instance here? | 1060 // TODO(iyengar) Should we delete the current plugin instance here? |
| 1046 return false; | 1061 return false; |
| 1047 } | 1062 } |
| 1048 | 1063 |
| 1049 mime_type_ = actual_mime_type; | 1064 mime_type_ = actual_mime_type; |
| 1050 delegate_ = plugin_delegate; | 1065 delegate_ = plugin_delegate; |
| 1051 | 1066 |
| 1052 // Force a geometry update to occur to ensure that the plugin becomes | 1067 // Force a geometry update to occur to ensure that the plugin becomes |
| 1053 // visible. TODO(darin): Avoid this cast! | 1068 // visible. |
| 1054 static_cast<WebPluginContainerImpl*>(container_)->frameRectsChanged(); | 1069 container_->reportGeometry(); |
| 1070 |
| 1055 // The plugin move sequences accumulated via DidMove are sent to the browser | 1071 // The plugin move sequences accumulated via DidMove are sent to the browser |
| 1056 // whenever the renderer paints. Force a paint here to ensure that changes | 1072 // whenever the renderer paints. Force a paint here to ensure that changes |
| 1057 // to the plugin window are propagated to the browser. | 1073 // to the plugin window are propagated to the browser. |
| 1058 container_->invalidate(); | 1074 container_->invalidate(); |
| 1059 return true; | 1075 return true; |
| 1060 } | 1076 } |
| 1061 | 1077 |
| 1062 void WebPluginImpl::ArrayToVector(int total_values, char** values, | |
| 1063 std::vector<std::string>* value_vector) { | |
| 1064 DCHECK(value_vector != NULL); | |
| 1065 for (int index = 0; index < total_values; ++index) { | |
| 1066 value_vector->push_back(values[index]); | |
| 1067 } | |
| 1068 } | |
| 1069 | |
| 1070 void WebPluginImpl::TearDownPluginInstance( | 1078 void WebPluginImpl::TearDownPluginInstance( |
| 1071 WebURLLoader* loader_to_ignore) { | 1079 WebURLLoader* loader_to_ignore) { |
| 1072 // The frame maintains a list of JSObjects which are related to this | 1080 // The container maintains a list of JSObjects which are related to this |
| 1073 // plugin. Tell the frame we're gone so that it can invalidate all | 1081 // plugin. Tell the frame we're gone so that it can invalidate all of |
| 1074 // of those sub JSObjects. | 1082 // those sub JSObjects. |
| 1075 if (frame()) { | 1083 if (container_) |
| 1076 ASSERT(container_); | 1084 container_->clearScriptObjects(); |
| 1077 // TODO(darin): Avoid this cast! | |
| 1078 frame()->script()->cleanupScriptObjectsForPlugin( | |
| 1079 static_cast<WebKit::WebPluginContainerImpl*>(container_)); | |
| 1080 } | |
| 1081 | 1085 |
| 1082 if (delegate_) { | 1086 if (delegate_) { |
| 1083 // Call PluginDestroyed() first to prevent the plugin from calling us back | 1087 // Call PluginDestroyed() first to prevent the plugin from calling us back |
| 1084 // in the middle of tearing down the render tree. | 1088 // in the middle of tearing down the render tree. |
| 1085 delegate_->PluginDestroyed(); | 1089 delegate_->PluginDestroyed(); |
| 1086 delegate_ = NULL; | 1090 delegate_ = NULL; |
| 1087 } | 1091 } |
| 1088 | 1092 |
| 1089 // Cancel any pending requests because otherwise this deleted object will | 1093 // Cancel any pending requests because otherwise this deleted object will |
| 1090 // be called by the ResourceDispatcher. | 1094 // be called by the ResourceDispatcher. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1102 | 1106 |
| 1103 client_index = clients_.erase(client_index); | 1107 client_index = clients_.erase(client_index); |
| 1104 } | 1108 } |
| 1105 | 1109 |
| 1106 // This needs to be called now and not in the destructor since the | 1110 // This needs to be called now and not in the destructor since the |
| 1107 // webframe_ might not be valid anymore. | 1111 // webframe_ might not be valid anymore. |
| 1108 webframe_ = NULL; | 1112 webframe_ = NULL; |
| 1109 method_factory_.RevokeAll(); | 1113 method_factory_.RevokeAll(); |
| 1110 } | 1114 } |
| 1111 | 1115 |
| 1112 WebViewDelegate* WebPluginImpl::GetWebViewDelegate() { | 1116 } // namespace webkit_glue |
| 1113 if (!webframe_) | |
| 1114 return NULL; | |
| 1115 WebViewImpl* webview = webframe_->GetWebViewImpl(); | |
| 1116 return webview ? webview->delegate() : NULL; | |
| 1117 } | |
| OLD | NEW |