| 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_DEVICES_MENU_MODEL_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_MENU_MODEL_H_ |
| 6 #define CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_MENU_MODEL_H_ | 6 #define CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_MENU_MODEL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "content/public/common/media_stream_request.h" | 11 #include "content/public/common/media_stream_request.h" |
| 12 #include "ui/base/models/simple_menu_model.h" | 12 #include "ui/base/models/simple_menu_model.h" |
| 13 | 13 |
| 14 class MediaStreamInfoBarDelegate; | 14 class MediaStreamInfoBarDelegate; |
| 15 | 15 |
| 16 // A menu model that builds the contents of the devices menu in the media stream | 16 // A menu model that builds the contents of the devices menu in the media stream |
| 17 // infobar. This menu has only one level (no submenus). | 17 // infobar. This menu has only one level (no submenus). |
| 18 class MediaStreamDevicesMenuModel : public ui::SimpleMenuModel, | 18 class MediaStreamDevicesMenuModel : public ui::SimpleMenuModel, |
| 19 public ui::SimpleMenuModel::Delegate { | 19 public ui::SimpleMenuModel::Delegate { |
| 20 public: | 20 public: |
| 21 explicit MediaStreamDevicesMenuModel(MediaStreamInfoBarDelegate* delegate); | 21 explicit MediaStreamDevicesMenuModel(MediaStreamInfoBarDelegate* delegate); |
| 22 virtual ~MediaStreamDevicesMenuModel(); | 22 virtual ~MediaStreamDevicesMenuModel(); |
| 23 | 23 |
| 24 // Returns the |device_id| for the selected device of type |type|. Returns | |
| 25 // true if a selected device of the requested |type| was found, and false if | |
| 26 // none was found, in which case |device_id| remains untouched. | |
| 27 bool GetSelectedDeviceId( | |
| 28 content::MediaStreamDeviceType type, | |
| 29 std::string* device_id) const; | |
| 30 | |
| 31 // ui::SimpleMenuModel::Delegate implementation: | 24 // ui::SimpleMenuModel::Delegate implementation: |
| 32 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | 25 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
| 33 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | 26 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
| 34 virtual bool GetAcceleratorForCommandId( | 27 virtual bool GetAcceleratorForCommandId( |
| 35 int command_id, | 28 int command_id, |
| 36 ui::Accelerator* accelerator) OVERRIDE; | 29 ui::Accelerator* accelerator) OVERRIDE; |
| 37 virtual void ExecuteCommand(int command_id) OVERRIDE; | 30 virtual void ExecuteCommand(int command_id) OVERRIDE; |
| 38 | 31 |
| 39 private: | 32 private: |
| 40 typedef std::map<int, content::MediaStreamDevice> CommandMap; | 33 typedef std::map<int, content::MediaStreamDevice> CommandMap; |
| 41 | 34 |
| 42 // Internal method to add the |devices| to the current menu. | 35 // Internal method to add the |devices| to the current menu. |
| 43 void AddDevices(const content::MediaStreamDevices& devices); | 36 void AddDevices(const content::MediaStreamDevices& devices); |
| 44 | 37 |
| 45 // Internal method to add "always allow" option to the current menu. | 38 // Internal method to add "always allow" option to the current menu. |
| 46 void AddAlwaysAllowOption(bool audio, bool video); | 39 void AddAlwaysAllowOption(bool audio, bool video); |
| 47 | 40 |
| 48 // Map of command IDs to devices. | 41 // Map of command IDs to devices. |
| 49 CommandMap commands_; | 42 CommandMap commands_; |
| 50 | 43 |
| 51 MediaStreamInfoBarDelegate* media_stream_delegate_; | 44 MediaStreamInfoBarDelegate* media_stream_delegate_; |
| 52 | 45 |
| 53 DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesMenuModel); | 46 DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesMenuModel); |
| 54 }; | 47 }; |
| 55 | 48 |
| 56 #endif // CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_MENU_MODEL_H_ | 49 #endif // CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_MENU_MODEL_H_ |
| OLD | NEW |