Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Side by Side Diff: chrome/browser/ui/content_settings/content_setting_media_menu_model.cc

Issue 183743021: Implement MediaCaptureDevices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "content/public/browser/media_capture_devices.h"
10 11
11 ContentSettingMediaMenuModel::ContentSettingMediaMenuModel( 12 ContentSettingMediaMenuModel::ContentSettingMediaMenuModel(
12 content::MediaStreamType type, 13 content::MediaStreamType type,
13 ContentSettingBubbleModel* bubble_model, 14 ContentSettingBubbleModel* bubble_model,
14 const MenuLabelChangedCallback& callback) 15 const MenuLabelChangedCallback& callback)
15 : ui::SimpleMenuModel(this), 16 : ui::SimpleMenuModel(this),
16 type_(type), 17 type_(type),
17 media_bubble_model_(bubble_model), 18 media_bubble_model_(bubble_model),
18 callback_(callback) { 19 callback_(callback) {
19 DCHECK(type_ == content::MEDIA_DEVICE_AUDIO_CAPTURE || 20 DCHECK(type_ == content::MEDIA_DEVICE_AUDIO_CAPTURE ||
20 type_ == content::MEDIA_DEVICE_VIDEO_CAPTURE); 21 type_ == content::MEDIA_DEVICE_VIDEO_CAPTURE);
21 DCHECK_EQ(CONTENT_SETTINGS_TYPE_MEDIASTREAM, 22 DCHECK_EQ(CONTENT_SETTINGS_TYPE_MEDIASTREAM,
22 media_bubble_model_->content_type()); 23 media_bubble_model_->content_type());
23 MediaCaptureDevicesDispatcher* dispatcher = 24 content::MediaCaptureDevices* media_capture_devices =
24 MediaCaptureDevicesDispatcher::GetInstance(); 25 content::MediaCaptureDevices::GetInstance();
25 const content::MediaStreamDevices& devices = 26 const content::MediaStreamDevices& devices =
26 (type_ == content::MEDIA_DEVICE_AUDIO_CAPTURE) ? 27 (type_ == content::MEDIA_DEVICE_AUDIO_CAPTURE) ?
27 dispatcher->GetAudioCaptureDevices() : 28 media_capture_devices->GetAudioCaptureDevices() :
28 dispatcher->GetVideoCaptureDevices(); 29 media_capture_devices->GetVideoCaptureDevices();
29 30
30 for (size_t i = 0; i < devices.size(); ++i) { 31 for (size_t i = 0; i < devices.size(); ++i) {
31 commands_.insert(std::make_pair(commands_.size(), devices[i])); 32 commands_.insert(std::make_pair(commands_.size(), devices[i]));
32 AddItem(i, base::UTF8ToUTF16(devices[i].name)); 33 AddItem(i, base::UTF8ToUTF16(devices[i].name));
33 } 34 }
34 } 35 }
35 36
36 ContentSettingMediaMenuModel::~ContentSettingMediaMenuModel() { 37 ContentSettingMediaMenuModel::~ContentSettingMediaMenuModel() {
37 } 38 }
38 39
(...skipping 13 matching lines...) Expand all
52 53
53 void ContentSettingMediaMenuModel::ExecuteCommand(int command_id, 54 void ContentSettingMediaMenuModel::ExecuteCommand(int command_id,
54 int event_flags) { 55 int event_flags) {
55 CommandMap::const_iterator it = commands_.find(command_id); 56 CommandMap::const_iterator it = commands_.find(command_id);
56 DCHECK(it != commands_.end()); 57 DCHECK(it != commands_.end());
57 media_bubble_model_->OnMediaMenuClicked(type_, it->second.id); 58 media_bubble_model_->OnMediaMenuClicked(type_, it->second.id);
58 59
59 if (!callback_.is_null()) 60 if (!callback_.is_null())
60 callback_.Run(type_, it->second.name); 61 callback_.Run(type_, it->second.name);
61 } 62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698