blob: 1f116435a97d3cf01ca0d77c61f8502f4fa4bdf6 [file] [log] [blame]
// 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.
#include <Cocoa/Cocoa.h>
#include "base/no_destructor.h"
#include "content/browser/media/desktop_media_window_registry.h"
namespace content {
class DesktopMediaWindowRegistryMac : public DesktopMediaWindowRegistry {
static DesktopMediaWindowRegistryMac* GetInstance() {
static base::NoDestructor<DesktopMediaWindowRegistryMac> instance;
return instance.get();
DesktopMediaWindowRegistryMac() = default;
Id RegisterWindow(gfx::NativeWindow window) final {
// Note that DesktopMediaPickerViews in //chrome depends on the fact that
// the Id returned from this function is the NSWindow's windowNumber, but
// that invariant is *not* part of the general contract for DesktopMediaID.
return window.GetNativeNSWindow().windowNumber;
gfx::NativeWindow GetWindowById(Id id) final {
return gfx::NativeWindow([NSApp windowWithWindowNumber:id]);
~DesktopMediaWindowRegistryMac() final = default;
// static
DesktopMediaWindowRegistry* DesktopMediaWindowRegistry::GetInstance() {
return DesktopMediaWindowRegistryMac::GetInstance();
} // namespace content