summaryrefslogtreecommitdiffstats
path: root/ui/base
diff options
context:
space:
mode:
authordcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-15 21:16:26 +0000
committerdcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-15 21:16:26 +0000
commit288a3bca50879ab24fe145126622be3c41cfc9f9 (patch)
treef0bd68156ac4c96d824a1267c7d22ca925576526 /ui/base
parent8a46d04dd39e7ac4b4ef88c3bfbad74a34fd2e58 (diff)
downloadchromium_src-288a3bca50879ab24fe145126622be3c41cfc9f9.zip
chromium_src-288a3bca50879ab24fe145126622be3c41cfc9f9.tar.gz
chromium_src-288a3bca50879ab24fe145126622be3c41cfc9f9.tar.bz2
Revert 256987 "Merge 256982 "Merge 256981 "Verify FormatType in ..."
> Merge 256982 "Merge 256981 "Verify FormatType in ScopedClipboard..." > > > Merge 256981 "Verify FormatType in ScopedClipboardWriter::WriteP..." > > > > > Verify FormatType in ScopedClipboardWriter::WritePickledData. > > > > > > BUG=352395 > > > R=tony@chromium.org > > > TBR=sky@chromium.org > > > > > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=256974 > > > > > > Review URL: https://codereview.chromium.org/199763002 > > > > TBR=dcheng@chromium.org > > > > Review URL: https://codereview.chromium.org/197763013 > > TBR=dcheng@chromium.org > > Review URL: https://codereview.chromium.org/199893002 TBR=inferno@chromium.org Review URL: https://codereview.chromium.org/201263002 git-svn-id: svn://svn.chromium.org/chrome/branches/1847/src@257338 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base')
-rw-r--r--ui/base/clipboard/clipboard.cc31
-rw-r--r--ui/base/clipboard/clipboard.h8
-rw-r--r--ui/base/clipboard/clipboard_android.cc12
-rw-r--r--ui/base/clipboard/clipboard_aura.cc8
-rw-r--r--ui/base/clipboard/clipboard_aurax11.cc8
-rw-r--r--ui/base/clipboard/clipboard_gtk.cc12
-rw-r--r--ui/base/clipboard/clipboard_mac.mm14
-rw-r--r--ui/base/clipboard/clipboard_win.cc6
-rw-r--r--ui/base/clipboard/scoped_clipboard_writer.cc4
9 files changed, 21 insertions, 82 deletions
diff --git a/ui/base/clipboard/clipboard.cc b/ui/base/clipboard/clipboard.cc
index 4c9189a..c71d5b9 100644
--- a/ui/base/clipboard/clipboard.cc
+++ b/ui/base/clipboard/clipboard.cc
@@ -6,7 +6,6 @@
#include <iterator>
#include <limits>
-#include <set>
#include "base/lazy_instance.h"
#include "base/logging.h"
@@ -52,14 +51,6 @@ static base::LazyInstance<ClipboardMap> g_clipboard_map =
static base::LazyInstance<base::Lock>::Leaky
g_clipboard_map_lock = LAZY_INSTANCE_INITIALIZER;
-// Set of registered custom formats.
-static base::LazyInstance<std::set<Clipboard::FormatType> >
- g_registered_formats = LAZY_INSTANCE_INITIALIZER;
-
-// Mutex that controls access to |g_registered_formats|.
-static base::LazyInstance<base::Lock>::Leaky g_registered_formats_lock =
- LAZY_INSTANCE_INITIALIZER;
-
} // namespace
// static
@@ -114,28 +105,6 @@ void Clipboard::DestroyClipboardForCurrentThread() {
}
}
-// static
-Clipboard::FormatType Clipboard::GetFormatType(
- const std::string& format_string) {
- FormatType format = GetFormatTypeInternal(format_string);
- {
- base::AutoLock lock(g_registered_formats_lock.Get());
- g_registered_formats.Get().insert(format);
- }
- return format;
-}
-
-bool Clipboard::IsRegisteredFormatType(const FormatType& format) {
- // Terrible hack to force web/pepper custom types to be registered.
- // TODO(dcheng): There's got to a better way...
- GetWebCustomDataFormatType();
- GetPepperCustomDataFormatType();
-
- base::AutoLock lock(g_registered_formats_lock.Get());
- const std::set<FormatType>& registered_formats = g_registered_formats.Get();
- return registered_formats.find(format) != registered_formats.end();
-}
-
void Clipboard::DispatchObject(ObjectType type, const ObjectMapParams& params) {
// All types apart from CBF_WEBKIT need at least 1 non-empty param.
if (type != CBF_WEBKIT && (params.empty() || params[0].empty()))
diff --git a/ui/base/clipboard/clipboard.h b/ui/base/clipboard/clipboard.h
index 09a4584..b59a73c 100644
--- a/ui/base/clipboard/clipboard.h
+++ b/ui/base/clipboard/clipboard.h
@@ -83,7 +83,10 @@ class UI_BASE_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
std::string Serialize() const;
static FormatType Deserialize(const std::string& serialization);
+#if defined(OS_WIN) || defined(USE_AURA)
+ // FormatType can be used in a set on some platforms.
bool operator<(const FormatType& other) const;
+#endif
#if defined(OS_WIN)
const FORMATETC& ToFormatEtc() const { return data_; }
@@ -270,9 +273,6 @@ class UI_BASE_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
// limitiations, |format_string| must never be controlled by the user.
static FormatType GetFormatType(const std::string& format_string);
- // Returns true if the |format| was registered with GetFormatType().
- static bool IsRegisteredFormatType(const FormatType& format);
-
// Get format identifiers for various types.
static const FormatType& GetUrlFormatType();
static const FormatType& GetUrlWFormatType();
@@ -317,8 +317,6 @@ class UI_BASE_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
Clipboard();
~Clipboard();
- static FormatType GetFormatTypeInternal(const std::string& format_string);
-
void DispatchObject(ObjectType type, const ObjectMapParams& params);
void WriteText(const char* text_data, size_t text_len);
diff --git a/ui/base/clipboard/clipboard_android.cc b/ui/base/clipboard/clipboard_android.cc
index f8feadc..e5e2a96 100644
--- a/ui/base/clipboard/clipboard_android.cc
+++ b/ui/base/clipboard/clipboard_android.cc
@@ -198,10 +198,6 @@ Clipboard::FormatType Clipboard::FormatType::Deserialize(
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_;
}
@@ -339,7 +335,7 @@ void Clipboard::ReadData(const Clipboard::FormatType& format,
}
// static
-Clipboard::FormatType Clipboard::GetFormatTypeInternal(
+Clipboard::FormatType Clipboard::GetFormatType(
const std::string& format_string) {
return FormatType::Deserialize(format_string);
}
@@ -382,15 +378,13 @@ const Clipboard::FormatType& Clipboard::GetBitmapFormatType() {
// static
const Clipboard::FormatType& Clipboard::GetWebCustomDataFormatType() {
- CR_DEFINE_STATIC_LOCAL(
- FormatType, type, (GetFormatType(kMimeTypeWebCustomData)));
+ CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeWebCustomData));
return type;
}
// static
const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() {
- CR_DEFINE_STATIC_LOCAL(
- FormatType, type, (GetFormatType(kMimeTypePepperCustomData)));
+ CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypePepperCustomData));
return type;
}
diff --git a/ui/base/clipboard/clipboard_aura.cc b/ui/base/clipboard/clipboard_aura.cc
index cd69237..2c787f7 100644
--- a/ui/base/clipboard/clipboard_aura.cc
+++ b/ui/base/clipboard/clipboard_aura.cc
@@ -601,7 +601,7 @@ void Clipboard::WriteData(const FormatType& format,
}
// static
-Clipboard::FormatType Clipboard::GetFormatTypeInternal(
+Clipboard::FormatType Clipboard::GetFormatType(
const std::string& format_string) {
return FormatType::Deserialize(format_string);
}
@@ -665,15 +665,13 @@ const Clipboard::FormatType& Clipboard::GetWebKitSmartPasteFormatType() {
// static
const Clipboard::FormatType& Clipboard::GetWebCustomDataFormatType() {
- CR_DEFINE_STATIC_LOCAL(
- FormatType, type, (GetFormatType(kMimeTypeWebCustomData)));
+ CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeWebCustomData));
return type;
}
// static
const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() {
- CR_DEFINE_STATIC_LOCAL(
- FormatType, type, (GetFormatType(kMimeTypePepperCustomData)));
+ CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypePepperCustomData));
return type;
}
diff --git a/ui/base/clipboard/clipboard_aurax11.cc b/ui/base/clipboard/clipboard_aurax11.cc
index 2ea2729..4588cc9 100644
--- a/ui/base/clipboard/clipboard_aurax11.cc
+++ b/ui/base/clipboard/clipboard_aurax11.cc
@@ -791,7 +791,7 @@ void Clipboard::WriteData(const FormatType& format,
}
// static
-Clipboard::FormatType Clipboard::GetFormatTypeInternal(
+Clipboard::FormatType Clipboard::GetFormatType(
const std::string& format_string) {
return FormatType::Deserialize(format_string);
}
@@ -855,15 +855,13 @@ const Clipboard::FormatType& Clipboard::GetWebKitSmartPasteFormatType() {
// static
const Clipboard::FormatType& Clipboard::GetWebCustomDataFormatType() {
- CR_DEFINE_STATIC_LOCAL(
- FormatType, type, (GetFormatType(kMimeTypeWebCustomData)));
+ CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeWebCustomData));
return type;
}
// static
const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() {
- CR_DEFINE_STATIC_LOCAL(
- FormatType, type, (GetFormatType(kMimeTypePepperCustomData)));
+ CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypePepperCustomData));
return type;
}
diff --git a/ui/base/clipboard/clipboard_gtk.cc b/ui/base/clipboard/clipboard_gtk.cc
index fddd86b..8f81911 100644
--- a/ui/base/clipboard/clipboard_gtk.cc
+++ b/ui/base/clipboard/clipboard_gtk.cc
@@ -202,10 +202,6 @@ Clipboard::FormatType Clipboard::FormatType::Deserialize(
return FormatType(serialization);
}
-bool Clipboard::FormatType::operator<(const FormatType& other) const {
- return GdkAtomToString(data_) < GdkAtomToString(other.data_);
-}
-
bool Clipboard::FormatType::Equals(const FormatType& other) const {
return data_ == other.data_;
}
@@ -596,7 +592,7 @@ uint64 Clipboard::GetSequenceNumber(ClipboardType type) {
}
//static
-Clipboard::FormatType Clipboard::GetFormatTypeInternal(
+Clipboard::FormatType Clipboard::GetFormatType(
const std::string& format_string) {
return FormatType::Deserialize(format_string);
}
@@ -649,15 +645,13 @@ const Clipboard::FormatType& Clipboard::GetWebKitSmartPasteFormatType() {
// static
const Clipboard::FormatType& Clipboard::GetWebCustomDataFormatType() {
- CR_DEFINE_STATIC_LOCAL(
- FormatType, type, (GetFormatType(kMimeTypeWebCustomData)));
+ CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeWebCustomData));
return type;
}
// static
const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() {
- CR_DEFINE_STATIC_LOCAL(
- FormatType, type, (GetFormatType(kMimeTypePepperCustomData)));
+ CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypePepperCustomData));
return type;
}
diff --git a/ui/base/clipboard/clipboard_mac.mm b/ui/base/clipboard/clipboard_mac.mm
index 9394dc7..0d0b2fa 100644
--- a/ui/base/clipboard/clipboard_mac.mm
+++ b/ui/base/clipboard/clipboard_mac.mm
@@ -84,10 +84,6 @@ Clipboard::FormatType Clipboard::FormatType::Deserialize(
return FormatType(base::SysUTF8ToNSString(serialization));
}
-bool Clipboard::FormatType::operator<(const FormatType& other) const {
- return [data_ compare:other.data_] == NSOrderedAscending;
-}
-
Clipboard::Clipboard() {
DCHECK(CalledOnValidThread());
}
@@ -367,7 +363,7 @@ void Clipboard::ReadData(const FormatType& format, std::string* result) const {
}
// static
-Clipboard::FormatType Clipboard::GetFormatTypeInternal(
+Clipboard::FormatType Clipboard::GetFormatType(
const std::string& format_string) {
return FormatType::Deserialize(format_string);
}
@@ -431,17 +427,13 @@ const Clipboard::FormatType& Clipboard::GetWebKitSmartPasteFormatType() {
// static
const Clipboard::FormatType& Clipboard::GetWebCustomDataFormatType() {
- CR_DEFINE_STATIC_LOCAL(
- FormatType, type, (GetFormatType([kWebCustomDataPboardType UTF8String])));
+ CR_DEFINE_STATIC_LOCAL(FormatType, type, (kWebCustomDataPboardType));
return type;
}
// static
const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() {
- CR_DEFINE_STATIC_LOCAL(
- FormatType,
- type,
- (GetFormatType([kPepperCustomDataPboardType UTF8String])));
+ CR_DEFINE_STATIC_LOCAL(FormatType, type, (kPepperCustomDataPboardType));
return type;
}
diff --git a/ui/base/clipboard/clipboard_win.cc b/ui/base/clipboard/clipboard_win.cc
index 1f40840..e97ca07 100644
--- a/ui/base/clipboard/clipboard_win.cc
+++ b/ui/base/clipboard/clipboard_win.cc
@@ -677,7 +677,7 @@ void Clipboard::ParseBookmarkClipboardFormat(const base::string16& bookmark,
}
// static
-Clipboard::FormatType Clipboard::GetFormatTypeInternal(
+Clipboard::FormatType Clipboard::GetFormatType(
const std::string& format_string) {
return FormatType(
::RegisterClipboardFormat(base::ASCIIToWide(format_string).c_str()));
@@ -802,7 +802,7 @@ const Clipboard::FormatType& Clipboard::GetWebCustomDataFormatType() {
CR_DEFINE_STATIC_LOCAL(
FormatType,
type,
- (GetFormatType("Chromium Web Custom MIME Data Format")));
+ (::RegisterClipboardFormat(L"Chromium Web Custom MIME Data Format")));
return type;
}
@@ -811,7 +811,7 @@ const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() {
CR_DEFINE_STATIC_LOCAL(
FormatType,
type,
- (GetFormatType("Chromium Pepper MIME Data Format")));
+ (::RegisterClipboardFormat(L"Chromium Pepper MIME Data Format")));
return type;
}
diff --git a/ui/base/clipboard/scoped_clipboard_writer.cc b/ui/base/clipboard/scoped_clipboard_writer.cc
index 884e5f7..380b8d2 100644
--- a/ui/base/clipboard/scoped_clipboard_writer.cc
+++ b/ui/base/clipboard/scoped_clipboard_writer.cc
@@ -91,10 +91,6 @@ void ScopedClipboardWriter::WriteWebSmartPaste() {
void ScopedClipboardWriter::WritePickledData(
const Pickle& pickle, const Clipboard::FormatType& format) {
- // |format| may originate from the renderer, so sanity check it.
- if (!Clipboard::IsRegisteredFormatType(format))
- return;
-
std::string format_string = format.Serialize();
Clipboard::ObjectMapParam format_parameter(format_string.begin(),
format_string.end());