| OLD | NEW |
| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 if (!service_) { | 157 if (!service_) { |
| 158 resolver->Reject(DOMException::Create(kNotFoundError, kNoServiceError)); | 158 resolver->Reject(DOMException::Create(kNotFoundError, kNoServiceError)); |
| 159 return promise; | 159 return promise; |
| 160 } | 160 } |
| 161 service_requests_.insert(resolver); | 161 service_requests_.insert(resolver); |
| 162 | 162 |
| 163 // TODO(mcasas): should be using a mojo::StructTraits instead. | 163 // TODO(mcasas): should be using a mojo::StructTraits instead. |
| 164 auto settings = media::mojom::blink::PhotoSettings::New(); | 164 auto settings = media::mojom::blink::PhotoSettings::New(); |
| 165 | 165 |
| 166 settings->has_height = photo_settings.hasImageHeight(); | 166 settings->has_height = photo_settings.hasImageHeight(); |
| 167 if (settings->has_height) | 167 if (settings->has_height) { |
| 168 settings->height = photo_settings.imageHeight(); | 168 const double height = photo_settings.imageHeight(); |
| 169 if (photo_capabilities_ && |
| 170 (height < photo_capabilities_->imageHeight()->min() || |
| 171 height > photo_capabilities_->imageHeight()->max())) { |
| 172 resolver->Reject(DOMException::Create( |
| 173 kNotSupportedError, "imageHeight setting out of range")); |
| 174 return promise; |
| 175 } |
| 176 settings->height = height; |
| 177 } |
| 169 settings->has_width = photo_settings.hasImageWidth(); | 178 settings->has_width = photo_settings.hasImageWidth(); |
| 170 if (settings->has_width) | 179 if (settings->has_width) { |
| 171 settings->width = photo_settings.imageWidth(); | 180 const double width = photo_settings.imageWidth(); |
| 181 if (photo_capabilities_ && |
| 182 (width < photo_capabilities_->imageWidth()->min() || |
| 183 width > photo_capabilities_->imageWidth()->max())) { |
| 184 resolver->Reject(DOMException::Create(kNotSupportedError, |
| 185 "imageWidth setting out of range")); |
| 186 return promise; |
| 187 } |
| 188 settings->width = width; |
| 189 } |
| 172 | 190 |
| 173 settings->has_red_eye_reduction = photo_settings.hasRedEyeReduction(); | 191 settings->has_red_eye_reduction = photo_settings.hasRedEyeReduction(); |
| 174 if (settings->has_red_eye_reduction) | 192 if (settings->has_red_eye_reduction) { |
| 193 if (photo_capabilities_ && |
| 194 !photo_capabilities_->IsRedEyeReductionControllable()) { |
| 195 resolver->Reject(DOMException::Create( |
| 196 kNotSupportedError, "redEyeReduction is not controllable.")); |
| 197 return promise; |
| 198 } |
| 175 settings->red_eye_reduction = photo_settings.redEyeReduction(); | 199 settings->red_eye_reduction = photo_settings.redEyeReduction(); |
| 200 } |
| 201 |
| 176 settings->has_fill_light_mode = photo_settings.hasFillLightMode(); | 202 settings->has_fill_light_mode = photo_settings.hasFillLightMode(); |
| 177 if (settings->has_fill_light_mode) { | 203 if (settings->has_fill_light_mode) { |
| 178 settings->fill_light_mode = | 204 const String fill_light_mode = photo_settings.fillLightMode(); |
| 179 ParseFillLightMode(photo_settings.fillLightMode()); | 205 if (photo_capabilities_ && photo_capabilities_->fillLightMode().Find( |
| 206 fill_light_mode) == kNotFound) { |
| 207 resolver->Reject(DOMException::Create(kNotSupportedError, |
| 208 "Unsupported fillLightMode")); |
| 209 return promise; |
| 210 } |
| 211 settings->fill_light_mode = ParseFillLightMode(fill_light_mode); |
| 180 } | 212 } |
| 181 | 213 |
| 182 service_->SetOptions( | 214 service_->SetOptions( |
| 183 stream_track_->Component()->Source()->Id(), std::move(settings), | 215 stream_track_->Component()->Source()->Id(), std::move(settings), |
| 184 ConvertToBaseCallback( | 216 ConvertToBaseCallback( |
| 185 WTF::Bind(&ImageCapture::OnMojoSetOptions, WrapPersistent(this), | 217 WTF::Bind(&ImageCapture::OnMojoSetOptions, WrapPersistent(this), |
| 186 WrapPersistent(resolver), trigger_take_photo))); | 218 WrapPersistent(resolver), trigger_take_photo))); |
| 187 return promise; | 219 return promise; |
| 188 } | 220 } |
| 189 | 221 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 (constraints.hasSaturation() && !capabilities_.hasSaturation()) || | 314 (constraints.hasSaturation() && !capabilities_.hasSaturation()) || |
| 283 (constraints.hasSharpness() && !capabilities_.hasSharpness()) || | 315 (constraints.hasSharpness() && !capabilities_.hasSharpness()) || |
| 284 (constraints.hasZoom() && !capabilities_.hasZoom()) || | 316 (constraints.hasZoom() && !capabilities_.hasZoom()) || |
| 285 (constraints.hasTorch() && !capabilities_.hasTorch())) { | 317 (constraints.hasTorch() && !capabilities_.hasTorch())) { |
| 286 resolver->Reject( | 318 resolver->Reject( |
| 287 DOMException::Create(kNotSupportedError, "Unsupported constraint(s)")); | 319 DOMException::Create(kNotSupportedError, "Unsupported constraint(s)")); |
| 288 return; | 320 return; |
| 289 } | 321 } |
| 290 | 322 |
| 291 auto settings = media::mojom::blink::PhotoSettings::New(); | 323 auto settings = media::mojom::blink::PhotoSettings::New(); |
| 324 MediaTrackConstraintSet temp_constraints = current_constraints_; |
| 292 | 325 |
| 293 // TODO(mcasas): support other Mode types beyond simple string i.e. the | 326 // TODO(mcasas): support other Mode types beyond simple string i.e. the |
| 294 // equivalents of "sequence<DOMString>"" or "ConstrainDOMStringParameters". | 327 // equivalents of "sequence<DOMString>"" or "ConstrainDOMStringParameters". |
| 295 settings->has_white_balance_mode = constraints.hasWhiteBalanceMode() && | 328 settings->has_white_balance_mode = constraints.hasWhiteBalanceMode() && |
| 296 constraints.whiteBalanceMode().isString(); | 329 constraints.whiteBalanceMode().isString(); |
| 297 if (settings->has_white_balance_mode) { | 330 if (settings->has_white_balance_mode) { |
| 298 current_constraints_.setWhiteBalanceMode(constraints.whiteBalanceMode()); | 331 const auto white_balance_mode = |
| 299 settings->white_balance_mode = | 332 constraints.whiteBalanceMode().getAsString(); |
| 300 ParseMeteringMode(constraints.whiteBalanceMode().getAsString()); | 333 if (capabilities_.whiteBalanceMode().Find(white_balance_mode) == |
| 334 kNotFound) { |
| 335 resolver->Reject(DOMException::Create(kNotSupportedError, |
| 336 "Unsupported whiteBalanceMode.")); |
| 337 return; |
| 338 } |
| 339 temp_constraints.setWhiteBalanceMode(constraints.whiteBalanceMode()); |
| 340 settings->white_balance_mode = ParseMeteringMode(white_balance_mode); |
| 301 } | 341 } |
| 302 settings->has_exposure_mode = | 342 settings->has_exposure_mode = |
| 303 constraints.hasExposureMode() && constraints.exposureMode().isString(); | 343 constraints.hasExposureMode() && constraints.exposureMode().isString(); |
| 304 if (settings->has_exposure_mode) { | 344 if (settings->has_exposure_mode) { |
| 305 current_constraints_.setExposureMode(constraints.exposureMode()); | 345 const auto exposure_mode = constraints.exposureMode().getAsString(); |
| 306 settings->exposure_mode = | 346 if (capabilities_.exposureMode().Find(exposure_mode) == kNotFound) { |
| 307 ParseMeteringMode(constraints.exposureMode().getAsString()); | 347 resolver->Reject(DOMException::Create(kNotSupportedError, |
| 348 "Unsupported exposureMode.")); |
| 349 return; |
| 350 } |
| 351 temp_constraints.setExposureMode(constraints.exposureMode()); |
| 352 settings->exposure_mode = ParseMeteringMode(exposure_mode); |
| 308 } | 353 } |
| 309 | 354 |
| 310 settings->has_focus_mode = | 355 settings->has_focus_mode = |
| 311 constraints.hasFocusMode() && constraints.focusMode().isString(); | 356 constraints.hasFocusMode() && constraints.focusMode().isString(); |
| 312 if (settings->has_focus_mode) { | 357 if (settings->has_focus_mode) { |
| 313 current_constraints_.setFocusMode(constraints.focusMode()); | 358 const auto focus_mode = constraints.focusMode().getAsString(); |
| 314 settings->focus_mode = | 359 if (capabilities_.focusMode().Find(focus_mode) == kNotFound) { |
| 315 ParseMeteringMode(constraints.focusMode().getAsString()); | 360 resolver->Reject( |
| 361 DOMException::Create(kNotSupportedError, "Unsupported focusMode.")); |
| 362 return; |
| 363 } |
| 364 temp_constraints.setFocusMode(constraints.focusMode()); |
| 365 settings->focus_mode = ParseMeteringMode(focus_mode); |
| 316 } | 366 } |
| 317 | 367 |
| 318 // TODO(mcasas): support ConstrainPoint2DParameters. | 368 // TODO(mcasas): support ConstrainPoint2DParameters. |
| 319 if (constraints.hasPointsOfInterest() && | 369 if (constraints.hasPointsOfInterest() && |
| 320 constraints.pointsOfInterest().isPoint2DSequence()) { | 370 constraints.pointsOfInterest().isPoint2DSequence()) { |
| 321 for (const auto& point : | 371 for (const auto& point : |
| 322 constraints.pointsOfInterest().getAsPoint2DSequence()) { | 372 constraints.pointsOfInterest().getAsPoint2DSequence()) { |
| 323 auto mojo_point = media::mojom::blink::Point2D::New(); | 373 auto mojo_point = media::mojom::blink::Point2D::New(); |
| 324 mojo_point->x = point.x(); | 374 mojo_point->x = point.x(); |
| 325 mojo_point->y = point.y(); | 375 mojo_point->y = point.y(); |
| 326 settings->points_of_interest.push_back(std::move(mojo_point)); | 376 settings->points_of_interest.push_back(std::move(mojo_point)); |
| 327 } | 377 } |
| 328 current_constraints_.setPointsOfInterest(constraints.pointsOfInterest()); | 378 temp_constraints.setPointsOfInterest(constraints.pointsOfInterest()); |
| 329 } | 379 } |
| 330 | 380 |
| 331 // TODO(mcasas): support ConstrainDoubleRange where applicable. | 381 // TODO(mcasas): support ConstrainDoubleRange where applicable. |
| 332 settings->has_exposure_compensation = | 382 settings->has_exposure_compensation = |
| 333 constraints.hasExposureCompensation() && | 383 constraints.hasExposureCompensation() && |
| 334 constraints.exposureCompensation().isDouble(); | 384 constraints.exposureCompensation().isDouble(); |
| 335 if (settings->has_exposure_compensation) { | 385 if (settings->has_exposure_compensation) { |
| 336 current_constraints_.setExposureCompensation( | 386 const auto exposure_compensation = |
| 387 constraints.exposureCompensation().getAsDouble(); |
| 388 if (exposure_compensation < capabilities_.exposureCompensation()->min() || |
| 389 exposure_compensation > capabilities_.exposureCompensation()->max()) { |
| 390 resolver->Reject(DOMException::Create( |
| 391 kNotSupportedError, "exposureCompensation setting out of range")); |
| 392 return; |
| 393 } |
| 394 temp_constraints.setExposureCompensation( |
| 337 constraints.exposureCompensation()); | 395 constraints.exposureCompensation()); |
| 338 settings->exposure_compensation = | 396 settings->exposure_compensation = exposure_compensation; |
| 339 constraints.exposureCompensation().getAsDouble(); | |
| 340 } | 397 } |
| 341 settings->has_color_temperature = constraints.hasColorTemperature() && | 398 settings->has_color_temperature = constraints.hasColorTemperature() && |
| 342 constraints.colorTemperature().isDouble(); | 399 constraints.colorTemperature().isDouble(); |
| 343 if (settings->has_color_temperature) { | 400 if (settings->has_color_temperature) { |
| 344 current_constraints_.setColorTemperature(constraints.colorTemperature()); | 401 const auto color_temperature = constraints.colorTemperature().getAsDouble(); |
| 345 settings->color_temperature = constraints.colorTemperature().getAsDouble(); | 402 if (color_temperature < capabilities_.colorTemperature()->min() || |
| 403 color_temperature > capabilities_.colorTemperature()->max()) { |
| 404 resolver->Reject(DOMException::Create( |
| 405 kNotSupportedError, "colorTemperature setting out of range")); |
| 406 return; |
| 407 } |
| 408 temp_constraints.setColorTemperature(constraints.colorTemperature()); |
| 409 settings->color_temperature = color_temperature; |
| 346 } | 410 } |
| 347 settings->has_iso = constraints.hasIso() && constraints.iso().isDouble(); | 411 settings->has_iso = constraints.hasIso() && constraints.iso().isDouble(); |
| 348 if (settings->has_iso) { | 412 if (settings->has_iso) { |
| 349 current_constraints_.setIso(constraints.iso()); | 413 const auto iso = constraints.iso().getAsDouble(); |
| 350 settings->iso = constraints.iso().getAsDouble(); | 414 if (iso < capabilities_.iso()->min() || iso > capabilities_.iso()->max()) { |
| 415 resolver->Reject( |
| 416 DOMException::Create(kNotSupportedError, "iso setting out of range")); |
| 417 return; |
| 418 } |
| 419 temp_constraints.setIso(constraints.iso()); |
| 420 settings->iso = iso; |
| 351 } | 421 } |
| 352 | 422 |
| 353 settings->has_brightness = | 423 settings->has_brightness = |
| 354 constraints.hasBrightness() && constraints.brightness().isDouble(); | 424 constraints.hasBrightness() && constraints.brightness().isDouble(); |
| 355 if (settings->has_brightness) { | 425 if (settings->has_brightness) { |
| 356 current_constraints_.setBrightness(constraints.brightness()); | 426 const auto brightness = constraints.brightness().getAsDouble(); |
| 357 settings->brightness = constraints.brightness().getAsDouble(); | 427 if (brightness < capabilities_.brightness()->min() || |
| 428 brightness > capabilities_.brightness()->max()) { |
| 429 resolver->Reject(DOMException::Create(kNotSupportedError, |
| 430 "brightness setting out of range")); |
| 431 return; |
| 432 } |
| 433 temp_constraints.setBrightness(constraints.brightness()); |
| 434 settings->brightness = brightness; |
| 358 } | 435 } |
| 359 settings->has_contrast = | 436 settings->has_contrast = |
| 360 constraints.hasContrast() && constraints.contrast().isDouble(); | 437 constraints.hasContrast() && constraints.contrast().isDouble(); |
| 361 if (settings->has_contrast) { | 438 if (settings->has_contrast) { |
| 362 current_constraints_.setContrast(constraints.contrast()); | 439 const auto contrast = constraints.contrast().getAsDouble(); |
| 363 settings->contrast = constraints.contrast().getAsDouble(); | 440 if (contrast < capabilities_.contrast()->min() || |
| 441 contrast > capabilities_.contrast()->max()) { |
| 442 resolver->Reject(DOMException::Create(kNotSupportedError, |
| 443 "contrast setting out of range")); |
| 444 return; |
| 445 } |
| 446 temp_constraints.setContrast(constraints.contrast()); |
| 447 settings->contrast = contrast; |
| 364 } | 448 } |
| 365 settings->has_saturation = | 449 settings->has_saturation = |
| 366 constraints.hasSaturation() && constraints.saturation().isDouble(); | 450 constraints.hasSaturation() && constraints.saturation().isDouble(); |
| 367 if (settings->has_saturation) { | 451 if (settings->has_saturation) { |
| 368 current_constraints_.setSaturation(constraints.saturation()); | 452 const auto saturation = constraints.saturation().getAsDouble(); |
| 369 settings->saturation = constraints.saturation().getAsDouble(); | 453 if (saturation < capabilities_.saturation()->min() || |
| 454 saturation > capabilities_.saturation()->max()) { |
| 455 resolver->Reject(DOMException::Create(kNotSupportedError, |
| 456 "saturation setting out of range")); |
| 457 return; |
| 458 } |
| 459 temp_constraints.setSaturation(constraints.saturation()); |
| 460 settings->saturation = saturation; |
| 370 } | 461 } |
| 371 settings->has_sharpness = | 462 settings->has_sharpness = |
| 372 constraints.hasSharpness() && constraints.sharpness().isDouble(); | 463 constraints.hasSharpness() && constraints.sharpness().isDouble(); |
| 373 if (settings->has_sharpness) { | 464 if (settings->has_sharpness) { |
| 374 current_constraints_.setSharpness(constraints.sharpness()); | 465 const auto sharpness = constraints.sharpness().getAsDouble(); |
| 375 settings->sharpness = constraints.sharpness().getAsDouble(); | 466 if (sharpness < capabilities_.sharpness()->min() || |
| 467 sharpness > capabilities_.sharpness()->max()) { |
| 468 resolver->Reject(DOMException::Create(kNotSupportedError, |
| 469 "sharpness setting out of range")); |
| 470 return; |
| 471 } |
| 472 temp_constraints.setSharpness(constraints.sharpness()); |
| 473 settings->sharpness = sharpness; |
| 376 } | 474 } |
| 377 | 475 |
| 378 settings->has_zoom = constraints.hasZoom() && constraints.zoom().isDouble(); | 476 settings->has_zoom = constraints.hasZoom() && constraints.zoom().isDouble(); |
| 379 if (settings->has_zoom) { | 477 if (settings->has_zoom) { |
| 380 current_constraints_.setZoom(constraints.zoom()); | 478 const auto zoom = constraints.zoom().getAsDouble(); |
| 381 settings->zoom = constraints.zoom().getAsDouble(); | 479 if (zoom < capabilities_.zoom()->min() || |
| 480 zoom > capabilities_.zoom()->max()) { |
| 481 resolver->Reject(DOMException::Create(kNotSupportedError, |
| 482 "zoom setting out of range")); |
| 483 return; |
| 484 } |
| 485 temp_constraints.setZoom(constraints.zoom()); |
| 486 settings->zoom = zoom; |
| 382 } | 487 } |
| 383 | 488 |
| 384 // TODO(mcasas): support ConstrainBooleanParameters where applicable. | 489 // TODO(mcasas): support ConstrainBooleanParameters where applicable. |
| 385 settings->has_torch = | 490 settings->has_torch = |
| 386 constraints.hasTorch() && constraints.torch().isBoolean(); | 491 constraints.hasTorch() && constraints.torch().isBoolean(); |
| 387 if (settings->has_torch) { | 492 if (settings->has_torch) { |
| 388 current_constraints_.setTorch(constraints.torch()); | 493 const auto torch = constraints.torch().getAsBoolean(); |
| 389 settings->torch = constraints.torch().getAsBoolean(); | 494 if (torch && !capabilities_.torch()) { |
| 495 resolver->Reject( |
| 496 DOMException::Create(kNotSupportedError, "torch not supported")); |
| 497 return; |
| 498 } |
| 499 temp_constraints.setTorch(constraints.torch()); |
| 500 settings->torch = torch; |
| 390 } | 501 } |
| 391 | 502 |
| 503 current_constraints_ = temp_constraints; |
| 504 |
| 392 service_->SetOptions( | 505 service_->SetOptions( |
| 393 stream_track_->Component()->Source()->Id(), std::move(settings), | 506 stream_track_->Component()->Source()->Id(), std::move(settings), |
| 394 ConvertToBaseCallback( | 507 ConvertToBaseCallback( |
| 395 WTF::Bind(&ImageCapture::OnMojoSetOptions, WrapPersistent(this), | 508 WTF::Bind(&ImageCapture::OnMojoSetOptions, WrapPersistent(this), |
| 396 WrapPersistent(resolver), false /* trigger_take_photo */))); | 509 WrapPersistent(resolver), false /* trigger_take_photo */))); |
| 397 } | 510 } |
| 398 | 511 |
| 399 const MediaTrackConstraintSet& ImageCapture::GetMediaTrackConstraints() const { | 512 const MediaTrackConstraintSet& ImageCapture::GetMediaTrackConstraints() const { |
| 400 return current_constraints_; | 513 return current_constraints_; |
| 401 } | 514 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 media::mojom::blink::PhotoCapabilitiesPtr capabilities) { | 607 media::mojom::blink::PhotoCapabilitiesPtr capabilities) { |
| 495 if (!service_requests_.Contains(resolver)) | 608 if (!service_requests_.Contains(resolver)) |
| 496 return; | 609 return; |
| 497 | 610 |
| 498 if (capabilities.is_null()) { | 611 if (capabilities.is_null()) { |
| 499 resolver->Reject(DOMException::Create(kUnknownError, "platform error")); | 612 resolver->Reject(DOMException::Create(kUnknownError, "platform error")); |
| 500 service_requests_.erase(resolver); | 613 service_requests_.erase(resolver); |
| 501 return; | 614 return; |
| 502 } | 615 } |
| 503 | 616 |
| 504 PhotoCapabilities* caps = PhotoCapabilities::Create(); | 617 photo_capabilities_ = PhotoCapabilities::Create(); |
| 505 caps->SetRedEyeReduction(capabilities->red_eye_reduction); | 618 photo_capabilities_->SetRedEyeReduction(capabilities->red_eye_reduction); |
| 506 // TODO(mcasas): Remove the explicit MediaSettingsRange::create() when | 619 // TODO(mcasas): Remove the explicit MediaSettingsRange::create() when |
| 507 // mojo::StructTraits supports garbage-collected mappings, | 620 // mojo::StructTraits supports garbage-collected mappings, |
| 508 // https://crbug.com/700180. | 621 // https://crbug.com/700180. |
| 509 if (capabilities->height->min != 0 || capabilities->height->max != 0) { | 622 if (capabilities->height->min != 0 || capabilities->height->max != 0) { |
| 510 caps->SetImageHeight( | 623 photo_capabilities_->SetImageHeight( |
| 511 MediaSettingsRange::Create(std::move(capabilities->height))); | 624 MediaSettingsRange::Create(std::move(capabilities->height))); |
| 512 } | 625 } |
| 513 if (capabilities->width->min != 0 || capabilities->width->max != 0) { | 626 if (capabilities->width->min != 0 || capabilities->width->max != 0) { |
| 514 caps->SetImageWidth( | 627 photo_capabilities_->SetImageWidth( |
| 515 MediaSettingsRange::Create(std::move(capabilities->width))); | 628 MediaSettingsRange::Create(std::move(capabilities->width))); |
| 516 } | 629 } |
| 517 if (!capabilities->fill_light_mode.IsEmpty()) | 630 if (!capabilities->fill_light_mode.IsEmpty()) |
| 518 caps->SetFillLightMode(capabilities->fill_light_mode); | 631 photo_capabilities_->SetFillLightMode(capabilities->fill_light_mode); |
| 519 | 632 |
| 520 // Update the local track capabilities cache. | 633 // Update the local track capabilities cache. |
| 521 UpdateMediaTrackCapabilities(std::move(capabilities)); | 634 UpdateMediaTrackCapabilities(std::move(capabilities)); |
| 522 | 635 |
| 523 if (trigger_take_photo) { | 636 if (trigger_take_photo) { |
| 524 service_->TakePhoto(stream_track_->Component()->Source()->Id(), | 637 service_->TakePhoto(stream_track_->Component()->Source()->Id(), |
| 525 ConvertToBaseCallback(WTF::Bind( | 638 ConvertToBaseCallback(WTF::Bind( |
| 526 &ImageCapture::OnMojoTakePhoto, | 639 &ImageCapture::OnMojoTakePhoto, |
| 527 WrapPersistent(this), WrapPersistent(resolver)))); | 640 WrapPersistent(this), WrapPersistent(resolver)))); |
| 528 return; | 641 return; |
| 529 } | 642 } |
| 530 | 643 |
| 531 resolver->Resolve(caps); | 644 resolver->Resolve(photo_capabilities_); |
| 532 service_requests_.erase(resolver); | 645 service_requests_.erase(resolver); |
| 533 } | 646 } |
| 534 | 647 |
| 535 void ImageCapture::OnMojoSetOptions(ScriptPromiseResolver* resolver, | 648 void ImageCapture::OnMojoSetOptions(ScriptPromiseResolver* resolver, |
| 536 bool trigger_take_photo, | 649 bool trigger_take_photo, |
| 537 bool result) { | 650 bool result) { |
| 538 if (!service_requests_.Contains(resolver)) | 651 if (!service_requests_.Contains(resolver)) |
| 539 return; | 652 return; |
| 540 | 653 |
| 541 if (!result) { | 654 if (!result) { |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 for (ScriptPromiseResolver* resolver : service_requests_) | 785 for (ScriptPromiseResolver* resolver : service_requests_) |
| 673 resolver->Reject(DOMException::Create(kNotFoundError, kNoServiceError)); | 786 resolver->Reject(DOMException::Create(kNotFoundError, kNoServiceError)); |
| 674 service_requests_.Clear(); | 787 service_requests_.Clear(); |
| 675 } | 788 } |
| 676 | 789 |
| 677 DEFINE_TRACE(ImageCapture) { | 790 DEFINE_TRACE(ImageCapture) { |
| 678 visitor->Trace(stream_track_); | 791 visitor->Trace(stream_track_); |
| 679 visitor->Trace(capabilities_); | 792 visitor->Trace(capabilities_); |
| 680 visitor->Trace(settings_); | 793 visitor->Trace(settings_); |
| 681 visitor->Trace(current_constraints_); | 794 visitor->Trace(current_constraints_); |
| 795 visitor->Trace(photo_capabilities_); |
| 682 visitor->Trace(service_requests_); | 796 visitor->Trace(service_requests_); |
| 683 EventTargetWithInlineData::Trace(visitor); | 797 EventTargetWithInlineData::Trace(visitor); |
| 684 ContextLifecycleObserver::Trace(visitor); | 798 ContextLifecycleObserver::Trace(visitor); |
| 685 } | 799 } |
| 686 | 800 |
| 687 } // namespace blink | 801 } // namespace blink |
| OLD | NEW |