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

Side by Side Diff: chrome/browser/media/media_stream_capture_indicator.h

Issue 11236052: Indicate tab recording state in tab strip (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Always add capture devices Created 8 years, 2 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_MEDIA_MEDIA_STREAM_CAPTURE_INDICATOR_H_ 5 #ifndef CHROME_BROWSER_MEDIA_MEDIA_STREAM_CAPTURE_INDICATOR_H_
6 #define CHROME_BROWSER_MEDIA_MEDIA_STREAM_CAPTURE_INDICATOR_H_ 6 #define CHROME_BROWSER_MEDIA_MEDIA_STREAM_CAPTURE_INDICATOR_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/extensions/image_loading_tracker.h" 12 #include "chrome/browser/extensions/image_loading_tracker.h"
14 #include "content/public/common/media_stream_request.h" 13 #include "content/public/common/media_stream_request.h"
15 #include "ui/base/models/simple_menu_model.h" 14 #include "ui/base/models/simple_menu_model.h"
16 #include "ui/gfx/image/image_skia.h" 15 #include "ui/gfx/image/image_skia.h"
17 16
18 class StatusIcon; 17 class StatusIcon;
19 class StatusTray; 18 class StatusTray;
20 19
21 // This indicator is owned by MediaInternals and deleted when MediaInternals 20 // This indicator is owned by MediaInternals and deleted when MediaInternals
22 // is deleted. 21 // is deleted.
23 class MediaStreamCaptureIndicator 22 class MediaStreamCaptureIndicator : public ui::SimpleMenuModel::Delegate,
24 : public base::RefCountedThreadSafe<MediaStreamCaptureIndicator>, 23 public ImageLoadingTracker::Observer {
25 public ui::SimpleMenuModel::Delegate,
26 public ImageLoadingTracker::Observer {
27 public: 24 public:
28 MediaStreamCaptureIndicator(); 25 MediaStreamCaptureIndicator();
26 virtual ~MediaStreamCaptureIndicator();
29 27
30 // Overrides from SimpleMenuModel::Delegate implementation. 28 // Overrides from SimpleMenuModel::Delegate implementation.
31 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; 29 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
32 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; 30 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
33 virtual bool GetAcceleratorForCommandId( 31 virtual bool GetAcceleratorForCommandId(
34 int command_id, 32 int command_id,
35 ui::Accelerator* accelerator) OVERRIDE; 33 ui::Accelerator* accelerator) OVERRIDE;
36 virtual void ExecuteCommand(int command_id) OVERRIDE; 34 virtual void ExecuteCommand(int command_id) OVERRIDE;
37 35
38 // Called on IO thread when MediaStream opens new capture devices. 36 // Called on IO thread when MediaStream opens new capture devices.
39 void CaptureDevicesOpened(int render_process_id, 37 void CaptureDevicesOpened(int render_process_id,
40 int render_view_id, 38 int render_view_id,
41 const content::MediaStreamDevices& devices); 39 const content::MediaStreamDevices& devices);
42 40
43 // Called on IO thread when MediaStream closes the opened devices. 41 // Called on IO thread when MediaStream closes the opened devices.
44 void CaptureDevicesClosed(int render_process_id, 42 void CaptureDevicesClosed(int render_process_id,
45 int render_view_id, 43 int render_view_id,
46 const content::MediaStreamDevices& devices); 44 const content::MediaStreamDevices& devices);
47 45
46 // Returns true if the render process is capturing media.
47 bool IsProcessCapturing(int render_process_id, int render_view_id) const;
48
48 // ImageLoadingTracker::Observer implementation. 49 // ImageLoadingTracker::Observer implementation.
49 virtual void OnImageLoaded(const gfx::Image& image, 50 virtual void OnImageLoaded(const gfx::Image& image,
50 const std::string& extension_id, 51 const std::string& extension_id,
51 int index) OVERRIDE; 52 int index) OVERRIDE;
52 53
53 private: 54 private:
54 // Struct to store the usage information of the capture devices for each tab. 55 // Struct to store the usage information of the capture devices for each tab.
55 // TODO(estade): this should be called CaptureDeviceContents; not all the 56 // TODO(estade): this should be called CaptureDeviceContents; not all the
56 // render views it represents are tabs. 57 // render views it represents are tabs.
57 struct CaptureDeviceTab { 58 struct CaptureDeviceTab {
(...skipping 17 matching lines...) Expand all
75 TabEquals(int render_process_id, int render_view_id); 76 TabEquals(int render_process_id, int render_view_id);
76 77
77 bool operator() ( 78 bool operator() (
78 const MediaStreamCaptureIndicator::CaptureDeviceTab& tab); 79 const MediaStreamCaptureIndicator::CaptureDeviceTab& tab);
79 80
80 private: 81 private:
81 int render_process_id_; 82 int render_process_id_;
82 int render_view_id_; 83 int render_view_id_;
83 }; 84 };
84 85
85 friend class base::RefCountedThreadSafe<MediaStreamCaptureIndicator>;
86 virtual ~MediaStreamCaptureIndicator();
87
88 // Called by the public functions, executed on UI thread. 86 // Called by the public functions, executed on UI thread.
89 void DoDevicesOpenedOnUIThread(int render_process_id, 87 void DoDevicesOpenedOnUIThread(int render_process_id,
90 int render_view_id, 88 int render_view_id,
91 const content::MediaStreamDevices& devices); 89 const content::MediaStreamDevices& devices);
92 void DoDevicesClosedOnUIThread(int render_process_id, 90 void DoDevicesClosedOnUIThread(int render_process_id,
93 int render_view_id, 91 int render_view_id,
94 const content::MediaStreamDevices& devices); 92 const content::MediaStreamDevices& devices);
95 93
96 // Following functions/variables are executed/accessed only on UI thread. 94 // Following functions/variables are executed/accessed only on UI thread.
97 // Creates the status tray if it has not been created. 95 // Creates the status tray if it has not been created.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 typedef std::vector<CaptureDeviceTab> CaptureDeviceTabs; 142 typedef std::vector<CaptureDeviceTab> CaptureDeviceTabs;
145 CaptureDeviceTabs tabs_; 143 CaptureDeviceTabs tabs_;
146 144
147 // Tracks the load of extension icons. 145 // Tracks the load of extension icons.
148 scoped_ptr<ImageLoadingTracker> tracker_; 146 scoped_ptr<ImageLoadingTracker> tracker_;
149 // The messages to display when extension images are loaded. The index 147 // The messages to display when extension images are loaded. The index
150 // corresponds to the index of the associated LoadImage request. 148 // corresponds to the index of the associated LoadImage request.
151 std::map<int, string16> pending_messages_; 149 std::map<int, string16> pending_messages_;
152 // Tracks the number of requests to |tracker_|. 150 // Tracks the number of requests to |tracker_|.
153 int request_index_; 151 int request_index_;
152
153 base::WeakPtrFactory<MediaStreamCaptureIndicator> weak_ptr_factory_;
154
155 DISALLOW_COPY_AND_ASSIGN(MediaStreamCaptureIndicator);
154 }; 156 };
155 157
156 #endif // CHROME_BROWSER_MEDIA_MEDIA_STREAM_CAPTURE_INDICATOR_H_ 158 #endif // CHROME_BROWSER_MEDIA_MEDIA_STREAM_CAPTURE_INDICATOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/media/media_internals.cc ('k') | chrome/browser/media/media_stream_capture_indicator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698