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

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

Issue 415933002: Turn webspeech on/off when tab goes fore/background (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge the previous change 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 3cb55cc23313826bef8491fc84a3064ca910a278..f22dea736b7d2ce0b691ffed7e82142616ff42ca 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"
@@ -649,7 +650,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);
}
@@ -657,6 +658,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;
+}
« no previous file with comments | « chrome/browser/media/media_stream_devices_controller.h ('k') | content/browser/speech/speech_recognition_dispatcher_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698