summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/webui/options/media_devices_selection_handler.h
blob: d9478367cc2083b4ee123b2cff3298e5e8b3751e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_MEDIA_DEVICES_SELECTION_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_OPTIONS_MEDIA_DEVICES_SELECTION_HANDLER_H_

#include "base/macros.h"
#include "chrome/browser/media/media_capture_devices_dispatcher.h"
#include "chrome/browser/ui/webui/options/options_ui.h"
#include "content/public/browser/web_contents.h"

namespace options {

// Handler for media devices selection in content settings.
class MediaDevicesSelectionHandler
    : public MediaCaptureDevicesDispatcher::Observer,
      public OptionsPageUIHandler {
 public:
  MediaDevicesSelectionHandler();
  ~MediaDevicesSelectionHandler() override;

  // OptionsPageUIHandler implementation.
  void GetLocalizedValues(base::DictionaryValue* values) override;
  void InitializePage() override;
  void RegisterMessages() override;

  // MediaCaptureDevicesDispatcher::Observer implementation.
  void OnUpdateAudioDevices(
      const content::MediaStreamDevices& devices) override;
  void OnUpdateVideoDevices(
      const content::MediaStreamDevices& devices) override;

 private:
  enum DeviceType {
    AUDIO,
    VIDEO,
  };

  // Sets the default audio/video capture device for media. |args| includes the
  // media type (kAuudio/kVideo) and the unique id of the new default device
  // that the user has chosen.
  void SetDefaultCaptureDevice(const base::ListValue* args);

  // Helpers methods to update the device menus.
  void UpdateDevicesMenuForType(DeviceType type);
  void UpdateDevicesMenu(DeviceType type,
                         const content::MediaStreamDevices& devices);

  DISALLOW_COPY_AND_ASSIGN(MediaDevicesSelectionHandler);
};

}  // namespace options

#endif  // CHROME_BROWSER_UI_WEBUI_OPTIONS_MEDIA_DEVICES_SELECTION_HANDLER_H_