| OLD | NEW | 
|---|
| 1 /** | 1 /** | 
| 2  * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2  * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 
| 3  *           (C) 1999 Antti Koivisto (koivisto@kde.org) | 3  *           (C) 1999 Antti Koivisto (koivisto@kde.org) | 
| 4  *           (C) 2000 Stefan Schimanski (1Stein@gmx.de) | 4  *           (C) 2000 Stefan Schimanski (1Stein@gmx.de) | 
| 5  * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. | 5  * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. | 
| 6  * | 6  * | 
| 7  * This library is free software; you can redistribute it and/or | 7  * This library is free software; you can redistribute it and/or | 
| 8  * modify it under the terms of the GNU Library General Public | 8  * modify it under the terms of the GNU Library General Public | 
| 9  * License as published by the Free Software Foundation; either | 9  * License as published by the Free Software Foundation; either | 
| 10  * version 2 of the License, or (at your option) any later version. | 10  * version 2 of the License, or (at your option) any later version. | 
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 111 } | 111 } | 
| 112 | 112 | 
| 113 void HTMLPlugInElement::SetFocused(bool focused, WebFocusType focus_type) { | 113 void HTMLPlugInElement::SetFocused(bool focused, WebFocusType focus_type) { | 
| 114   PluginView* plugin = OwnedPlugin(); | 114   PluginView* plugin = OwnedPlugin(); | 
| 115   if (plugin) | 115   if (plugin) | 
| 116     plugin->SetFocused(focused, focus_type); | 116     plugin->SetFocused(focused, focus_type); | 
| 117   HTMLFrameOwnerElement::SetFocused(focused, focus_type); | 117   HTMLFrameOwnerElement::SetFocused(focused, focus_type); | 
| 118 } | 118 } | 
| 119 | 119 | 
| 120 bool HTMLPlugInElement::RequestObjectInternal( | 120 bool HTMLPlugInElement::RequestObjectInternal( | 
|  | 121     const String& url, | 
|  | 122     const String& mime_type, | 
| 121     const Vector<String>& param_names, | 123     const Vector<String>& param_names, | 
| 122     const Vector<String>& param_values) { | 124     const Vector<String>& param_values) { | 
| 123   if (url_.IsEmpty() && service_type_.IsEmpty()) | 125   if (url.IsEmpty() && mime_type.IsEmpty()) | 
| 124     return false; | 126     return false; | 
| 125 | 127 | 
| 126   if (ProtocolIsJavaScript(url_)) | 128   if (ProtocolIsJavaScript(url)) | 
| 127     return false; | 129     return false; | 
| 128 | 130 | 
| 129   KURL completed_url = | 131   KURL completed_url = url.IsEmpty() ? KURL() : GetDocument().CompleteURL(url); | 
| 130       url_.IsEmpty() ? KURL() : GetDocument().CompleteURL(url_); | 132   if (!AllowedToLoadObject(completed_url, mime_type)) | 
| 131   if (!AllowedToLoadObject(completed_url, service_type_)) |  | 
| 132     return false; | 133     return false; | 
| 133 | 134 | 
| 134   ObjectContentType object_type = GetObjectContentType(); | 135   bool use_fallback; | 
| 135   if (object_type == ObjectContentType::kFrame || | 136   if (!ShouldUsePlugin(completed_url, mime_type, HasFallbackContent(), | 
| 136       object_type == ObjectContentType::kImage) { | 137                        use_fallback)) { | 
| 137     // If the plugin element already contains a subframe, | 138     // If the plugin element already contains a subframe, | 
| 138     // loadOrRedirectSubframe will re-use it. Otherwise, it will create a | 139     // loadOrRedirectSubframe will re-use it. Otherwise, it will create a | 
| 139     // new frame and set it as the LayoutEmbeddedContent's EmbeddedContentView, | 140     // new frame and set it as the LayoutEmbeddedContent's EmbeddedContentView, | 
| 140     // causing what was previously in the EmbeddedContentView to be torn down. | 141     // causing what was previously in the EmbeddedContentView to be torn down. | 
| 141     return LoadOrRedirectSubframe(completed_url, GetNameAttribute(), true); | 142     return LoadOrRedirectSubframe(completed_url, GetNameAttribute(), true); | 
| 142   } | 143   } | 
| 143 | 144 | 
| 144   // If an object's content can't be handled and it has no fallback, let | 145   return LoadPlugin(completed_url, mime_type, param_names, param_values, | 
| 145   // it be handled as a plugin to show the broken plugin icon. |  | 
| 146   bool use_fallback = |  | 
| 147       object_type == ObjectContentType::kNone && HasFallbackContent(); |  | 
| 148   return LoadPlugin(completed_url, service_type_, param_names, param_values, |  | 
| 149                     use_fallback, true); | 146                     use_fallback, true); | 
| 150 } | 147 } | 
| 151 | 148 | 
| 152 bool HTMLPlugInElement::CanProcessDrag() const { | 149 bool HTMLPlugInElement::CanProcessDrag() const { | 
| 153   return PluginEmbeddedContentView() && | 150   return PluginEmbeddedContentView() && | 
| 154          PluginEmbeddedContentView()->CanProcessDrag(); | 151          PluginEmbeddedContentView()->CanProcessDrag(); | 
| 155 } | 152 } | 
| 156 | 153 | 
| 157 bool HTMLPlugInElement::CanStartSelection() const { | 154 bool HTMLPlugInElement::CanStartSelection() const { | 
| 158   return UseFallbackContent() && Node::CanStartSelection(); | 155   return UseFallbackContent() && Node::CanStartSelection(); | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 190     } | 187     } | 
| 191     return; | 188     return; | 
| 192   } | 189   } | 
| 193 | 190 | 
| 194   if (IsImageType()) { | 191   if (IsImageType()) { | 
| 195     if (!image_loader_) | 192     if (!image_loader_) | 
| 196       image_loader_ = HTMLImageLoader::Create(this); | 193       image_loader_ = HTMLImageLoader::Create(this); | 
| 197     image_loader_->UpdateFromElement(); | 194     image_loader_->UpdateFromElement(); | 
| 198   } else if (NeedsPluginUpdate() && !GetLayoutEmbeddedItem().IsNull() && | 195   } else if (NeedsPluginUpdate() && !GetLayoutEmbeddedItem().IsNull() && | 
| 199              !GetLayoutEmbeddedItem().ShowsUnavailablePluginIndicator() && | 196              !GetLayoutEmbeddedItem().ShowsUnavailablePluginIndicator() && | 
| 200              GetObjectContentType() != ObjectContentType::kPlugin && | 197              !WouldLoadAsNetscapePlugin(url_, service_type_) && | 
| 201              !is_delaying_load_event_) { | 198              !is_delaying_load_event_) { | 
| 202     is_delaying_load_event_ = true; | 199     is_delaying_load_event_ = true; | 
| 203     GetDocument().IncrementLoadEventDelayCount(); | 200     GetDocument().IncrementLoadEventDelayCount(); | 
| 204     GetDocument().LoadPluginsSoon(); | 201     GetDocument().LoadPluginsSoon(); | 
| 205   } | 202   } | 
| 206 } | 203 } | 
| 207 | 204 | 
| 208 void HTMLPlugInElement::UpdatePlugin() { | 205 void HTMLPlugInElement::UpdatePlugin() { | 
| 209   UpdatePluginInternal(); | 206   UpdatePluginInternal(); | 
| 210   if (is_delaying_load_event_) { | 207   if (is_delaying_load_event_) { | 
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 465 bool HTMLPlugInElement::LayoutObjectIsFocusable() const { | 462 bool HTMLPlugInElement::LayoutObjectIsFocusable() const { | 
| 466   if (HTMLFrameOwnerElement::SupportsFocus() && | 463   if (HTMLFrameOwnerElement::SupportsFocus() && | 
| 467       HTMLFrameOwnerElement::LayoutObjectIsFocusable()) | 464       HTMLFrameOwnerElement::LayoutObjectIsFocusable()) | 
| 468     return true; | 465     return true; | 
| 469 | 466 | 
| 470   if (UseFallbackContent() || !HTMLFrameOwnerElement::LayoutObjectIsFocusable()) | 467   if (UseFallbackContent() || !HTMLFrameOwnerElement::LayoutObjectIsFocusable()) | 
| 471     return false; | 468     return false; | 
| 472   return plugin_is_available_; | 469   return plugin_is_available_; | 
| 473 } | 470 } | 
| 474 | 471 | 
| 475 HTMLPlugInElement::ObjectContentType HTMLPlugInElement::GetObjectContentType() { |  | 
| 476   String mime_type = service_type_; |  | 
| 477   KURL url = GetDocument().CompleteURL(url_); |  | 
| 478   if (mime_type.IsEmpty()) { |  | 
| 479     // Try to guess the MIME type based off the extension. |  | 
| 480     String filename = url.LastPathComponent(); |  | 
| 481     int extension_pos = filename.ReverseFind('.'); |  | 
| 482     if (extension_pos >= 0) { |  | 
| 483       String extension = filename.Substring(extension_pos + 1); |  | 
| 484       mime_type = MIMETypeRegistry::GetWellKnownMIMETypeForExtension(extension); |  | 
| 485     } |  | 
| 486 |  | 
| 487     if (mime_type.IsEmpty()) |  | 
| 488       return ObjectContentType::kFrame; |  | 
| 489   } |  | 
| 490 |  | 
| 491   // If Chrome is started with the --disable-plugins switch, pluginData is 0. |  | 
| 492   PluginData* plugin_data = GetDocument().GetFrame()->GetPluginData(); |  | 
| 493   bool plugin_supports_mime_type = |  | 
| 494       plugin_data && plugin_data->SupportsMimeType(mime_type); |  | 
| 495 |  | 
| 496   if (MIMETypeRegistry::IsSupportedImageMIMEType(mime_type)) { |  | 
| 497     return should_prefer_plug_ins_for_images_ && plugin_supports_mime_type |  | 
| 498                ? ObjectContentType::kPlugin |  | 
| 499                : ObjectContentType::kImage; |  | 
| 500   } |  | 
| 501 |  | 
| 502   if (plugin_supports_mime_type) |  | 
| 503     return ObjectContentType::kPlugin; |  | 
| 504   if (MIMETypeRegistry::IsSupportedNonImageMIMEType(mime_type)) |  | 
| 505     return ObjectContentType::kFrame; |  | 
| 506   return ObjectContentType::kNone; |  | 
| 507 } |  | 
| 508 |  | 
| 509 bool HTMLPlugInElement::IsImageType() { | 472 bool HTMLPlugInElement::IsImageType() { | 
| 510   if (service_type_.IsEmpty() && ProtocolIs(url_, "data")) | 473   if (service_type_.IsEmpty() && ProtocolIs(url_, "data")) | 
| 511     service_type_ = MimeTypeFromDataURL(url_); | 474     service_type_ = MimeTypeFromDataURL(url_); | 
| 512 | 475 | 
| 513   if (GetDocument().GetFrame()) | 476   if (LocalFrame* frame = GetDocument().GetFrame()) { | 
| 514     return GetObjectContentType() == ObjectContentType::kImage; | 477     KURL completed_url = GetDocument().CompleteURL(url_); | 
|  | 478     return frame->Loader().Client()->GetObjectContentType( | 
|  | 479                completed_url, service_type_, ShouldPreferPlugInsForImages()) == | 
|  | 480            kObjectContentImage; | 
|  | 481   } | 
|  | 482 | 
| 515   return Image::SupportsType(service_type_); | 483   return Image::SupportsType(service_type_); | 
| 516 } | 484 } | 
| 517 | 485 | 
| 518 LayoutEmbeddedItem HTMLPlugInElement::GetLayoutEmbeddedItem() const { | 486 LayoutEmbeddedItem HTMLPlugInElement::GetLayoutEmbeddedItem() const { | 
| 519   // HTMLObjectElement and HTMLEmbedElement may return arbitrary layoutObjects | 487   // HTMLObjectElement and HTMLEmbedElement may return arbitrary layoutObjects | 
| 520   // when using fallback content. | 488   // when using fallback content. | 
| 521   if (!GetLayoutObject() || !GetLayoutObject()->IsEmbeddedObject()) | 489   if (!GetLayoutObject() || !GetLayoutObject()->IsEmbeddedObject()) | 
| 522     return LayoutEmbeddedItem(nullptr); | 490     return LayoutEmbeddedItem(nullptr); | 
| 523   return LayoutEmbeddedItem(ToLayoutEmbeddedObject(GetLayoutObject())); | 491   return LayoutEmbeddedItem(ToLayoutEmbeddedObject(GetLayoutObject())); | 
| 524 } | 492 } | 
| 525 | 493 | 
| 526 // We don't use m_url, as it may not be the final URL that the object loads, | 494 // We don't use m_url, as it may not be the final URL that the object loads, | 
| 527 // depending on <param> values. | 495 // depending on <param> values. | 
| 528 bool HTMLPlugInElement::AllowedToLoadFrameURL(const String& url) { | 496 bool HTMLPlugInElement::AllowedToLoadFrameURL(const String& url) { | 
| 529   KURL complete_url = GetDocument().CompleteURL(url); | 497   KURL complete_url = GetDocument().CompleteURL(url); | 
| 530   return !(ContentFrame() && complete_url.ProtocolIsJavaScript() && | 498   return !(ContentFrame() && complete_url.ProtocolIsJavaScript() && | 
| 531            !GetDocument().GetSecurityOrigin()->CanAccess( | 499            !GetDocument().GetSecurityOrigin()->CanAccess( | 
| 532                ContentFrame()->GetSecurityContext()->GetSecurityOrigin())); | 500                ContentFrame()->GetSecurityContext()->GetSecurityOrigin())); | 
| 533 } | 501 } | 
| 534 | 502 | 
| 535 bool HTMLPlugInElement::RequestObject(const Vector<String>& param_names, | 503 // We don't use m_url, or m_serviceType as they may not be the final values | 
|  | 504 // that <object> uses depending on <param> values. | 
|  | 505 bool HTMLPlugInElement::WouldLoadAsNetscapePlugin(const String& url, | 
|  | 506                                                   const String& service_type) { | 
|  | 507   DCHECK(GetDocument().GetFrame()); | 
|  | 508   KURL completed_url; | 
|  | 509   if (!url.IsEmpty()) | 
|  | 510     completed_url = GetDocument().CompleteURL(url); | 
|  | 511   return GetDocument().GetFrame()->Loader().Client()->GetObjectContentType( | 
|  | 512              completed_url, service_type, ShouldPreferPlugInsForImages()) == | 
|  | 513          kObjectContentNetscapePlugin; | 
|  | 514 } | 
|  | 515 | 
|  | 516 bool HTMLPlugInElement::RequestObject(const String& url, | 
|  | 517                                       const String& mime_type, | 
|  | 518                                       const Vector<String>& param_names, | 
| 536                                       const Vector<String>& param_values) { | 519                                       const Vector<String>& param_values) { | 
| 537   bool result = RequestObjectInternal(param_names, param_values); | 520   bool result = | 
|  | 521       RequestObjectInternal(url, mime_type, param_names, param_values); | 
| 538 | 522 | 
| 539   DEFINE_STATIC_LOCAL( | 523   DEFINE_STATIC_LOCAL( | 
| 540       EnumerationHistogram, result_histogram, | 524       EnumerationHistogram, result_histogram, | 
| 541       ("Plugin.RequestObjectResult", kPluginRequestObjectResultMax)); | 525       ("Plugin.RequestObjectResult", kPluginRequestObjectResultMax)); | 
| 542   result_histogram.Count(result ? kPluginRequestObjectResultSuccess | 526   result_histogram.Count(result ? kPluginRequestObjectResultSuccess | 
| 543                                 : kPluginRequestObjectResultFailure); | 527                                 : kPluginRequestObjectResultFailure); | 
| 544 | 528 | 
| 545   return result; | 529   return result; | 
| 546 } | 530 } | 
| 547 | 531 | 
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 602   // Make sure any input event handlers introduced by the plugin are taken into | 586   // Make sure any input event handlers introduced by the plugin are taken into | 
| 603   // account. | 587   // account. | 
| 604   if (Page* page = GetDocument().GetFrame()->GetPage()) { | 588   if (Page* page = GetDocument().GetFrame()->GetPage()) { | 
| 605     if (ScrollingCoordinator* scrolling_coordinator = | 589     if (ScrollingCoordinator* scrolling_coordinator = | 
| 606             page->GetScrollingCoordinator()) | 590             page->GetScrollingCoordinator()) | 
| 607       scrolling_coordinator->NotifyGeometryChanged(); | 591       scrolling_coordinator->NotifyGeometryChanged(); | 
| 608   } | 592   } | 
| 609   return true; | 593   return true; | 
| 610 } | 594 } | 
| 611 | 595 | 
|  | 596 bool HTMLPlugInElement::ShouldUsePlugin(const KURL& url, | 
|  | 597                                         const String& mime_type, | 
|  | 598                                         bool has_fallback, | 
|  | 599                                         bool& use_fallback) { | 
|  | 600   ObjectContentType object_type = | 
|  | 601       GetDocument().GetFrame()->Loader().Client()->GetObjectContentType( | 
|  | 602           url, mime_type, ShouldPreferPlugInsForImages()); | 
|  | 603   // If an object's content can't be handled and it has no fallback, let | 
|  | 604   // it be handled as a plugin to show the broken plugin icon. | 
|  | 605   use_fallback = object_type == kObjectContentNone && has_fallback; | 
|  | 606   return object_type == kObjectContentNone || | 
|  | 607          object_type == kObjectContentNetscapePlugin; | 
|  | 608 } | 
|  | 609 | 
| 612 void HTMLPlugInElement::DispatchErrorEvent() { | 610 void HTMLPlugInElement::DispatchErrorEvent() { | 
| 613   if (GetDocument().IsPluginDocument() && GetDocument().LocalOwner()) | 611   if (GetDocument().IsPluginDocument() && GetDocument().LocalOwner()) | 
| 614     GetDocument().LocalOwner()->DispatchEvent( | 612     GetDocument().LocalOwner()->DispatchEvent( | 
| 615         Event::Create(EventTypeNames::error)); | 613         Event::Create(EventTypeNames::error)); | 
| 616   else | 614   else | 
| 617     DispatchEvent(Event::Create(EventTypeNames::error)); | 615     DispatchEvent(Event::Create(EventTypeNames::error)); | 
| 618 } | 616 } | 
| 619 | 617 | 
| 620 bool HTMLPlugInElement::AllowedToLoadObject(const KURL& url, | 618 bool HTMLPlugInElement::AllowedToLoadObject(const KURL& url, | 
| 621                                             const String& mime_type) { | 619                                             const String& mime_type) { | 
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 678 | 676 | 
| 679 void HTMLPlugInElement::LazyReattachIfNeeded() { | 677 void HTMLPlugInElement::LazyReattachIfNeeded() { | 
| 680   if (!UseFallbackContent() && NeedsPluginUpdate() && GetLayoutObject() && | 678   if (!UseFallbackContent() && NeedsPluginUpdate() && GetLayoutObject() && | 
| 681       !IsImageType()) { | 679       !IsImageType()) { | 
| 682     LazyReattachIfAttached(); | 680     LazyReattachIfAttached(); | 
| 683     SetPersistedPlugin(nullptr); | 681     SetPersistedPlugin(nullptr); | 
| 684   } | 682   } | 
| 685 } | 683 } | 
| 686 | 684 | 
| 687 }  // namespace blink | 685 }  // namespace blink | 
| OLD | NEW | 
|---|