[Mac] Implement Ambient Light API
[chromium-blink-merge.git] / athena / content / chrome / media_utils.cc
blobbe77697d502fa89229e1d2744d09ed3ad8445c89
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "athena/content/media_utils.h"
7 #include "athena/activity/public/activity.h"
8 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
9 #include "chrome/browser/media/media_stream_capture_indicator.h"
10 #include "content/browser/media/audio_stream_monitor.h"
11 #include "content/public/browser/web_contents.h"
13 namespace athena {
15 Activity::ActivityMediaState GetActivityMediaState(
16 content::WebContents* contents) {
17 // TODO(skuhne): This needs to be refactored and / or moved out of Chrome.
18 // See crbug.com/420677.
19 scoped_refptr<MediaStreamCaptureIndicator> indicator =
20 MediaCaptureDevicesDispatcher::GetInstance()->
21 GetMediaStreamCaptureIndicator();
22 if (indicator.get() && indicator->IsCapturingUserMedia(contents))
23 return Activity::ACTIVITY_MEDIA_STATE_RECORDING;
25 if (contents->GetCapturerCount())
26 return Activity::ACTIVITY_MEDIA_STATE_CAPTURING;
28 DCHECK(content::AudioStreamMonitor::monitoring_available());
29 return contents->WasRecentlyAudible() ?
30 Activity::ACTIVITY_MEDIA_STATE_AUDIO_PLAYING :
31 Activity::ACTIVITY_MEDIA_STATE_NONE;
34 } // namespace athena