Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 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 #include "chrome/browser/ui/content_settings/content_setting_media_menu_model.h" | |
| 6 | |
| 7 #include "base/prefs/pref_service.h" | |
| 8 #include "base/utf_string_conversions.h" | |
| 9 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | |
| 10 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | |
| 11 #include "chrome/common/pref_names.h" | |
| 12 | |
| 13 ContentSettingMediaMenuModel::ContentSettingMediaMenuModel( | |
| 14 PrefService* prefs, | |
| 15 content::MediaStreamType type, | |
| 16 ContentSettingBubbleModel* bubble_model, | |
| 17 const MenuLabelChangedCallback& callback) | |
| 18 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), | |
| 19 prefs_(prefs), | |
| 20 type_(type), | |
| 21 media_bubble_model_(bubble_model), | |
| 22 callback_(callback) { | |
| 23 DCHECK(type_ == content::MEDIA_DEVICE_AUDIO_CAPTURE || | |
| 24 type_ == content::MEDIA_DEVICE_VIDEO_CAPTURE); | |
| 25 DCHECK_EQ(CONTENT_SETTINGS_TYPE_MEDIASTREAM, | |
| 26 media_bubble_model_->content_type()); | |
| 27 MediaCaptureDevicesDispatcher* dispatcher = | |
| 28 MediaCaptureDevicesDispatcher::GetInstance(); | |
| 29 content::MediaStreamDevices devices; | |
| 30 std::string default_device; | |
|
Peter Kasting
2013/02/18 18:23:18
What do we even use this for? It looks like we se
no longer working on chromium
2013/02/19 14:37:36
It was used to marked the default device as a chec
| |
| 31 if (type_ == content::MEDIA_DEVICE_AUDIO_CAPTURE) { | |
| 32 devices = dispatcher->GetAudioCaptureDevices(); | |
| 33 default_device = prefs_->GetString(prefs::kDefaultAudioCaptureDevice); | |
| 34 } else { | |
| 35 devices = dispatcher->GetVideoCaptureDevices(); | |
| 36 default_device = prefs_->GetString(prefs::kDefaultVideoCaptureDevice); | |
| 37 } | |
| 38 | |
| 39 for (size_t i = 0; i < devices.size(); ++i) { | |
| 40 commands_.insert(std::make_pair(commands_.size(), devices[i])); | |
| 41 AddItem(i, UTF8ToUTF16(devices[i].name)); | |
| 42 } | |
| 43 } | |
| 44 | |
| 45 ContentSettingMediaMenuModel::~ContentSettingMediaMenuModel() { | |
| 46 } | |
| 47 | |
| 48 bool ContentSettingMediaMenuModel::IsCommandIdChecked(int command_id) const { | |
| 49 return false; | |
| 50 } | |
| 51 | |
| 52 bool ContentSettingMediaMenuModel::IsCommandIdEnabled(int command_id) const { | |
| 53 return true; | |
| 54 } | |
| 55 | |
| 56 bool ContentSettingMediaMenuModel::GetAcceleratorForCommandId( | |
| 57 int command_id, | |
| 58 ui::Accelerator* accelerator) { | |
| 59 return false; | |
| 60 } | |
| 61 | |
| 62 void ContentSettingMediaMenuModel::ExecuteCommand(int command_id) { | |
| 63 CommandMap::const_iterator it = commands_.find(command_id); | |
| 64 DCHECK(it != commands_.end()); | |
| 65 media_bubble_model_->OnMediaMenuClicked(type_, it->second.id); | |
| 66 | |
| 67 if (!callback_.is_null()) | |
| 68 callback_.Run(type_, it->second.name); | |
| 69 } | |
| OLD | NEW |