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

Side by Side Diff: chrome/browser/media/media_internals.cc

Issue 10168008: Show camera and microphone status indicators. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed Tommi's comments, displayed the title of the tab on the tray icon menu Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/media/media_internals.h" 5 #include "chrome/browser/media/media_internals.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/string16.h" 8 #include "base/string16.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "chrome/browser/media/media_internals_observer.h" 10 #include "chrome/browser/media/media_internals_observer.h"
11 #include "chrome/browser/media/media_stream_capture_indicator.h"
11 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/web_ui.h" 13 #include "content/public/browser/web_ui.h"
13 #include "media/base/media_log.h" 14 #include "media/base/media_log.h"
14 #include "media/base/media_log_event.h" 15 #include "media/base/media_log_event.h"
15 16
16 using content::BrowserThread; 17 using content::BrowserThread;
17 18
18 MediaInternals* MediaInternals::GetInstance() { 19 MediaInternals* MediaInternals::GetInstance() {
19 return Singleton<MediaInternals>::get(); 20 return Singleton<MediaInternals>::get();
20 } 21 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // Notify observers that |event| has occured. 57 // Notify observers that |event| has occured.
57 DictionaryValue dict; 58 DictionaryValue dict;
58 dict.SetInteger("renderer", render_process_id); 59 dict.SetInteger("renderer", render_process_id);
59 dict.SetInteger("player", event.id); 60 dict.SetInteger("player", event.id);
60 dict.SetString("type", media::MediaLog::EventTypeToString(event.type)); 61 dict.SetString("type", media::MediaLog::EventTypeToString(event.type));
61 dict.SetDouble("time", event.time.ToDoubleT()); 62 dict.SetDouble("time", event.time.ToDoubleT());
62 dict.Set("params", event.params.DeepCopy()); 63 dict.Set("params", event.params.DeepCopy());
63 SendUpdate("media.onMediaEvent", &dict); 64 SendUpdate("media.onMediaEvent", &dict);
64 } 65 }
65 66
67 void MediaInternals::OnCaptureDevicesOpened(
68 int render_process_id,
69 int render_view_id,
70 const content::MediaStreamDevices& devices) {
71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
72 if (!media_stream_capture_indicator_.get())
73 media_stream_capture_indicator_ = new MediaStreamCaptureIndicator();
74 media_stream_capture_indicator_->CaptureDevicesOpened(render_process_id,
75 render_view_id,
76 devices);
77 }
78
79 void MediaInternals::OnCaptureDevicesClosed(
80 int render_process_id,
81 int render_view_id,
82 const content::MediaStreamDevices& devices) {
83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
84 DCHECK(media_stream_capture_indicator_.get());
tommi (sloooow) - chröme 2012/05/02 12:10:55 this dcheck isn't very useful since you deref the
tommi (sloooow) - chröme 2012/05/02 12:10:55 no need for this dcheck
no longer working on chromium 2012/05/02 13:24:29 Done.
no longer working on chromium 2012/05/02 13:24:29 Done.
85 media_stream_capture_indicator_->CaptureDevicesClosed(render_process_id,
86 render_view_id,
87 devices);
88 }
89
66 void MediaInternals::AddObserver(MediaInternalsObserver* observer) { 90 void MediaInternals::AddObserver(MediaInternalsObserver* observer) {
67 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 91 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
68 observers_.AddObserver(observer); 92 observers_.AddObserver(observer);
69 } 93 }
70 94
71 void MediaInternals::RemoveObserver(MediaInternalsObserver* observer) { 95 void MediaInternals::RemoveObserver(MediaInternalsObserver* observer) {
72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
73 observers_.RemoveObserver(observer); 97 observers_.RemoveObserver(observer);
74 } 98 }
75 99
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 132
109 void MediaInternals::SendUpdate(const std::string& function, Value* value) { 133 void MediaInternals::SendUpdate(const std::string& function, Value* value) {
110 // Only bother serializing the update to JSON if someone is watching. 134 // Only bother serializing the update to JSON if someone is watching.
111 if (observers_.size()) { 135 if (observers_.size()) {
112 std::vector<const Value*> args; 136 std::vector<const Value*> args;
113 args.push_back(value); 137 args.push_back(value);
114 string16 update = content::WebUI::GetJavascriptCall(function, args); 138 string16 update = content::WebUI::GetJavascriptCall(function, args);
115 FOR_EACH_OBSERVER(MediaInternalsObserver, observers_, OnUpdate(update)); 139 FOR_EACH_OBSERVER(MediaInternalsObserver, observers_, OnUpdate(update));
116 } 140 }
117 } 141 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698