diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/core/html/html_plugin_element.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/core/html/html_plugin_element.cc | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/chromium/third_party/blink/renderer/core/html/html_plugin_element.cc b/chromium/third_party/blink/renderer/core/html/html_plugin_element.cc index 16a0c13eba1..a1564b5d615 100644 --- a/chromium/third_party/blink/renderer/core/html/html_plugin_element.cc +++ b/chromium/third_party/blink/renderer/core/html/html_plugin_element.cc @@ -23,6 +23,7 @@ #include "third_party/blink/renderer/core/html/html_plugin_element.h" #include "third_party/blink/public/mojom/feature_policy/feature_policy.mojom-blink.h" +#include "third_party/blink/public/mojom/feature_policy/policy_value.mojom-blink-forward.h" #include "third_party/blink/public/mojom/loader/request_context_frame_type.mojom-blink.h" #include "third_party/blink/public/platform/web_url_request.h" #include "third_party/blink/renderer/bindings/core/v8/script_controller.h" @@ -52,7 +53,7 @@ #include "third_party/blink/renderer/core/page/plugin_data.h" #include "third_party/blink/renderer/core/page/scrolling/scrolling_coordinator.h" #include "third_party/blink/renderer/platform/bindings/v8_per_isolate_data.h" -#include "third_party/blink/renderer/platform/instrumentation/histogram.h" +#include "third_party/blink/renderer/platform/heap/heap.h" #include "third_party/blink/renderer/platform/instrumentation/use_counter.h" #include "third_party/blink/renderer/platform/loader/fetch/resource_request.h" #include "third_party/blink/renderer/platform/network/mime/mime_type_from_url.h" @@ -94,12 +95,22 @@ void PluginParameters::AppendNameWithValue(const String& name, values_.push_back(value); } -int PluginParameters::FindStringInNames(const String& str) { - for (wtf_size_t i = 0; i < names_.size(); ++i) { - if (DeprecatedEqualIgnoringCase(names_[i], str)) - return i; +void PluginParameters::MapDataParamToSrc() { + auto* src = std::find_if(names_.begin(), names_.end(), [](auto name) { + return EqualIgnoringASCIICase(name, "src"); + }); + + if (src != names_.end()) { + return; + } + + auto* data = std::find_if(names_.begin(), names_.end(), [](auto name) { + return EqualIgnoringASCIICase(name, "data"); + }); + + if (data != names_.end()) { + AppendNameWithValue("src", values_[data - names_.begin()]); } - return -1; } HTMLPlugInElement::HTMLPlugInElement( @@ -149,7 +160,8 @@ void HTMLPlugInElement::SetPersistedPlugin(WebPluginContainerImpl* plugin) { persisted_plugin_ = plugin; } -void HTMLPlugInElement::SetFocused(bool focused, WebFocusType focus_type) { +void HTMLPlugInElement::SetFocused(bool focused, + mojom::blink::FocusType focus_type) { WebPluginContainerImpl* plugin = OwnedPlugin(); if (plugin) plugin->SetFocused(focused, focus_type); @@ -228,7 +240,7 @@ void HTMLPlugInElement::AttachLayoutTree(AttachContext& context) { ToLayoutImage(layout_object)->ImageResource(); image_resource->SetImageResource(image_loader_->GetContent()); } - if (!layout_object->IsFloatingOrOutOfFlowPositioned()) + if (layout_object->AffectsWhitespaceSiblings()) context.previous_in_flow = layout_object; dispose_view_ = false; @@ -269,7 +281,8 @@ ParsedFeaturePolicy HTMLPlugInElement::ConstructContainerPolicy( // https://fullscreen.spec.whatwg.org/#model ParsedFeaturePolicy container_policy; ParsedFeaturePolicyDeclaration allowlist( - mojom::FeaturePolicyFeature::kFullscreen, mojom::PolicyValueType::kBool); + mojom::blink::FeaturePolicyFeature::kFullscreen, + mojom::blink::PolicyValueType::kBool); container_policy.push_back(allowlist); return container_policy; } @@ -291,7 +304,8 @@ void HTMLPlugInElement::DetachLayoutTree(bool performing_reattach) { // Only try to persist a plugin we actually own. WebPluginContainerImpl* plugin = OwnedPlugin(); if (plugin && keep_plugin) { - SetPersistedPlugin(ToWebPluginContainerImpl(ReleaseEmbeddedContentView())); + SetPersistedPlugin( + To<WebPluginContainerImpl>(ReleaseEmbeddedContentView())); } else { // A persisted plugin isn't processed and hooked up immediately // (synchronously) when attaching the layout object, so it's possible that @@ -391,7 +405,7 @@ WebPluginContainerImpl* HTMLPlugInElement::PluginEmbeddedContentView() const { WebPluginContainerImpl* HTMLPlugInElement::OwnedPlugin() const { EmbeddedContentView* view = OwnedEmbeddedContentView(); if (view && view->IsPluginView()) - return ToWebPluginContainerImpl(view); + return To<WebPluginContainerImpl>(view); return nullptr; } @@ -458,7 +472,7 @@ LayoutEmbeddedContent* HTMLPlugInElement::LayoutEmbeddedContentForJSBindings() // Needs to load the plugin immediatedly because this function is called // when JavaScript code accesses the plugin. // FIXME: Check if dispatching events here is safe. - GetDocument().UpdateStyleAndLayout(); + GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kJavaScript); if (auto* view = GetDocument().View()) view->FlushAnyPendingPostLayoutTasks(); @@ -642,7 +656,7 @@ bool HTMLPlugInElement::LoadPlugin(const KURL& url, layout_object->GetFrameView()->AddPlugin(plugin); } else { bool load_manually = - GetDocument().IsPluginDocument() && !GetDocument().ContainsPlugins(); + IsA<PluginDocument>(GetDocument()) && !GetDocument().ContainsPlugins(); WebPluginContainerImpl* plugin = frame->Client()->CreatePlugin( *this, url, plugin_params.Names(), plugin_params.Values(), mime_type, load_manually); @@ -676,7 +690,7 @@ bool HTMLPlugInElement::LoadPlugin(const KURL& url, } void HTMLPlugInElement::DispatchErrorEvent() { - if (GetDocument().IsPluginDocument() && GetDocument().LocalOwner()) { + if (IsA<PluginDocument>(GetDocument()) && GetDocument().LocalOwner()) { GetDocument().LocalOwner()->DispatchEvent( *Event::Create(event_type_names::kError)); } else { @@ -718,14 +732,14 @@ bool HTMLPlugInElement::AllowedToLoadObject(const KURL& url, bool HTMLPlugInElement::AllowedToLoadPlugin(const KURL& url, const String& mime_type) { - if (GetDocument().IsSandboxed(WebSandboxFlags::kPlugins)) { - GetDocument().AddConsoleMessage( - ConsoleMessage::Create(mojom::ConsoleMessageSource::kSecurity, - mojom::ConsoleMessageLevel::kError, - "Failed to load '" + url.ElidedString() + - "' as a plugin, because the " - "frame into which the plugin " - "is loading is sandboxed.")); + if (GetDocument().IsSandboxed(mojom::blink::WebSandboxFlags::kPlugins)) { + GetDocument().AddConsoleMessage(MakeGarbageCollected<ConsoleMessage>( + mojom::ConsoleMessageSource::kSecurity, + mojom::ConsoleMessageLevel::kError, + "Failed to load '" + url.ElidedString() + + "' as a plugin, because the " + "frame into which the plugin " + "is loading is sandboxed.")); return false; } return true; |