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

Unified Diff: chrome/browser/media/media_access_handler.cc

Issue 2746873004: Move ChromeOS login media access logic into a MediaAccessHandler (Closed)
Patch Set: Move SAML access logic into MediaAccessHandler Created 3 years, 9 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/media/media_access_handler.cc
diff --git a/chrome/browser/media/extension_media_access_handler.cc b/chrome/browser/media/media_access_handler.cc
similarity index 50%
copy from chrome/browser/media/extension_media_access_handler.cc
copy to chrome/browser/media/media_access_handler.cc
index 681fe900f28a8ec754e681bfbdbf23e1aec5717c..6f2ff8c7960dbb01808f063d8c018f633335b348 100644
--- a/chrome/browser/media/extension_media_access_handler.cc
+++ b/chrome/browser/media/media_access_handler.cc
@@ -1,96 +1,24 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
+// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/media/extension_media_access_handler.h"
-
-#include <utility>
+#include "chrome/browser/media/saml_media_access_handler.h"
#include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
#include "chrome/browser/media/webrtc/media_stream_capture_indicator.h"
-#include "chrome/browser/media/webrtc/media_stream_device_permissions.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/pref_names.h"
#include "content/public/browser/web_contents.h"
-#include "extensions/common/extension.h"
-#include "extensions/common/permissions/permissions_data.h"
-
-namespace {
-
-// This is a short-term solution to grant camera and/or microphone access to
-// extensions:
-// 1. Virtual keyboard extension.
-// 2. Flutter gesture recognition extension.
-// 3. TODO(smus): Airbender experiment 1.
-// 4. TODO(smus): Airbender experiment 2.
-// 5. Hotwording component extension.
-// 6. XKB input method component extension.
-// 7. M17n/T13n/CJK input method component extension.
-// Once http://crbug.com/292856 is fixed, remove this whitelist.
-bool IsMediaRequestWhitelistedForExtension(
- const extensions::Extension* extension) {
- return extension->id() == "mppnpdlheglhdfmldimlhpnegondlapf" ||
- extension->id() == "jokbpnebhdcladagohdnfgjcpejggllo" ||
- extension->id() == "clffjmdilanldobdnedchkdbofoimcgb" ||
- extension->id() == "nnckehldicaciogcbchegobnafnjkcne" ||
- extension->id() == "nbpagnldghgfoolbancepceaanlmhfmd" ||
- extension->id() == "jkghodnilhceideoidjikpgommlajknk" ||
- extension->id() == "gjaehgfemfahhmlgpdfknkhdnemmolop";
-}
-
-} // namespace
-
-ExtensionMediaAccessHandler::ExtensionMediaAccessHandler() {
-}
-
-ExtensionMediaAccessHandler::~ExtensionMediaAccessHandler() {
-}
-
-bool ExtensionMediaAccessHandler::SupportsStreamType(
- const content::MediaStreamType type,
- const extensions::Extension* extension) {
- return extension && (extension->is_platform_app() ||
- IsMediaRequestWhitelistedForExtension(extension)) &&
- (type == content::MEDIA_DEVICE_AUDIO_CAPTURE ||
- type == content::MEDIA_DEVICE_VIDEO_CAPTURE);
-}
-bool ExtensionMediaAccessHandler::CheckMediaAccessPermission(
- content::WebContents* web_contents,
- const GURL& security_origin,
- content::MediaStreamType type,
- const extensions::Extension* extension) {
- return extension->permissions_data()->HasAPIPermission(
- type == content::MEDIA_DEVICE_AUDIO_CAPTURE
- ? extensions::APIPermission::kAudioCapture
- : extensions::APIPermission::kVideoCapture);
-}
-
-void ExtensionMediaAccessHandler::HandleRequest(
+// static
+void MediaAccessHandler::CheckDevicesAndRunCallback(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback,
- const extensions::Extension* extension) {
+ bool audio_allowed,
+ bool video_allowed) {
// TODO(vrk): This code is largely duplicated in
// MediaStreamDevicesController::Accept(). Move this code into a shared method
Sergey Ulanov 2017/03/15 22:48:30 That code is in MediaStreamDevicesController::GetD
raymes 2017/03/16 02:30:37 Done.
// between the two classes.
-
- Profile* profile =
- Profile::FromBrowserContext(web_contents->GetBrowserContext());
-
- bool audio_allowed =
- request.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE &&
- extension->permissions_data()->HasAPIPermission(
- extensions::APIPermission::kAudioCapture) &&
- GetDevicePolicy(profile, extension->url(), prefs::kAudioCaptureAllowed,
- prefs::kAudioCaptureAllowedUrls) != ALWAYS_DENY;
- bool video_allowed =
- request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE &&
- extension->permissions_data()->HasAPIPermission(
- extensions::APIPermission::kVideoCapture) &&
- GetDevicePolicy(profile, extension->url(), prefs::kVideoCaptureAllowed,
- prefs::kVideoCaptureAllowedUrls) != ALWAYS_DENY;
-
bool get_default_audio_device = audio_allowed;
bool get_default_video_device = video_allowed;
@@ -130,6 +58,9 @@ void ExtensionMediaAccessHandler::HandleRequest(
}
}
+ Profile* profile =
+ Profile::FromBrowserContext(web_contents->GetBrowserContext());
+
// If either or both audio and video devices were requested but not
// specified by id, get the default devices.
if (get_default_audio_device || get_default_video_device) {

Powered by Google App Engine
This is Rietveld 408576698