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

Unified Diff: chrome/browser/extensions/api/tab_capture/tab_capture_api.cc

Issue 1631243003: Filter goog constraints in tabCapture API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(&params->options);
AddMediaStreamSourceConstraints(target_contents, &params->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(&params->options);
AddMediaStreamSourceConstraints(offscreen_tab->web_contents(),
&params->options);
« 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