blob: 787c9a0b47ab31edd4f998b8b254d632d7ad4dbc [file] [log] [blame]
// Copyright 2020 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 "base/optional.h"
#include "base/stl_util.h"
#include "url/gurl.h"
namespace ui {
// EndpointType can represent either the source of the clipboard data or the
// destination trying to read the clipboard data.
// Whenever a new format is supported, a new enum should be added.
enum class EndpointType {
kUrl = 0, // Website URL e.g.
kVm = 1, // Virtual machine: ARC++, PluginVM, Crostini.
kMaxValue = kVm
// ClipboardDataEndpoint can represent:
// - The source of the data in the clipboard.
// - The destination trying to access the clipboard data.
explicit ClipboardDataEndpoint(const GURL& url);
// This constructor shouldn't be used if |type| == EndpointType::kUrl.
explicit ClipboardDataEndpoint(EndpointType type);
ClipboardDataEndpoint(const ClipboardDataEndpoint& other);
ClipboardDataEndpoint(ClipboardDataEndpoint&& other);
ClipboardDataEndpoint& operator=(const ClipboardDataEndpoint& other) = delete;
ClipboardDataEndpoint& operator=(ClipboardDataEndpoint&& other) = delete;
bool operator==(const ClipboardDataEndpoint& other) const;
bool IsUrlType() const { return type_ == EndpointType::kUrl; }
const GURL* url() const { return base::OptionalOrNullptr(url_); }
EndpointType type() const { return type_; }
// This variable should always have a value representing the object type.
const EndpointType type_;
// The url of the data endpoint. It always has a value if |type_| ==
// EndpointType::URL, otherwise it's empty.
const base::Optional<GURL> url_;
} // namespace ui