Commit 0024dbfd authored by Darwin Huang's avatar Darwin Huang Committed by Commit Bot

ui/base/clipboard:Update ClipboardFormatType::operator==

Replace ClipboardFormatType's Equals() function with operator==. This
should be more consistent with how Chrome classes tend to test for
equality.

Also, reorder some equality comparisons per Chromium C++ Style Guide[1]
(foo == 0 vs 0 == foo).

[1]: https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#code-formatting

Change-Id: Ia1089e838af392808116cb08410d66a69ca722ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2333572
Commit-Queue: Darwin Huang <huangdarwin@chromium.org>
Auto-Submit: Darwin Huang <huangdarwin@chromium.org>
Reviewed-by: default avatarMarijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#794323}
parent c1f383a9
...@@ -5705,7 +5705,7 @@ void ChromeContentBrowserClient::IsClipboardPasteAllowed( ...@@ -5705,7 +5705,7 @@ void ChromeContentBrowserClient::IsClipboardPasteAllowed(
// Safe browsing does not support images, so accept without checking. // Safe browsing does not support images, so accept without checking.
// TODO(crbug.com/1013584): check policy on what to do about unsupported // TODO(crbug.com/1013584): check policy on what to do about unsupported
// types when it is implemented. // types when it is implemented.
if (data_type.Equals(ui::ClipboardFormatType::GetBitmapType())) { if (data_type == ui::ClipboardFormatType::GetBitmapType()) {
std::move(callback).Run(ClipboardPasteAllowed(true)); std::move(callback).Run(ClipboardPasteAllowed(true));
return; return;
} }
......
...@@ -380,7 +380,7 @@ bool ClipboardAndroid::IsFormatAvailable( ...@@ -380,7 +380,7 @@ bool ClipboardAndroid::IsFormatAvailable(
DCHECK(CalledOnValidThread()); DCHECK(CalledOnValidThread());
DCHECK_EQ(buffer, ClipboardBuffer::kCopyPaste); DCHECK_EQ(buffer, ClipboardBuffer::kCopyPaste);
if (ClipboardFormatType::GetBitmapType().Equals(format)) { if (format == ClipboardFormatType::GetBitmapType()) {
return g_map.Get().HasFormat(kMimeTypeImageURI); return g_map.Get().HasFormat(kMimeTypeImageURI);
} }
return g_map.Get().HasFormat(format.GetName()); return g_map.Get().HasFormat(format.GetName());
......
...@@ -101,7 +101,7 @@ class COMPONENT_EXPORT(UI_BASE_CLIPBOARD_TYPES) ClipboardFormatType { ...@@ -101,7 +101,7 @@ class COMPONENT_EXPORT(UI_BASE_CLIPBOARD_TYPES) ClipboardFormatType {
ClipboardFormatType& operator=(const ClipboardFormatType& other); ClipboardFormatType& operator=(const ClipboardFormatType& other);
#endif #endif
bool Equals(const ClipboardFormatType& other) const; bool operator==(const ClipboardFormatType& other) const;
private: private:
friend class base::NoDestructor<ClipboardFormatType>; friend class base::NoDestructor<ClipboardFormatType>;
......
...@@ -34,7 +34,7 @@ bool ClipboardFormatType::operator<(const ClipboardFormatType& other) const { ...@@ -34,7 +34,7 @@ bool ClipboardFormatType::operator<(const ClipboardFormatType& other) const {
return data_ < other.data_; return data_ < other.data_;
} }
bool ClipboardFormatType::Equals(const ClipboardFormatType& other) const { bool ClipboardFormatType::operator==(const ClipboardFormatType& other) const {
return data_ == other.data_; return data_ == other.data_;
} }
......
...@@ -41,7 +41,7 @@ bool ClipboardFormatType::operator<(const ClipboardFormatType& other) const { ...@@ -41,7 +41,7 @@ bool ClipboardFormatType::operator<(const ClipboardFormatType& other) const {
return data_ < other.data_; return data_ < other.data_;
} }
bool ClipboardFormatType::Equals(const ClipboardFormatType& other) const { bool ClipboardFormatType::operator==(const ClipboardFormatType& other) const {
return data_ == other.data_; return data_ == other.data_;
} }
......
...@@ -29,7 +29,7 @@ ClipboardFormatType& ClipboardFormatType::operator=( ...@@ -29,7 +29,7 @@ ClipboardFormatType& ClipboardFormatType::operator=(
return *this; return *this;
} }
bool ClipboardFormatType::Equals(const ClipboardFormatType& other) const { bool ClipboardFormatType::operator==(const ClipboardFormatType& other) const {
return [data_ isEqualToString:other.data_]; return [data_ isEqualToString:other.data_];
} }
......
...@@ -141,7 +141,7 @@ bool ClipboardFormatType::operator<(const ClipboardFormatType& other) const { ...@@ -141,7 +141,7 @@ bool ClipboardFormatType::operator<(const ClipboardFormatType& other) const {
return data_.cfFormat < other.data_.cfFormat; return data_.cfFormat < other.data_.cfFormat;
} }
bool ClipboardFormatType::Equals(const ClipboardFormatType& other) const { bool ClipboardFormatType::operator==(const ClipboardFormatType& other) const {
return data_.cfFormat == other.data_.cfFormat; return data_.cfFormat == other.data_.cfFormat;
} }
......
...@@ -393,20 +393,20 @@ bool ClipboardNonBacked::IsFormatAvailable( ...@@ -393,20 +393,20 @@ bool ClipboardNonBacked::IsFormatAvailable(
if (!clipboard_internal_->IsReadAllowed(data_dst)) if (!clipboard_internal_->IsReadAllowed(data_dst))
return false; return false;
if (ClipboardFormatType::GetPlainTextType().Equals(format) || if (format == ClipboardFormatType::GetPlainTextType() ||
ClipboardFormatType::GetUrlType().Equals(format)) format == ClipboardFormatType::GetUrlType())
return clipboard_internal_->IsFormatAvailable( return clipboard_internal_->IsFormatAvailable(
ClipboardInternalFormat::kText); ClipboardInternalFormat::kText);
if (ClipboardFormatType::GetHtmlType().Equals(format)) if (format == ClipboardFormatType::GetHtmlType())
return clipboard_internal_->IsFormatAvailable( return clipboard_internal_->IsFormatAvailable(
ClipboardInternalFormat::kHtml); ClipboardInternalFormat::kHtml);
if (ClipboardFormatType::GetRtfType().Equals(format)) if (format == ClipboardFormatType::GetRtfType())
return clipboard_internal_->IsFormatAvailable( return clipboard_internal_->IsFormatAvailable(
ClipboardInternalFormat::kRtf); ClipboardInternalFormat::kRtf);
if (ClipboardFormatType::GetBitmapType().Equals(format)) if (format == ClipboardFormatType::GetBitmapType())
return clipboard_internal_->IsFormatAvailable( return clipboard_internal_->IsFormatAvailable(
ClipboardInternalFormat::kBitmap); ClipboardInternalFormat::kBitmap);
if (ClipboardFormatType::GetWebKitSmartPasteType().Equals(format)) if (format == ClipboardFormatType::GetWebKitSmartPasteType())
return clipboard_internal_->IsFormatAvailable( return clipboard_internal_->IsFormatAvailable(
ClipboardInternalFormat::kWeb); ClipboardInternalFormat::kWeb);
const ClipboardData* data = clipboard_internal_->GetData(); const ClipboardData* data = clipboard_internal_->GetData();
......
...@@ -513,8 +513,8 @@ bool ClipboardX11::IsFormatAvailable( ...@@ -513,8 +513,8 @@ bool ClipboardX11::IsFormatAvailable(
DCHECK(IsSupportedClipboardBuffer(buffer)); DCHECK(IsSupportedClipboardBuffer(buffer));
TargetList target_list = x11_details_->WaitAndGetTargetsList(buffer); TargetList target_list = x11_details_->WaitAndGetTargetsList(buffer);
if (format.Equals(ClipboardFormatType::GetPlainTextType()) || if (format == ClipboardFormatType::GetPlainTextType() ||
format.Equals(ClipboardFormatType::GetUrlType())) { format == ClipboardFormatType::GetUrlType()) {
return target_list.ContainsText(); return target_list.ContainsText();
} }
return target_list.ContainsFormat(format); return target_list.ContainsFormat(format);
......
...@@ -57,7 +57,7 @@ bool TestClipboard::IsFormatAvailable( ...@@ -57,7 +57,7 @@ bool TestClipboard::IsFormatAvailable(
#if defined(OS_LINUX) #if defined(OS_LINUX)
// The linux clipboard treats the presence of text on the clipboard // The linux clipboard treats the presence of text on the clipboard
// as the url format being available. // as the url format being available.
if (format.Equals(ClipboardFormatType::GetUrlType())) if (format == ClipboardFormatType::GetUrlType())
return IsFormatAvailable(ClipboardFormatType::GetPlainTextType(), buffer, return IsFormatAvailable(ClipboardFormatType::GetPlainTextType(), buffer,
data_dst); data_dst);
#endif // OS_LINUX #endif // OS_LINUX
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment