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

Side by Side Diff: third_party/WebKit/Source/modules/imagecapture/ImageCapture.cpp

Issue 2819233002: Image Capture: Reject applyConstraints() if passed an unsupported constraint (Closed)
Patch Set: Created 3 years, 8 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 | « third_party/WebKit/LayoutTests/imagecapture/MediaStreamTrack-getCapabilities.html ('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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/imagecapture/ImageCapture.h" 5 #include "modules/imagecapture/ImageCapture.h"
6 6
7 #include "bindings/core/v8/CallbackPromiseAdapter.h" 7 #include "bindings/core/v8/CallbackPromiseAdapter.h"
8 #include "bindings/core/v8/ScriptPromiseResolver.h" 8 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "core/dom/DOMException.h" 9 #include "core/dom/DOMException.h"
10 #include "core/dom/ExceptionCode.h" 10 #include "core/dom/ExceptionCode.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 const HeapVector<MediaTrackConstraintSet>& constraints_vector) { 254 const HeapVector<MediaTrackConstraintSet>& constraints_vector) {
255 if (!service_) { 255 if (!service_) {
256 resolver->Reject(DOMException::Create(kNotFoundError, kNoServiceError)); 256 resolver->Reject(DOMException::Create(kNotFoundError, kNoServiceError));
257 return; 257 return;
258 } 258 }
259 service_requests_.insert(resolver); 259 service_requests_.insert(resolver);
260 260
261 // TODO(mcasas): add support more than one single advanced constraint. 261 // TODO(mcasas): add support more than one single advanced constraint.
262 const auto constraints = constraints_vector[0]; 262 const auto constraints = constraints_vector[0];
263 263
264 if ((constraints.hasWhiteBalanceMode() &&
265 !capabilities_.hasWhiteBalanceMode()) ||
266 (constraints.hasExposureMode() && !capabilities_.hasExposureMode()) ||
267 (constraints.hasFocusMode() && !capabilities_.hasFocusMode()) ||
268 (constraints.hasExposureCompensation() &&
269 !capabilities_.hasExposureCompensation()) ||
270 (constraints.hasColorTemperature() &&
271 !capabilities_.hasColorTemperature()) ||
272 (constraints.hasIso() && !capabilities_.hasIso()) ||
273 (constraints.hasBrightness() && !capabilities_.hasBrightness()) ||
274 (constraints.hasContrast() && !capabilities_.hasContrast()) ||
275 (constraints.hasSaturation() && !capabilities_.hasSaturation()) ||
276 (constraints.hasSharpness() && !capabilities_.hasSharpness()) ||
277 (constraints.hasZoom() && !capabilities_.hasZoom()) ||
278 (constraints.hasTorch() && !capabilities_.hasTorch())) {
279 resolver->Reject(
280 DOMException::Create(kNotSupportedError, "Unsupported constraint(s)"));
281 return;
282 }
283
264 auto settings = media::mojom::blink::PhotoSettings::New(); 284 auto settings = media::mojom::blink::PhotoSettings::New();
265 285
266 // TODO(mcasas): support other Mode types beyond simple string i.e. the 286 // TODO(mcasas): support other Mode types beyond simple string i.e. the
267 // equivalents of "sequence<DOMString>"" or "ConstrainDOMStringParameters". 287 // equivalents of "sequence<DOMString>"" or "ConstrainDOMStringParameters".
268 settings->has_white_balance_mode = constraints.hasWhiteBalanceMode() && 288 settings->has_white_balance_mode = constraints.hasWhiteBalanceMode() &&
269 constraints.whiteBalanceMode().isString(); 289 constraints.whiteBalanceMode().isString();
270 if (settings->has_white_balance_mode) { 290 if (settings->has_white_balance_mode) {
271 current_constraints_.setWhiteBalanceMode(constraints.whiteBalanceMode()); 291 current_constraints_.setWhiteBalanceMode(constraints.whiteBalanceMode());
272 settings->white_balance_mode = 292 settings->white_balance_mode =
273 ParseMeteringMode(constraints.whiteBalanceMode().getAsString()); 293 ParseMeteringMode(constraints.whiteBalanceMode().getAsString());
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 visitor->Trace(stream_track_); 652 visitor->Trace(stream_track_);
633 visitor->Trace(capabilities_); 653 visitor->Trace(capabilities_);
634 visitor->Trace(settings_); 654 visitor->Trace(settings_);
635 visitor->Trace(current_constraints_); 655 visitor->Trace(current_constraints_);
636 visitor->Trace(service_requests_); 656 visitor->Trace(service_requests_);
637 EventTargetWithInlineData::Trace(visitor); 657 EventTargetWithInlineData::Trace(visitor);
638 ContextLifecycleObserver::Trace(visitor); 658 ContextLifecycleObserver::Trace(visitor);
639 } 659 }
640 660
641 } // namespace blink 661 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/imagecapture/MediaStreamTrack-getCapabilities.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698