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

Unified Diff: Source/core/html/canvas/CanvasRenderingContext.cpp

Issue 297293004: Adding cache for security origin validations in 2D/WebGL canvases (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: reorganized code Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/html/canvas/CanvasRenderingContext.cpp
diff --git a/Source/core/html/canvas/CanvasRenderingContext.cpp b/Source/core/html/canvas/CanvasRenderingContext.cpp
index b2cb6faf378fba6f750699a91da7950620099134..9e5dd350d8f463efb01aa0f5525460e584bfae0a 100644
--- a/Source/core/html/canvas/CanvasRenderingContext.cpp
+++ b/Source/core/html/canvas/CanvasRenderingContext.cpp
@@ -26,6 +26,7 @@
#include "config.h"
#include "core/html/canvas/CanvasRenderingContext.h"
+#include "core/html/canvas/CanvasImageSource.h"
#include "platform/weborigin/SecurityOrigin.h"
namespace WebCore {
@@ -36,4 +37,27 @@ CanvasRenderingContext::CanvasRenderingContext(HTMLCanvasElement* canvas)
}
+bool CanvasRenderingContext::wouldTaintOrigin(CanvasImageSource* imageSource)
+{
+ const KURL& sourceURL = imageSource->sourceURL();
+ bool hasURL = (sourceURL.isValid() && !sourceURL.isAboutBlankURL());
+
+ if (hasURL) {
+ if (sourceURL.protocolIsData() || m_cleanURLs.contains(sourceURL.string()))
+ return false;
+ if (m_dirtyURLs.contains(sourceURL.string()))
+ return true;
+ }
+
+ bool taintOrigin = imageSource->wouldTaintOrigin(canvas()->securityOrigin());
+
+ if (hasURL) {
+ if (taintOrigin)
+ m_dirtyURLs.add(sourceURL.string());
+ else
+ m_cleanURLs.add(sourceURL.string());
+ }
+ return taintOrigin;
+}
+
} // namespace WebCore
« no previous file with comments | « Source/core/html/canvas/CanvasRenderingContext.h ('k') | Source/core/html/canvas/CanvasRenderingContext2D.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698