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

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

Issue 12208010: Adding device selection menus to the content setting bubble (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed the final comments. Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
(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/utf_string_conversions.h"
8 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
9 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
10
11 ContentSettingMediaMenuModel::ContentSettingMediaMenuModel(
12 content::MediaStreamType type,
13 ContentSettingBubbleModel* bubble_model,
14 const MenuLabelChangedCallback& callback)
15 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)),
16 type_(type),
17 media_bubble_model_(bubble_model),
18 callback_(callback) {
19 DCHECK(type_ == content::MEDIA_DEVICE_AUDIO_CAPTURE ||
20 type_ == content::MEDIA_DEVICE_VIDEO_CAPTURE);
21 DCHECK_EQ(CONTENT_SETTINGS_TYPE_MEDIASTREAM,
22 media_bubble_model_->content_type());
23 MediaCaptureDevicesDispatcher* dispatcher =
24 MediaCaptureDevicesDispatcher::GetInstance();
25 const content::MediaStreamDevices& devices =
26 (type_ == content::MEDIA_DEVICE_AUDIO_CAPTURE) ?
27 dispatcher->GetAudioCaptureDevices() :
28 dispatcher->GetVideoCaptureDevices();
29
30 for (size_t i = 0; i < devices.size(); ++i) {
31 commands_.insert(std::make_pair(commands_.size(), devices[i]));
32 AddItem(i, UTF8ToUTF16(devices[i].name));
33 }
34 }
35
36 ContentSettingMediaMenuModel::~ContentSettingMediaMenuModel() {
37 }
38
39 bool ContentSettingMediaMenuModel::IsCommandIdChecked(int command_id) const {
40 return false;
41 }
42
43 bool ContentSettingMediaMenuModel::IsCommandIdEnabled(int command_id) const {
44 return true;
45 }
46
47 bool ContentSettingMediaMenuModel::GetAcceleratorForCommandId(
48 int command_id,
49 ui::Accelerator* accelerator) {
50 return false;
51 }
52
53 void ContentSettingMediaMenuModel::ExecuteCommand(int command_id) {
54 CommandMap::const_iterator it = commands_.find(command_id);
55 DCHECK(it != commands_.end());
56 media_bubble_model_->OnMediaMenuClicked(type_, it->second.id);
57
58 if (!callback_.is_null())
59 callback_.Run(type_, it->second.name);
60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698