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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "content/public/common/media_stream_request.h" | 12 #include "content/public/common/media_stream_request.h" |
13 #include "ui/base/models/simple_menu_model.h" | 13 #include "ui/base/models/simple_menu_model.h" |
14 | 14 |
15 class MediaStreamInfoBarDelegate; | 15 class MediaStreamInfoBarDelegate; |
16 | 16 |
17 // A menu model that builds the contents of the devices menu in the media stream | 17 // A menu model that builds the contents of the devices menu in the media stream |
18 // infobar. This menu has only one level (no submenus). | 18 // infobar. This menu has only one level (no submenus). |
19 class MediaStreamDevicesMenuModel : public ui::SimpleMenuModel, | 19 class MediaStreamDevicesMenuModel : public ui::SimpleMenuModel, |
20 public ui::SimpleMenuModel::Delegate { | 20 public ui::SimpleMenuModel::Delegate { |
21 public: | 21 public: |
22 explicit MediaStreamDevicesMenuModel( | 22 explicit MediaStreamDevicesMenuModel(MediaStreamInfoBarDelegate* delegate); |
23 const MediaStreamInfoBarDelegate* delegate); | |
24 virtual ~MediaStreamDevicesMenuModel(); | 23 virtual ~MediaStreamDevicesMenuModel(); |
25 | 24 |
26 // Returns the |device_id| for the selected device of type |type|. Returns | 25 // Returns the |device_id| for the selected device of type |type|. Returns |
27 // true if a selected device of the requested |type| was found, and false if | 26 // true if a selected device of the requested |type| was found, and false if |
28 // none was found, in which case |device_id| remains untouched. | 27 // none was found, in which case |device_id| remains untouched. |
29 bool GetSelectedDeviceId( | 28 bool GetSelectedDeviceId( |
30 content::MediaStreamDeviceType type, | 29 content::MediaStreamDeviceType type, |
31 std::string* device_id) const; | 30 std::string* device_id) const; |
32 | 31 |
32 bool IsAlwaysAllowChecked() { return always_allow_; } | |
tommi (sloooow) - chröme
2012/06/11 20:59:21
bool always_allow() const?
no longer working on chromium
2012/06/14 13:03:25
Done.
| |
33 | |
33 // ui::SimpleMenuModel::Delegate implementation: | 34 // ui::SimpleMenuModel::Delegate implementation: |
34 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | 35 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
35 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | 36 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
36 virtual bool GetAcceleratorForCommandId( | 37 virtual bool GetAcceleratorForCommandId( |
37 int command_id, | 38 int command_id, |
38 ui::Accelerator* accelerator) OVERRIDE; | 39 ui::Accelerator* accelerator) OVERRIDE; |
39 virtual void ExecuteCommand(int command_id) OVERRIDE; | 40 virtual void ExecuteCommand(int command_id) OVERRIDE; |
40 | 41 |
41 private: | 42 private: |
42 typedef std::map<int, content::MediaStreamDevice> CommandMap; | 43 typedef std::map<int, content::MediaStreamDevice> CommandMap; |
43 | 44 |
44 // Internal method to add the |devices| to the current menu. | 45 // Internal method to add the |devices| to the current menu. |
45 void AddDevices(const content::MediaStreamDevices& devices); | 46 void AddDevices(const content::MediaStreamDevices& devices); |
46 | 47 |
48 // Internal method to add "always" and "never" options to the current menu. | |
49 void AddAlwaysAndNeverOptions(bool audio, bool video); | |
50 | |
47 // Map of command IDs to devices. | 51 // Map of command IDs to devices. |
48 CommandMap commands_; | 52 CommandMap commands_; |
49 | 53 |
54 MediaStreamInfoBarDelegate* media_stream_delegate_; | |
tommi (sloooow) - chröme
2012/06/11 20:59:21
document ownership
no longer working on chromium
2012/06/14 13:03:25
Uncleaned debugging code. Remove now.
| |
55 | |
50 // These are the command IDs (key of above |commands_| map) of the selected | 56 // These are the command IDs (key of above |commands_| map) of the selected |
51 // devices entries in the menu, or -1 if there is no selected ID. | 57 // devices entries in the menu, or -1 if there is no selected ID. |
52 int selected_command_id_audio_; | 58 int selected_command_id_audio_; |
53 int selected_command_id_video_; | 59 int selected_command_id_video_; |
54 | 60 |
61 bool always_allow_; | |
62 | |
55 DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesMenuModel); | 63 DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesMenuModel); |
56 }; | 64 }; |
57 | 65 |
58 #endif // CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_MENU_MODEL_H_ | 66 #endif // CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_MENU_MODEL_H_ |
OLD | NEW |