| Index: ui/base/clipboard/clipboard.cc
|
| diff --git a/ui/base/clipboard/clipboard.cc b/ui/base/clipboard/clipboard.cc
|
| index c71d5b910f142047a28709caac23f4264cd09308..4c9189aa74de4370cfa3bccf963041e5c1f30738 100644
|
| --- a/ui/base/clipboard/clipboard.cc
|
| +++ b/ui/base/clipboard/clipboard.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include <iterator>
|
| #include <limits>
|
| +#include <set>
|
|
|
| #include "base/lazy_instance.h"
|
| #include "base/logging.h"
|
| @@ -51,6 +52,14 @@ 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
|
| @@ -105,6 +114,28 @@ 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()))
|
|
|