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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/extensions/extension_host.h" 5 #include "chrome/browser/extensions/extension_host.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 initial_pos, user_gesture); 633 initial_pos, user_gesture);
634 } 634 }
635 635
636 void ExtensionHost::RenderViewReady() { 636 void ExtensionHost::RenderViewReady() {
637 content::NotificationService::current()->Notify( 637 content::NotificationService::current()->Notify(
638 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, 638 chrome::NOTIFICATION_EXTENSION_HOST_CREATED,
639 content::Source<Profile>(profile_), 639 content::Source<Profile>(profile_),
640 content::Details<ExtensionHost>(this)); 640 content::Details<ExtensionHost>(this));
641 } 641 }
642 642
643 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
644 content::WebContents* web_contents,
645 const content::MediaStreamRequest* request,
646 const content::MediaResponseCallback& callback) {
647 content::MediaStreamDevices devices;
648
649 bool accepted_an_audio_device = false;
650 bool accepted_a_video_device = false;
651 for (content::MediaStreamDeviceMap::const_iterator it =
652 request->devices.begin(); it != request->devices.end(); ++it) {
653 if (!accepted_an_audio_device &&
654 content::IsAudioMediaType(it->first) &&
655 !it->second.empty()) {
656 // For tab capture device, we require the tabCapture permission, otherwise
657 // we don't need to check permission.
658 if (it->first != content::MEDIA_TAB_AUDIO_CAPTURE ||
659 extension()->HasAPIPermission(APIPermission::kTabCapture)) {
660 devices.push_back(it->second.front());
661 accepted_an_audio_device = true;
662 }
663 } else if (!accepted_a_video_device &&
664 content::IsVideoMediaType(it->first) &&
665 !it->second.empty()) {
666 if (it->first != content::MEDIA_TAB_VIDEO_CAPTURE ||
667 extension()->HasAPIPermission(APIPermission::kTabCapture)) {
668 devices.push_back(it->second.front());
669 accepted_a_video_device = true;
670 }
671 }
672 }
673
674 callback.Run(devices);
675 }
676
643 } // namespace extensions 677 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698