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 #ifndef CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_MEDIA_MENU_MODEL_H_ 6 #define CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_MEDIA_MENU_MODEL_H_ 7 8 #include <map> 9 10 #include "base/callback.h" 11 #include "content/public/common/media_stream_request.h" 12 #include "ui/base/models/simple_menu_model.h" 13 14 class ContentSettingBubbleModel; 15 16 // A menu model that builds the contents of the media capture devices menu in 17 // the content setting bubble. 18 class ContentSettingMediaMenuModel : public ui::SimpleMenuModel, 19 public ui::SimpleMenuModel::Delegate { 20 public: 21 // Callback to update the label of the menu in the UI. 22 typedef base::Callback<void(content::MediaStreamType, const std::string&)> 23 MenuLabelChangedCallback; 24 25 ContentSettingMediaMenuModel( 26 content::MediaStreamType type, 27 ContentSettingBubbleModel* bubble_model, 28 const MenuLabelChangedCallback& callback); 29 virtual ~ContentSettingMediaMenuModel(); 30 31 // ui::SimpleMenuModel::Delegate: 32 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; 33 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; 34 virtual bool GetAcceleratorForCommandId( 35 int command_id, 36 ui::Accelerator* accelerator) OVERRIDE; 37 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; 38 39 private: 40 typedef std::map<int, content::MediaStreamDevice> CommandMap; 41 42 content::MediaStreamType type_; 43 ContentSettingBubbleModel* media_bubble_model_; // Weak. 44 MenuLabelChangedCallback callback_; 45 CommandMap commands_; 46 47 DISALLOW_COPY_AND_ASSIGN(ContentSettingMediaMenuModel); 48 }; 49 50 #endif // CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_MEDIA_MENU_MODEL_H_ 51