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

Unified Diff: chrome/browser/ui/extensions/shell_window.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: address comments 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/ui/extensions/shell_window.cc
diff --git a/chrome/browser/ui/extensions/shell_window.cc b/chrome/browser/ui/extensions/shell_window.cc
index e15731934b9c19c8d614463d37015ea9232bbf92..0c6edb4934a98f9ae73811699d67360ff0edbff2 100644
--- a/chrome/browser/ui/extensions/shell_window.cc
+++ b/chrome/browser/ui/extensions/shell_window.cc
@@ -28,6 +28,7 @@
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_messages.h"
+#include "chrome/common/extensions/request_media_access_permission_helper.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/invalidate_type.h"
#include "content/public/browser/navigation_entry.h"
@@ -52,6 +53,7 @@ using content::ResourceDispatcherHost;
using content::SiteInstance;
using content::WebContents;
using extensions::APIPermission;
+using extensions::RequestMediaAccessPermissionHelper;
namespace {
const int kDefaultWidth = 512;
@@ -193,31 +195,8 @@ void ShellWindow::RequestMediaAccessPermission(
content::WebContents* web_contents,
const content::MediaStreamRequest* request,
const content::MediaResponseCallback& callback) {
- content::MediaStreamDevices devices;
-
- // Auto-accept the first audio device and the first video device from the
- // request when the appropriate API permissions exist.
- 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) &&
- extension()->HasAPIPermission(APIPermission::kAudioCapture) &&
- !it->second.empty()) {
- devices.push_back(it->second.front());
- accepted_an_audio_device = true;
- } else if (!accepted_a_video_device &&
- content::IsVideoMediaType(it->first) &&
- extension()->HasAPIPermission(APIPermission::kVideoCapture) &&
- !it->second.empty()) {
- devices.push_back(it->second.front());
- accepted_a_video_device = true;
- }
- }
-
- callback.Run(devices);
+ RequestMediaAccessPermissionHelper::AuthorizeRequest(
+ request, callback, extension(), true);
}
WebContents* ShellWindow::OpenURLFromTab(WebContents* source,

Powered by Google App Engine
This is Rietveld 408576698