OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_MEDIA_MEDIA_STREAM_CAPTURE_INDICATOR_H_ | |
6 #define CHROME_BROWSER_MEDIA_MEDIA_STREAM_CAPTURE_INDICATOR_H_ | |
7 #pragma once | |
8 | |
9 #include <list> | |
10 #include <string> | |
11 | |
12 #include "content/public/common/media_stream_request.h" | |
13 #include "third_party/skia/include/core/SkBitmap.h" | |
14 #include "ui/base/models/simple_menu_model.h" | |
15 | |
16 class StatusIcon; | |
17 class StatusTray; | |
18 | |
19 class MediaStreamCaptureIndicator : public ui::SimpleMenuModel::Delegate { | |
20 public: | |
21 explicit MediaStreamCaptureIndicator(); | |
22 virtual ~MediaStreamCaptureIndicator(); | |
23 | |
24 // Overrides from SimpleMenuModel::Delegate implementation. | |
25 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | |
26 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | |
27 virtual bool GetAcceleratorForCommandId( | |
28 int command_id, ui::Accelerator* accelerator) OVERRIDE; | |
tommi (sloooow) - chröme
2012/04/24 11:36:18
nit: use a consistent way of wrapping (see e.g. be
no longer working on chromium
2012/04/25 13:52:51
Done.
| |
29 virtual void ExecuteCommand(int command_id) OVERRIDE; | |
30 | |
31 // Called every time MediaStream opens the capture devices. | |
32 void OnCaptureDevicesOpened(const std::string& url, | |
33 const content::MediaStreamDevices& devices); | |
34 | |
35 // Called every time the MediaStream closes the opened devices. | |
36 void OnCaptureDevicesClosed(const std::string& url, | |
37 const content::MediaStreamDevices& devices); | |
38 | |
39 private: | |
40 struct CaptureDeviceUser { | |
tommi (sloooow) - chröme
2012/04/24 11:36:18
Please add some documentation. It's not immediate
no longer working on chromium
2012/04/25 13:52:51
Done.
| |
41 CaptureDeviceUser(const std::string& url, | |
42 const std::string device, | |
43 content::MediaStreamDeviceType type) | |
44 : url(url), | |
45 device(device), | |
46 type(type) {} | |
47 | |
48 std::string url; | |
49 std::string device; | |
50 content::MediaStreamDeviceType type; | |
51 }; | |
52 | |
53 // Creates the status tray if it has not been created. | |
54 void CreateStatusTray(); | |
55 | |
56 // Makes sure we have done one-time initialization of the |icon_image_|. | |
57 void EnsureStatusTrayIcon(); | |
58 | |
59 // Triggers a balloon in the corner telling users devices are being used. | |
60 void ShowBalloon(const std::string& url, | |
61 const content::MediaStreamDevices& devices); | |
62 | |
63 // Hides the status tray from the desktop. | |
64 void Hide(); | |
65 | |
66 // Adds the new user to the device usage list. | |
67 void AddCaptureDeviceUser(const std::string& url, | |
68 const content::MediaStreamDevices& devices); | |
69 | |
70 // Removes the user from the device usage list. | |
71 void RemoveCaptureDeviceUser(const std::string& url, | |
72 const content::MediaStreamDevices& devices); | |
73 | |
74 // Updates the status tray menu with the new device list. This call will be | |
75 // triggered by both |AddCaptureDeviceUser| and |RemoveCaptureDeviceUser|. | |
76 void UpdateStatusTrayIconContextMenu(); | |
77 | |
78 // Reference to our status icon - owned by the StatusTray. If null, | |
79 // the platform doesn't support status icons. | |
80 StatusIcon* status_icon_; | |
81 | |
82 // Icon to be displayed on the status tray. | |
83 SkBitmap icon_image_; | |
84 | |
85 typedef std::list<CaptureDeviceUser> CaptureDeviceUserList; | |
86 CaptureDeviceUserList users_; | |
87 }; | |
88 | |
89 #endif // CHROME_BROWSER_MEDIA_MEDIA_STREAM_CAPTURE_INDICATOR_H_ | |
OLD | NEW |