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

Unified Diff: chrome/browser/extensions/extension_host.cc

Issue 11198044: Make tab capture media stream requests verify that the request came from extension API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 8 years, 2 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
Index: chrome/browser/extensions/extension_host.cc
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index d370c268c555b51ae652538ac323cac0c26de36b..d7874a94c564756e93679901faf3ec82a3060aa1 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -640,4 +640,38 @@ void ExtensionHost::RenderViewReady() {
content::Details<ExtensionHost>(this));
}
+void ExtensionHost::RequestMediaAccessPermission(
Aaron Boodman 2012/10/18 22:14:09 This code looks like a dupe of the one in shell_ho
justinlin 2012/10/19 02:22:54 Done the refactor. Are those implementations need
+ content::WebContents* web_contents,
+ const content::MediaStreamRequest* request,
+ const content::MediaResponseCallback& callback) {
+ content::MediaStreamDevices devices;
+
+ bool accepted_an_audio_device = false;
+ bool accepted_a_video_device = false;
+ for (content::MediaStreamDeviceMap::const_iterator it =
+ request->devices.begin(); it != request->devices.end(); ++it) {
+ if (!accepted_an_audio_device &&
+ content::IsAudioMediaType(it->first) &&
+ !it->second.empty()) {
+ // For tab capture device, we require the tabCapture permission, otherwise
+ // we don't need to check permission.
+ if (it->first != content::MEDIA_TAB_AUDIO_CAPTURE ||
+ extension()->HasAPIPermission(APIPermission::kTabCapture)) {
+ devices.push_back(it->second.front());
+ accepted_an_audio_device = true;
+ }
+ } else if (!accepted_a_video_device &&
+ content::IsVideoMediaType(it->first) &&
+ !it->second.empty()) {
+ if (it->first != content::MEDIA_TAB_VIDEO_CAPTURE ||
+ extension()->HasAPIPermission(APIPermission::kTabCapture)) {
+ devices.push_back(it->second.front());
+ accepted_a_video_device = true;
+ }
+ }
+ }
+
+ callback.Run(devices);
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698