Chromium Code Reviews| Index: chrome/browser/media/media_stream_capture_indicator.h |
| diff --git a/chrome/browser/media/media_stream_capture_indicator.h b/chrome/browser/media/media_stream_capture_indicator.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cce8a879dfbed8e20c926518e03739ca1a179b1b |
| --- /dev/null |
| +++ b/chrome/browser/media/media_stream_capture_indicator.h |
| @@ -0,0 +1,89 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_MEDIA_MEDIA_STREAM_CAPTURE_INDICATOR_H_ |
| +#define CHROME_BROWSER_MEDIA_MEDIA_STREAM_CAPTURE_INDICATOR_H_ |
| +#pragma once |
| + |
| +#include <list> |
| +#include <string> |
| + |
| +#include "content/public/common/media_stream_request.h" |
| +#include "third_party/skia/include/core/SkBitmap.h" |
| +#include "ui/base/models/simple_menu_model.h" |
| + |
| +class StatusIcon; |
| +class StatusTray; |
| + |
| +class MediaStreamCaptureIndicator : public ui::SimpleMenuModel::Delegate { |
| + public: |
| + explicit MediaStreamCaptureIndicator(); |
| + virtual ~MediaStreamCaptureIndicator(); |
| + |
| + // Overrides from SimpleMenuModel::Delegate implementation. |
| + virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
| + virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
| + virtual bool GetAcceleratorForCommandId( |
| + 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.
|
| + virtual void ExecuteCommand(int command_id) OVERRIDE; |
| + |
| + // Called every time MediaStream opens the capture devices. |
| + void OnCaptureDevicesOpened(const std::string& url, |
| + const content::MediaStreamDevices& devices); |
| + |
| + // Called every time the MediaStream closes the opened devices. |
| + void OnCaptureDevicesClosed(const std::string& url, |
| + const content::MediaStreamDevices& devices); |
| + |
| + private: |
| + 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.
|
| + CaptureDeviceUser(const std::string& url, |
| + const std::string device, |
| + content::MediaStreamDeviceType type) |
| + : url(url), |
| + device(device), |
| + type(type) {} |
| + |
| + std::string url; |
| + std::string device; |
| + content::MediaStreamDeviceType type; |
| + }; |
| + |
| + // Creates the status tray if it has not been created. |
| + void CreateStatusTray(); |
| + |
| + // Makes sure we have done one-time initialization of the |icon_image_|. |
| + void EnsureStatusTrayIcon(); |
| + |
| + // Triggers a balloon in the corner telling users devices are being used. |
| + void ShowBalloon(const std::string& url, |
| + const content::MediaStreamDevices& devices); |
| + |
| + // Hides the status tray from the desktop. |
| + void Hide(); |
| + |
| + // Adds the new user to the device usage list. |
| + void AddCaptureDeviceUser(const std::string& url, |
| + const content::MediaStreamDevices& devices); |
| + |
| + // Removes the user from the device usage list. |
| + void RemoveCaptureDeviceUser(const std::string& url, |
| + const content::MediaStreamDevices& devices); |
| + |
| + // Updates the status tray menu with the new device list. This call will be |
| + // triggered by both |AddCaptureDeviceUser| and |RemoveCaptureDeviceUser|. |
| + void UpdateStatusTrayIconContextMenu(); |
| + |
| + // Reference to our status icon - owned by the StatusTray. If null, |
| + // the platform doesn't support status icons. |
| + StatusIcon* status_icon_; |
| + |
| + // Icon to be displayed on the status tray. |
| + SkBitmap icon_image_; |
| + |
| + typedef std::list<CaptureDeviceUser> CaptureDeviceUserList; |
| + CaptureDeviceUserList users_; |
| +}; |
| + |
| +#endif // CHROME_BROWSER_MEDIA_MEDIA_STREAM_CAPTURE_INDICATOR_H_ |