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

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

Issue 415433002: Turn webspeech on/off when tab goes fore/background (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: adding a TODO for test Created 6 years, 5 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_stream_devices_controller.cc
diff --git a/chrome/browser/media/media_stream_devices_controller.cc b/chrome/browser/media/media_stream_devices_controller.cc
index 1103f9af842553ecfca9291206d657caa8c569f8..431af985362b043c48a232b1c535c8c0baebccfb 100644
--- a/chrome/browser/media/media_stream_devices_controller.cc
+++ b/chrome/browser/media/media_stream_devices_controller.cc
@@ -23,6 +23,7 @@
#include "chrome/common/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/render_widget_host_view.h"
#include "content/public/common/media_stream_request.h"
#include "extensions/common/constants.h"
#include "grit/generated_resources.h"
@@ -662,7 +663,7 @@ bool MediaStreamDevicesController::IsDeviceAudioCaptureRequestedAndAllowed()
const {
MediaStreamTypeSettingsMap::const_iterator it =
request_permissions_.find(content::MEDIA_DEVICE_AUDIO_CAPTURE);
- return (it != request_permissions_.end() &&
+ return (it != request_permissions_.end() && IsCaptureDeviceRequestAllowed() &&
it->second.permission == MEDIA_ALLOWED);
}
@@ -670,6 +671,15 @@ bool MediaStreamDevicesController::IsDeviceVideoCaptureRequestedAndAllowed()
const {
MediaStreamTypeSettingsMap::const_iterator it =
request_permissions_.find(content::MEDIA_DEVICE_VIDEO_CAPTURE);
- return (it != request_permissions_.end() &&
+ return (it != request_permissions_.end() && IsCaptureDeviceRequestAllowed() &&
it->second.permission == MEDIA_ALLOWED);
}
+
+bool MediaStreamDevicesController::IsCaptureDeviceRequestAllowed() const {
+#if defined(OS_ANDROID)
+ // Don't approve device requests if the tab was hidden.
+ // TODO(qinmin): Add a test for this. http://crbug.com/396869.
+ return web_contents_->GetRenderWidgetHostView()->IsShowing();
+#endif
+ return true;
+}

Powered by Google App Engine
This is Rietveld 408576698