#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "ui/base/x/x11_clipboard_helper.h"
#include <string>
#include <vector>
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/singleton.h"
#include "base/metrics/histogram_macros.h"
#include "base/time/time.h"
#include "ui/base/clipboard/clipboard_buffer.h"
#include "ui/base/clipboard/clipboard_constants.h"
#include "ui/base/ui_base_features.h"
#include "ui/base/x/selection_owner.h"
#include "ui/base/x/selection_requestor.h"
#include "ui/base/x/selection_utils.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/x/atom_cache.h"
#include "ui/gfx/x/event.h"
#include "ui/gfx/x/window_event_manager.h"
#include "ui/gfx/x/xfixes.h"
#include "ui/gfx/x/xproto.h"
namespace ui {
namespace {
const char kClipboard[] = …;
const char kClipboardManager[] = …;
class SelectionChangeObserver : public x11::EventObserver { … };
SelectionChangeObserver::SelectionChangeObserver()
: … { … }
SelectionChangeObserver* SelectionChangeObserver::Get() { … }
void SelectionChangeObserver::OnEvent(const x11::Event& xev) { … }
x11::Window GetSelectionOwner(x11::Atom selection) { … }
}
class XClipboardHelper::TargetList { … };
XClipboardHelper::XClipboardHelper(
SelectionChangeCallback selection_change_callback)
: … { … }
XClipboardHelper::~XClipboardHelper() { … }
void XClipboardHelper::CreateNewClipboardData() { … }
void XClipboardHelper::InsertMapping(
const std::string& key,
const scoped_refptr<base::RefCountedMemory>& memory) { … }
void XClipboardHelper::TakeOwnershipOfSelection(ClipboardBuffer buffer) { … }
SelectionData XClipboardHelper::Read(ClipboardBuffer buffer,
const std::vector<x11::Atom>& types) { … }
std::vector<std::string> XClipboardHelper::GetAvailableTypes(
ClipboardBuffer buffer) { … }
std::vector<std::string> XClipboardHelper::GetAvailableAtomNames(
ClipboardBuffer buffer) { … }
bool XClipboardHelper::IsFormatAvailable(ClipboardBuffer buffer,
const ClipboardFormatType& format) { … }
bool XClipboardHelper::IsSelectionOwner(ClipboardBuffer buffer) const { … }
std::vector<x11::Atom> XClipboardHelper::GetTextAtoms() const { … }
std::vector<x11::Atom> XClipboardHelper::GetAtomsForFormat(
const ClipboardFormatType& format) { … }
void XClipboardHelper::Clear(ClipboardBuffer buffer) { … }
void XClipboardHelper::StoreCopyPasteDataAndWait() { … }
XClipboardHelper::TargetList XClipboardHelper::GetTargetList(
ClipboardBuffer buffer) { … }
bool XClipboardHelper::DispatchEvent(const x11::Event& xev) { … }
SelectionRequestor* XClipboardHelper::GetSelectionRequestorForTest() { … }
void XClipboardHelper::OnEvent(const x11::Event& xev) { … }
x11::Atom XClipboardHelper::LookupSelectionForClipboardBuffer(
ClipboardBuffer buffer) const { … }
x11::Atom XClipboardHelper::GetCopyPasteSelection() const { … }
const SelectionFormatMap& XClipboardHelper::LookupStorageForAtom(
x11::Atom atom) { … }
}