blob: e9e8cbe79606d094e415759a9ce52fc23dfa6ce5 [file] [log] [blame]
// Copyright (c) 2016 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 "ui/base/clipboard/clipboard_monitor.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/clipboard/clipboard_observer.h"
namespace ui {
ClipboardMonitor::ClipboardMonitor() {}
ClipboardMonitor::~ClipboardMonitor() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
}
// static
ClipboardMonitor* ClipboardMonitor::GetInstance() {
static base::NoDestructor<ClipboardMonitor> monitor;
return monitor.get();
}
void ClipboardMonitor::NotifyClipboardDataChanged() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
for (ClipboardObserver& observer : observers_)
observer.OnClipboardDataChanged();
}
void ClipboardMonitor::AddObserver(ClipboardObserver* observer) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
observers_.AddObserver(observer);
}
void ClipboardMonitor::RemoveObserver(ClipboardObserver* observer) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
observers_.RemoveObserver(observer);
}
} // namespace ui