| Index: chrome/browser/extensions/api/tab_capture/tab_capture_api.cc
|
| diff --git a/chrome/browser/extensions/api/tab_capture/tab_capture_api.cc b/chrome/browser/extensions/api/tab_capture/tab_capture_api.cc
|
| index 34c31faac5102db52908d2e4183ad2b5bcf0cc16..04a12e0d7e873b5d62caee33653dcb760f5f3602 100644
|
| --- a/chrome/browser/extensions/api/tab_capture/tab_capture_api.cc
|
| +++ b/chrome/browser/extensions/api/tab_capture/tab_capture_api.cc
|
| @@ -75,6 +75,45 @@ bool IsAcceptableOffscreenTabUrl(const GURL& url) {
|
| return url.is_valid() && (url.SchemeIsHTTPOrHTTPS() || url.SchemeIs("data"));
|
| }
|
|
|
| +// Removes all mandatory and optional constraint entries that start with the
|
| +// "goog" prefix. These are never needed and may cause the renderer-side
|
| +// getUserMedia() call to fail. http://crbug.com/579729
|
| +//
|
| +// TODO(miu): Remove once tabCapture API is migrated to new constraints spec.
|
| +// http://crbug.com/579729
|
| +void FilterDeprecatedGoogConstraints(TabCapture::CaptureOptions* options) {
|
| + const auto FilterGoogKeysFromDictionary = [](base::DictionaryValue* dict) {
|
| + std::vector<std::string> bad_keys;
|
| + base::DictionaryValue::Iterator it(*dict);
|
| + for (; !it.IsAtEnd(); it.Advance()) {
|
| + if (it.key().find("goog") == 0)
|
| + bad_keys.push_back(it.key());
|
| + }
|
| + for (const std::string& k : bad_keys) {
|
| + scoped_ptr<base::Value> ignored;
|
| + dict->RemoveWithoutPathExpansion(k, &ignored);
|
| + }
|
| + };
|
| +
|
| + if (options->audio_constraints) {
|
| + FilterGoogKeysFromDictionary(
|
| + &options->audio_constraints->mandatory.additional_properties);
|
| + if (options->audio_constraints->optional) {
|
| + FilterGoogKeysFromDictionary(
|
| + &options->audio_constraints->optional->additional_properties);
|
| + }
|
| + }
|
| +
|
| + if (options->video_constraints) {
|
| + FilterGoogKeysFromDictionary(
|
| + &options->video_constraints->mandatory.additional_properties);
|
| + if (options->video_constraints->optional) {
|
| + FilterGoogKeysFromDictionary(
|
| + &options->video_constraints->optional->additional_properties);
|
| + }
|
| + }
|
| +}
|
| +
|
| // Add Chrome-specific source identifiers to the MediaStreamConstraints objects
|
| // in |options| to provide references to the |target_contents| to be captured.
|
| void AddMediaStreamSourceConstraints(content::WebContents* target_contents,
|
| @@ -208,6 +247,7 @@ bool TabCaptureCaptureFunction::RunSync() {
|
| error_ = kCapturingSameTab;
|
| return false;
|
| }
|
| + FilterDeprecatedGoogConstraints(¶ms->options);
|
| AddMediaStreamSourceConstraints(target_contents, ¶ms->options);
|
|
|
| // At this point, everything is set up in the browser process. It's now up to
|
| @@ -286,6 +326,7 @@ bool TabCaptureCaptureOffscreenTabFunction::RunSync() {
|
| SetError(kCapturingSameOffscreenTab);
|
| return false;
|
| }
|
| + FilterDeprecatedGoogConstraints(¶ms->options);
|
| AddMediaStreamSourceConstraints(offscreen_tab->web_contents(),
|
| ¶ms->options);
|
|
|
|
|