| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/ui/content_settings/content_setting_media_menu_model.h" | 5 #include "chrome/browser/ui/content_settings/content_setting_media_menu_model.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 8 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
| 9 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 9 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 media_bubble_model_->content_type()); | 22 media_bubble_model_->content_type()); |
| 23 MediaCaptureDevicesDispatcher* dispatcher = | 23 MediaCaptureDevicesDispatcher* dispatcher = |
| 24 MediaCaptureDevicesDispatcher::GetInstance(); | 24 MediaCaptureDevicesDispatcher::GetInstance(); |
| 25 const content::MediaStreamDevices& devices = | 25 const content::MediaStreamDevices& devices = |
| 26 (type_ == content::MEDIA_DEVICE_AUDIO_CAPTURE) ? | 26 (type_ == content::MEDIA_DEVICE_AUDIO_CAPTURE) ? |
| 27 dispatcher->GetAudioCaptureDevices() : | 27 dispatcher->GetAudioCaptureDevices() : |
| 28 dispatcher->GetVideoCaptureDevices(); | 28 dispatcher->GetVideoCaptureDevices(); |
| 29 | 29 |
| 30 for (size_t i = 0; i < devices.size(); ++i) { | 30 for (size_t i = 0; i < devices.size(); ++i) { |
| 31 commands_.insert(std::make_pair(commands_.size(), devices[i])); | 31 commands_.insert(std::make_pair(commands_.size(), devices[i])); |
| 32 AddItem(i, UTF8ToUTF16(devices[i].name)); | 32 AddItem(i, base::UTF8ToUTF16(devices[i].name)); |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 | 35 |
| 36 ContentSettingMediaMenuModel::~ContentSettingMediaMenuModel() { | 36 ContentSettingMediaMenuModel::~ContentSettingMediaMenuModel() { |
| 37 } | 37 } |
| 38 | 38 |
| 39 bool ContentSettingMediaMenuModel::IsCommandIdChecked(int command_id) const { | 39 bool ContentSettingMediaMenuModel::IsCommandIdChecked(int command_id) const { |
| 40 return false; | 40 return false; |
| 41 } | 41 } |
| 42 | 42 |
| 43 bool ContentSettingMediaMenuModel::IsCommandIdEnabled(int command_id) const { | 43 bool ContentSettingMediaMenuModel::IsCommandIdEnabled(int command_id) const { |
| 44 return true; | 44 return true; |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool ContentSettingMediaMenuModel::GetAcceleratorForCommandId( | 47 bool ContentSettingMediaMenuModel::GetAcceleratorForCommandId( |
| 48 int command_id, | 48 int command_id, |
| 49 ui::Accelerator* accelerator) { | 49 ui::Accelerator* accelerator) { |
| 50 return false; | 50 return false; |
| 51 } | 51 } |
| 52 | 52 |
| 53 void ContentSettingMediaMenuModel::ExecuteCommand(int command_id, | 53 void ContentSettingMediaMenuModel::ExecuteCommand(int command_id, |
| 54 int event_flags) { | 54 int event_flags) { |
| 55 CommandMap::const_iterator it = commands_.find(command_id); | 55 CommandMap::const_iterator it = commands_.find(command_id); |
| 56 DCHECK(it != commands_.end()); | 56 DCHECK(it != commands_.end()); |
| 57 media_bubble_model_->OnMediaMenuClicked(type_, it->second.id); | 57 media_bubble_model_->OnMediaMenuClicked(type_, it->second.id); |
| 58 | 58 |
| 59 if (!callback_.is_null()) | 59 if (!callback_.is_null()) |
| 60 callback_.Run(type_, it->second.name); | 60 callback_.Run(type_, it->second.name); |
| 61 } | 61 } |
| OLD | NEW |