summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/media/webrtc/desktop_media_picker_manager.h
blob: 391994156e6083c7bcd3cdad60fee10707d8b204 (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
// Copyright 2019 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_MEDIA_WEBRTC_DESKTOP_MEDIA_PICKER_MANAGER_H_
#define CHROME_BROWSER_MEDIA_WEBRTC_DESKTOP_MEDIA_PICKER_MANAGER_H_

#include "base/macros.h"
#include "base/observer_list.h"

namespace base {
template <typename T>
class NoDestructor;
}

// A singleton that acts as a rendezvous for dialog observers to register and
// the dialog managers/delegates to post their activities.
// TODO(crbug/953495): Merge this into DesktopMediaPickerFactoryImpl.
class DesktopMediaPickerManager {
 public:
  class DialogObserver : public base::CheckedObserver {
   public:
    // Called when a media dialog is opened/shown.
    virtual void OnDialogOpened() = 0;

    // Called when a media dialog is closed/hidden.
    virtual void OnDialogClosed() = 0;
  };

  static DesktopMediaPickerManager* Get();

  // For the observers
  void AddObserver(DialogObserver* observer);
  void RemoveObserver(DialogObserver* observer);

  // For the notifiers
  void OnShowDialog();
  void OnHideDialog();

 private:
  friend base::NoDestructor<DesktopMediaPickerManager>;

  DesktopMediaPickerManager();
  ~DesktopMediaPickerManager();  // Never called.

  base::ObserverList<DesktopMediaPickerManager::DialogObserver> observers_;

  DISALLOW_COPY_AND_ASSIGN(DesktopMediaPickerManager);
};

#endif  // CHROME_BROWSER_MEDIA_WEBRTC_DESKTOP_MEDIA_PICKER_MANAGER_H_