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

Side by Side Diff: Source/modules/imagebitmap/ImageBitmapFactories.cpp

Issue 320843002: Safeguard for webMediaPlayer() access (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 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
« no previous file with comments | « no previous file | 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) 2013, Google Inc. All rights reserved. 2 * Copyright (c) 2013, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 { 117 {
118 IntSize s = sizeFor(video); 118 IntSize s = sizeFor(video);
119 return createImageBitmap(scriptState, eventTarget, video, 0, 0, s.width(), s .height(), exceptionState); 119 return createImageBitmap(scriptState, eventTarget, video, 0, 0, s.width(), s .height(), exceptionState);
120 } 120 }
121 121
122 ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState, EventTarget& eventTarget, HTMLVideoElement* video, int sx, int sy, int sw, int s h, ExceptionState& exceptionState) 122 ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState, EventTarget& eventTarget, HTMLVideoElement* video, int sx, int sy, int sw, int s h, ExceptionState& exceptionState)
123 { 123 {
124 // This variant does not work in worker threads. 124 // This variant does not work in worker threads.
125 ASSERT(eventTarget.toDOMWindow()); 125 ASSERT(eventTarget.toDOMWindow());
126 126
127 if (!video->webMediaPlayer()) {
128 exceptionState.throwDOMException(InvalidStateError, "No player can be re trieved from the provided video element.");
129 return ScriptPromise();
130 }
127 if (video->networkState() == HTMLMediaElement::NETWORK_EMPTY) { 131 if (video->networkState() == HTMLMediaElement::NETWORK_EMPTY) {
128 exceptionState.throwDOMException(InvalidStateError, "The provided elemen t has not retrieved data."); 132 exceptionState.throwDOMException(InvalidStateError, "The provided elemen t has not retrieved data.");
129 return ScriptPromise(); 133 return ScriptPromise();
130 } 134 }
131 if (video->readyState() <= HTMLMediaElement::HAVE_METADATA) { 135 if (video->readyState() <= HTMLMediaElement::HAVE_METADATA) {
acolwell GONE FROM CHROMIUM 2014/06/09 23:09:36 nit: I think you should probably just make the nul
Srirama 2014/06/10 05:50:25 Done.
132 exceptionState.throwDOMException(InvalidStateError, "The provided elemen t's player has no current data."); 136 exceptionState.throwDOMException(InvalidStateError, "The provided elemen t's player has no current data.");
133 return ScriptPromise(); 137 return ScriptPromise();
134 } 138 }
135 if (!sw || !sh) { 139 if (!sw || !sh) {
136 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width")); 140 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width"));
137 return ScriptPromise(); 141 return ScriptPromise();
138 } 142 }
139 if (!video->hasSingleSecurityOrigin()) { 143 if (!video->hasSingleSecurityOrigin()) {
140 exceptionState.throwSecurityError("The source video contains image data from multiple origins."); 144 exceptionState.throwSecurityError("The source video contains image data from multiple origins.");
141 return ScriptPromise(); 145 return ScriptPromise();
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 { 335 {
332 rejectPromise(); 336 rejectPromise();
333 } 337 }
334 338
335 void ImageBitmapFactories::ImageBitmapLoader::trace(Visitor* visitor) 339 void ImageBitmapFactories::ImageBitmapLoader::trace(Visitor* visitor)
336 { 340 {
337 visitor->trace(m_factory); 341 visitor->trace(m_factory);
338 } 342 }
339 343
340 } // namespace WebCore 344 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698