Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: Source/core/html/HTMLPlugInElement.cpp

Issue 76303002: CSP: Check <param> element values against the document's CSP before loading. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Async. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLPlugInElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10 matching lines...) Expand all
21 */ 21 */
22 22
23 #include "config.h" 23 #include "config.h"
24 #include "core/html/HTMLPlugInElement.h" 24 #include "core/html/HTMLPlugInElement.h"
25 25
26 #include "CSSPropertyNames.h" 26 #include "CSSPropertyNames.h"
27 #include "HTMLNames.h" 27 #include "HTMLNames.h"
28 #include "bindings/v8/ScriptController.h" 28 #include "bindings/v8/ScriptController.h"
29 #include "bindings/v8/npruntime_impl.h" 29 #include "bindings/v8/npruntime_impl.h"
30 #include "core/dom/Document.h" 30 #include "core/dom/Document.h"
31 #include "core/dom/Node.h"
31 #include "core/dom/PostAttachCallbacks.h" 32 #include "core/dom/PostAttachCallbacks.h"
32 #include "core/dom/shadow/ShadowRoot.h" 33 #include "core/dom/shadow/ShadowRoot.h"
33 #include "core/events/Event.h" 34 #include "core/events/Event.h"
34 #include "core/frame/ContentSecurityPolicy.h" 35 #include "core/frame/ContentSecurityPolicy.h"
35 #include "core/frame/Frame.h" 36 #include "core/frame/Frame.h"
36 #include "core/html/HTMLImageLoader.h" 37 #include "core/html/HTMLImageLoader.h"
37 #include "core/html/PluginDocument.h" 38 #include "core/html/PluginDocument.h"
38 #include "core/html/shadow/HTMLContentElement.h" 39 #include "core/html/shadow/HTMLContentElement.h"
39 #include "core/loader/FrameLoaderClient.h" 40 #include "core/loader/FrameLoaderClient.h"
40 #include "core/page/EventHandler.h" 41 #include "core/page/EventHandler.h"
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 if (url.isEmpty() && mimeType.isEmpty()) 404 if (url.isEmpty() && mimeType.isEmpty())
404 return false; 405 return false;
405 406
406 // FIXME: None of this code should use renderers! 407 // FIXME: None of this code should use renderers!
407 RenderEmbeddedObject* renderer = renderEmbeddedObject(); 408 RenderEmbeddedObject* renderer = renderEmbeddedObject();
408 ASSERT(renderer); 409 ASSERT(renderer);
409 if (!renderer) 410 if (!renderer)
410 return false; 411 return false;
411 412
412 KURL completedURL = document().completeURL(url); 413 KURL completedURL = document().completeURL(url);
414 if (!pluginIsLoadable(completedURL, mimeType))
415 return false;
413 416
414 bool useFallback; 417 bool useFallback;
415 if (shouldUsePlugin(completedURL, mimeType, renderer->hasFallbackContent(), useFallback)) 418 if (shouldUsePlugin(completedURL, mimeType, renderer->hasFallbackContent(), useFallback))
416 return loadPlugin(completedURL, mimeType, paramNames, paramValues, useFa llback); 419 return loadPlugin(completedURL, mimeType, paramNames, paramValues, useFa llback);
417 420
418 // If the plug-in element already contains a subframe, 421 // If the plug-in element already contains a subframe,
419 // loadOrRedirectSubframe will re-use it. Otherwise, it will create a new 422 // loadOrRedirectSubframe will re-use it. Otherwise, it will create a new
420 // frame and set it as the RenderPart's widget, causing what was previously 423 // frame and set it as the RenderPart's widget, causing what was previously
421 // in the widget to be torn down. 424 // in the widget to be torn down.
422 return loadOrRedirectSubframe(completedURL, getNameAttribute(), true); 425 return loadOrRedirectSubframe(completedURL, getNameAttribute(), true);
423 } 426 }
424 427
425 bool HTMLPlugInElement::loadPlugin(const KURL& url, const String& mimeType, cons t Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallbac k) 428 bool HTMLPlugInElement::loadPlugin(const KURL& url, const String& mimeType, cons t Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallbac k)
426 { 429 {
427 Frame* frame = document().frame(); 430 Frame* frame = document().frame();
428 431
429 if (!frame->loader().allowPlugins(AboutToInstantiatePlugin)) 432 if (!frame->loader().allowPlugins(AboutToInstantiatePlugin))
430 return false; 433 return false;
431 434
432 if (!pluginIsLoadable(url, mimeType))
433 return false;
434
435 RenderEmbeddedObject* renderer = renderEmbeddedObject(); 435 RenderEmbeddedObject* renderer = renderEmbeddedObject();
436 // FIXME: This code should not depend on renderer! 436 // FIXME: This code should not depend on renderer!
437 if (!renderer || useFallback) 437 if (!renderer || useFallback)
438 return false; 438 return false;
439 439
440 WTF_LOG(Plugins, "%p Plug-in URL: %s", this, m_url.utf8().data()); 440 WTF_LOG(Plugins, "%p Plug-in URL: %s", this, m_url.utf8().data());
441 WTF_LOG(Plugins, " Loaded URL: %s", url.string().utf8().data()); 441 WTF_LOG(Plugins, " Loaded URL: %s", url.string().utf8().data());
442 m_loadedUrl = url; 442 m_loadedUrl = url;
443 443
444 IntSize contentSize = roundedIntSize(LayoutSize(renderer->contentWidth(), re nderer->contentHeight())); 444 IntSize contentSize = roundedIntSize(LayoutSize(renderer->contentWidth(), re nderer->contentHeight()));
(...skipping 25 matching lines...) Expand all
470 } 470 }
471 471
472 ObjectContentType objectType = document().frame()->loader().client()->object ContentType(url, mimeType, shouldPreferPlugInsForImages()); 472 ObjectContentType objectType = document().frame()->loader().client()->object ContentType(url, mimeType, shouldPreferPlugInsForImages());
473 // If an object's content can't be handled and it has no fallback, let 473 // If an object's content can't be handled and it has no fallback, let
474 // it be handled as a plugin to show the broken plugin icon. 474 // it be handled as a plugin to show the broken plugin icon.
475 useFallback = objectType == ObjectContentNone && hasFallback; 475 useFallback = objectType == ObjectContentNone && hasFallback;
476 return objectType == ObjectContentNone || objectType == ObjectContentNetscap ePlugin || objectType == ObjectContentOtherPlugin; 476 return objectType == ObjectContentNone || objectType == ObjectContentNetscap ePlugin || objectType == ObjectContentOtherPlugin;
477 477
478 } 478 }
479 479
480 void HTMLPlugInElement::dispatchErrorEvent()
481 {
482 if (document().isPluginDocument() && document().ownerElement())
483 document().ownerElement()->dispatchEvent(Event::create(EventTypeNames::e rror));
484 else
485 dispatchEvent(Event::create(EventTypeNames::error));
486 }
487
480 bool HTMLPlugInElement::pluginIsLoadable(const KURL& url, const String& mimeType ) 488 bool HTMLPlugInElement::pluginIsLoadable(const KURL& url, const String& mimeType )
481 { 489 {
482 Frame* frame = document().frame(); 490 Frame* frame = document().frame();
483 Settings* settings = frame->settings(); 491 Settings* settings = frame->settings();
484 if (!settings) 492 if (!settings)
485 return false; 493 return false;
486 494
487 if (MIMETypeRegistry::isJavaAppletMIMEType(mimeType) && !settings->javaEnabl ed()) 495 if (MIMETypeRegistry::isJavaAppletMIMEType(mimeType) && !settings->javaEnabl ed())
488 return false; 496 return false;
489 497
(...skipping 27 matching lines...) Expand all
517 if (root.isOldestAuthorShadowRoot()) 525 if (root.isOldestAuthorShadowRoot())
518 lazyReattachIfAttached(); 526 lazyReattachIfAttached();
519 } 527 }
520 528
521 bool HTMLPlugInElement::useFallbackContent() const 529 bool HTMLPlugInElement::useFallbackContent() const
522 { 530 {
523 return hasAuthorShadowRoot(); 531 return hasAuthorShadowRoot();
524 } 532 }
525 533
526 } 534 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLPlugInElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698