forked from mirror/chromium
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DoNotCarryForward] Clipboard: move various predefined FormatTypes to…
… common file. Many clipboard implementations use the predefined FormatTypes from the clipboard_aurax11. Thus, to make clipboard ozone use them as well, move those into a separate clipboard_linux file and include it when necessary. Change-Id: Iec6b6aacecc567a35534a170fb50afff7e978140
- Loading branch information
1 parent
6596541
commit 873dde0
Showing
3 changed files
with
126 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
// Copyright 2018 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.h" | ||
|
||
namespace ui { | ||
|
||
namespace { | ||
constexpr char kMimeTypeFilename[] = "chromium/filename"; | ||
} | ||
|
||
// I would love for the FormatType to really be a wrapper around an X11 ::Atom, | ||
// but there are a few problems. Chromeos unit tests spawn a new X11 server for | ||
// each test, so Atom numeric values don't persist across tests. We could still | ||
// maybe deal with that if we didn't have static accessor methods everywhere. | ||
|
||
Clipboard::FormatType::FormatType() {} | ||
|
||
Clipboard::FormatType::FormatType(const std::string& native_format) | ||
: data_(native_format) {} | ||
|
||
Clipboard::FormatType::~FormatType() {} | ||
|
||
std::string Clipboard::FormatType::Serialize() const { | ||
return data_; | ||
} | ||
|
||
// static | ||
Clipboard::FormatType Clipboard::FormatType::Deserialize( | ||
const std::string& serialization) { | ||
return FormatType(serialization); | ||
} | ||
|
||
bool Clipboard::FormatType::operator<(const FormatType& other) const { | ||
return data_ < other.data_; | ||
} | ||
|
||
bool Clipboard::FormatType::Equals(const FormatType& other) const { | ||
return data_ == other.data_; | ||
} | ||
|
||
// Various predefined FormatTypes. | ||
// static | ||
Clipboard::FormatType Clipboard::GetFormatType( | ||
const std::string& format_string) { | ||
return FormatType::Deserialize(format_string); | ||
} | ||
|
||
// static | ||
const Clipboard::FormatType& Clipboard::GetUrlFormatType() { | ||
static base::NoDestructor<FormatType> type(kMimeTypeURIList); | ||
return *type; | ||
} | ||
|
||
// static | ||
const Clipboard::FormatType& Clipboard::GetUrlWFormatType() { | ||
return GetUrlFormatType(); | ||
} | ||
|
||
// static | ||
const Clipboard::FormatType& Clipboard::GetMozUrlFormatType() { | ||
static base::NoDestructor<FormatType> type(kMimeTypeMozillaURL); | ||
return *type; | ||
} | ||
|
||
// static | ||
const Clipboard::FormatType& Clipboard::GetPlainTextFormatType() { | ||
static base::NoDestructor<FormatType> type(kMimeTypeText); | ||
return *type; | ||
} | ||
|
||
// static | ||
const Clipboard::FormatType& Clipboard::GetPlainTextWFormatType() { | ||
return GetPlainTextFormatType(); | ||
} | ||
|
||
// static | ||
const Clipboard::FormatType& Clipboard::GetFilenameFormatType() { | ||
static base::NoDestructor<FormatType> type(kMimeTypeFilename); | ||
return *type; | ||
} | ||
|
||
// static | ||
const Clipboard::FormatType& Clipboard::GetFilenameWFormatType() { | ||
return Clipboard::GetFilenameFormatType(); | ||
} | ||
|
||
// static | ||
const Clipboard::FormatType& Clipboard::GetHtmlFormatType() { | ||
static base::NoDestructor<FormatType> type(kMimeTypeHTML); | ||
return *type; | ||
} | ||
|
||
// static | ||
const Clipboard::FormatType& Clipboard::GetRtfFormatType() { | ||
static base::NoDestructor<FormatType> type(kMimeTypeRTF); | ||
return *type; | ||
} | ||
|
||
// static | ||
const Clipboard::FormatType& Clipboard::GetBitmapFormatType() { | ||
static base::NoDestructor<FormatType> type(kMimeTypePNG); | ||
return *type; | ||
} | ||
|
||
// static | ||
const Clipboard::FormatType& Clipboard::GetWebKitSmartPasteFormatType() { | ||
static base::NoDestructor<FormatType> type(kMimeTypeWebkitSmartPaste); | ||
return *type; | ||
} | ||
|
||
// static | ||
const Clipboard::FormatType& Clipboard::GetWebCustomDataFormatType() { | ||
static base::NoDestructor<FormatType> type(kMimeTypeWebCustomData); | ||
return *type; | ||
} | ||
|
||
// static | ||
const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() { | ||
static base::NoDestructor<FormatType> type(kMimeTypePepperCustomData); | ||
return *type; | ||
} | ||
|
||
} // namespace ui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters