OLD | NEW |
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" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #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 |
24 : public base::RefCountedThreadSafe<MediaStreamCaptureIndicator>, | 23 : public base::RefCountedThreadSafe<MediaStreamCaptureIndicator>, |
25 public ui::SimpleMenuModel::Delegate, | 24 public ui::SimpleMenuModel::Delegate { |
26 public ImageLoadingTracker::Observer { | |
27 public: | 25 public: |
28 MediaStreamCaptureIndicator(); | 26 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 |
48 // Returns true if the render process is capturing media. | 46 // Returns true if the render process is capturing media. |
49 bool IsProcessCapturing(int render_process_id, int render_view_id) const; | 47 bool IsProcessCapturing(int render_process_id, int render_view_id) const; |
50 | 48 |
51 // ImageLoadingTracker::Observer implementation. | 49 // ImageLoader callback. |
52 virtual void OnImageLoaded(const gfx::Image& image, | 50 void OnImageLoaded(const string16& message, const gfx::Image& image); |
53 const std::string& extension_id, | |
54 int index) OVERRIDE; | |
55 | 51 |
56 private: | 52 private: |
57 // Struct to store the usage information of the capture devices for each tab. | 53 // Struct to store the usage information of the capture devices for each tab. |
58 // TODO(estade): this should be called CaptureDeviceContents; not all the | 54 // TODO(estade): this should be called CaptureDeviceContents; not all the |
59 // render views it represents are tabs. | 55 // render views it represents are tabs. |
60 struct CaptureDeviceTab { | 56 struct CaptureDeviceTab { |
61 CaptureDeviceTab(int render_process_id, | 57 CaptureDeviceTab(int render_process_id, |
62 int render_view_id) | 58 int render_view_id) |
63 : render_process_id(render_process_id), | 59 : render_process_id(render_process_id), |
64 render_view_id(render_view_id), | 60 render_view_id(render_view_id), |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 120 |
125 // Updates the status tray menu with the new device list. This call will be | 121 // Updates the status tray menu with the new device list. This call will be |
126 // triggered by both AddCaptureDeviceTab() and RemoveCaptureDeviceTab(). | 122 // triggered by both AddCaptureDeviceTab() and RemoveCaptureDeviceTab(). |
127 void UpdateStatusTrayIconContextMenu(); | 123 void UpdateStatusTrayIconContextMenu(); |
128 | 124 |
129 // Updates the status tray tooltip and image according to which kind of | 125 // Updates the status tray tooltip and image according to which kind of |
130 // devices are being used. This function is called by | 126 // devices are being used. This function is called by |
131 // UpdateStatusTrayIconContextMenu(). | 127 // UpdateStatusTrayIconContextMenu(). |
132 void UpdateStatusTrayIconDisplay(bool audio, bool video); | 128 void UpdateStatusTrayIconDisplay(bool audio, bool video); |
133 | 129 |
134 // Initializes image loading state. | |
135 void EnsureImageLoadingTracker(); | |
136 | |
137 // Reference to our status icon - owned by the StatusTray. If null, | 130 // Reference to our status icon - owned by the StatusTray. If null, |
138 // the platform doesn't support status icons. | 131 // the platform doesn't support status icons. |
139 StatusIcon* status_icon_; | 132 StatusIcon* status_icon_; |
140 | 133 |
141 // These images are owned by ResourceBundle and need not be destroyed. | 134 // These images are owned by ResourceBundle and need not be destroyed. |
142 gfx::ImageSkia* mic_image_; | 135 gfx::ImageSkia* mic_image_; |
143 gfx::ImageSkia* camera_image_; | 136 gfx::ImageSkia* camera_image_; |
144 gfx::ImageSkia* balloon_image_; | 137 gfx::ImageSkia* balloon_image_; |
145 | 138 |
146 // A list that contains the usage information of the opened capture devices. | 139 // A list that contains the usage information of the opened capture devices. |
147 typedef std::vector<CaptureDeviceTab> CaptureDeviceTabs; | 140 typedef std::vector<CaptureDeviceTab> CaptureDeviceTabs; |
148 CaptureDeviceTabs tabs_; | 141 CaptureDeviceTabs tabs_; |
149 | 142 |
150 // Tracks the load of extension icons. | 143 bool should_show_balloon_; |
151 scoped_ptr<ImageLoadingTracker> tracker_; | |
152 // The messages to display when extension images are loaded. The index | |
153 // corresponds to the index of the associated LoadImage request. | |
154 std::map<int, string16> pending_messages_; | |
155 // Tracks the number of requests to |tracker_|. | |
156 int request_index_; | |
157 }; | 144 }; |
158 | 145 |
159 #endif // CHROME_BROWSER_MEDIA_MEDIA_STREAM_CAPTURE_INDICATOR_H_ | 146 #endif // CHROME_BROWSER_MEDIA_MEDIA_STREAM_CAPTURE_INDICATOR_H_ |
OLD | NEW |