This source file includes following definitions.
- clipboard_sequence_number
- primary_sequence_number
- DidProcessEvent
- primary_sequence_number_
- GetInstance
- WillProcessEvent
- target_list
- atom_cache_
- ContainsText
- ContainsFormat
- ContainsAtom
- Serialize
- Deserialize
- Equals
- atom_cache
- primary_owner_
- LookupSelectionForClipboardType
- LookupStorageForAtom
- GetSelectionRequestorForClipboardType
- CreateNewClipboardData
- InsertMapping
- TakeOwnershipOfSelection
- RequestAndWaitForTypes
- WaitAndGetTargetsList
- GetTextAtoms
- GetAtomsForFormat
- Clear
- Dispatch
- WriteObjects
- IsFormatAvailable
- Clear
- ReadAvailableTypes
- ReadText
- ReadAsciiText
- ReadHTML
- ReadRTF
- ReadImage
- ReadCustomData
- ReadBookmark
- ReadData
- GetSequenceNumber
- WriteText
- WriteHTML
- WriteRTF
- WriteBookmark
- WriteWebSmartPaste
- WriteBitmap
- WriteData
- GetFormatType
- GetUrlFormatType
- GetUrlWFormatType
- GetPlainTextFormatType
- GetPlainTextWFormatType
- GetFilenameFormatType
- GetFilenameWFormatType
- GetHtmlFormatType
- GetRtfFormatType
- GetBitmapFormatType
- GetWebKitSmartPasteFormatType
- GetWebCustomDataFormatType
- GetPepperCustomDataFormatType
#include "ui/base/clipboard/clipboard.h"
#include <X11/extensions/Xfixes.h>
#include <X11/Xatom.h>
#include <list>
#include <set>
#include "base/basictypes.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "base/message_loop/message_pump_observer.h"
#include "base/message_loop/message_pump_x11.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/clipboard/custom_data_helper.h"
#include "ui/base/x/selection_owner.h"
#include "ui/base/x/selection_requestor.h"
#include "ui/base/x/selection_utils.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/size.h"
#include "ui/gfx/x/x11_atom_cache.h"
namespace ui {
namespace {
const char kClipboard[] = "CLIPBOARD";
const char kMimeTypeFilename[] = "chromium/filename";
const char kMimeTypePepperCustomData[] = "chromium/x-pepper-custom-data";
const char kMimeTypeWebkitSmartPaste[] = "chromium/x-webkit-paste";
const char kTargets[] = "TARGETS";
const char* kAtomsToCache[] = {
kClipboard,
Clipboard::kMimeTypePNG,
kMimeTypeFilename,
kMimeTypeMozillaURL,
kMimeTypeWebkitSmartPaste,
kString,
kTargets,
kText,
kUtf8String,
NULL
};
class SelectionChangeObserver : public base::MessagePumpObserver {
public:
static SelectionChangeObserver* GetInstance();
uint64 clipboard_sequence_number() const {
return clipboard_sequence_number_;
}
uint64 primary_sequence_number() const { return primary_sequence_number_; }
private:
friend struct DefaultSingletonTraits<SelectionChangeObserver>;
SelectionChangeObserver();
virtual ~SelectionChangeObserver();
virtual base::EventStatus WillProcessEvent(
const base::NativeEvent& event) OVERRIDE;
virtual void DidProcessEvent(
const base::NativeEvent& event) OVERRIDE {}
int event_base_;
Atom clipboard_atom_;
uint64 clipboard_sequence_number_;
uint64 primary_sequence_number_;
DISALLOW_COPY_AND_ASSIGN(SelectionChangeObserver);
};
SelectionChangeObserver::SelectionChangeObserver()
: event_base_(-1),
clipboard_atom_(None),
clipboard_sequence_number_(0),
primary_sequence_number_(0) {
int ignored;
if (XFixesQueryExtension(gfx::GetXDisplay(), &event_base_, &ignored)) {
clipboard_atom_ = XInternAtom(gfx::GetXDisplay(), kClipboard, false);
XFixesSelectSelectionInput(gfx::GetXDisplay(), GetX11RootWindow(),
clipboard_atom_,
XFixesSetSelectionOwnerNotifyMask |
XFixesSelectionWindowDestroyNotifyMask |
XFixesSelectionClientCloseNotifyMask);
XFixesSelectSelectionInput(gfx::GetXDisplay(), GetX11RootWindow(),
XA_PRIMARY,
XFixesSetSelectionOwnerNotifyMask |
XFixesSelectionWindowDestroyNotifyMask |
XFixesSelectionClientCloseNotifyMask);
base::MessagePumpX11::Current()->AddObserver(this);
}
}
SelectionChangeObserver::~SelectionChangeObserver() {
}
SelectionChangeObserver* SelectionChangeObserver::GetInstance() {
return Singleton<SelectionChangeObserver>::get();
}
base::EventStatus SelectionChangeObserver::WillProcessEvent(
const base::NativeEvent& event) {
if (event->type == event_base_ + XFixesSelectionNotify) {
XFixesSelectionNotifyEvent* ev =
reinterpret_cast<XFixesSelectionNotifyEvent*>(event);
if (ev->selection == clipboard_atom_) {
clipboard_sequence_number_++;
} else if (ev->selection == XA_PRIMARY) {
primary_sequence_number_++;
} else {
DLOG(ERROR) << "Unexpected selection atom: " << ev->selection;
}
}
return base::EVENT_CONTINUE;
}
class TargetList {
public:
typedef std::vector< ::Atom> AtomVector;
TargetList(const AtomVector& target_list, X11AtomCache* atom_cache);
const AtomVector& target_list() { return target_list_; }
bool ContainsText() const;
bool ContainsFormat(const Clipboard::FormatType& format_type) const;
bool ContainsAtom(::Atom atom) const;
private:
AtomVector target_list_;
X11AtomCache* atom_cache_;
};
TargetList::TargetList(const AtomVector& target_list,
X11AtomCache* atom_cache)
: target_list_(target_list),
atom_cache_(atom_cache) {
}
bool TargetList::ContainsText() const {
std::vector< ::Atom> atoms = GetTextAtomsFrom(atom_cache_);
for (std::vector< ::Atom>::const_iterator it = atoms.begin();
it != atoms.end(); ++it) {
if (ContainsAtom(*it))
return true;
}
return false;
}
bool TargetList::ContainsFormat(
const Clipboard::FormatType& format_type) const {
::Atom atom = atom_cache_->GetAtom(format_type.ToString().c_str());
return ContainsAtom(atom);
}
bool TargetList::ContainsAtom(::Atom atom) const {
return find(target_list_.begin(), target_list_.end(), atom)
!= target_list_.end();
}
}
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_;
}
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_;
}
class Clipboard::AuraX11Details : public base::MessagePumpDispatcher {
public:
AuraX11Details();
virtual ~AuraX11Details();
X11AtomCache* atom_cache() { return &atom_cache_; }
::Atom LookupSelectionForClipboardType(ClipboardType type) const;
SelectionRequestor* GetSelectionRequestorForClipboardType(ClipboardType type);
const SelectionFormatMap& LookupStorageForAtom(::Atom atom);
void CreateNewClipboardData();
void InsertMapping(const std::string& key,
const scoped_refptr<base::RefCountedMemory>& memory);
void TakeOwnershipOfSelection(ClipboardType type);
ui::SelectionData RequestAndWaitForTypes(ClipboardType type,
const std::vector< ::Atom>& types);
TargetList WaitAndGetTargetsList(ClipboardType type);
std::vector< ::Atom> GetTextAtoms() const;
std::vector< ::Atom> GetAtomsForFormat(const Clipboard::FormatType& format);
void Clear(ClipboardType type);
private:
virtual uint32_t Dispatch(const base::NativeEvent& event) OVERRIDE;
Display* x_display_;
::Window x_root_window_;
::Window x_window_;
X11AtomCache atom_cache_;
SelectionRequestor clipboard_requestor_;
SelectionRequestor primary_requestor_;
SelectionFormatMap clipboard_data_;
SelectionOwner clipboard_owner_;
SelectionOwner primary_owner_;
DISALLOW_COPY_AND_ASSIGN(AuraX11Details);
};
Clipboard::AuraX11Details::AuraX11Details()
: x_display_(gfx::GetXDisplay()),
x_root_window_(DefaultRootWindow(x_display_)),
x_window_(XCreateWindow(
x_display_, x_root_window_,
-100, -100, 10, 10,
0,
CopyFromParent,
InputOnly,
CopyFromParent,
0,
NULL)),
atom_cache_(x_display_, kAtomsToCache),
clipboard_requestor_(x_display_, x_window_,
atom_cache_.GetAtom(kClipboard)),
primary_requestor_(x_display_, x_window_, XA_PRIMARY),
clipboard_owner_(x_display_, x_window_, atom_cache_.GetAtom(kClipboard)),
primary_owner_(x_display_, x_window_, XA_PRIMARY) {
atom_cache_.allow_uncached_atoms();
XStoreName(x_display_, x_window_, "Chromium clipboard");
XSelectInput(x_display_, x_window_, PropertyChangeMask);
base::MessagePumpX11::Current()->AddDispatcherForWindow(this, x_window_);
}
Clipboard::AuraX11Details::~AuraX11Details() {
base::MessagePumpX11::Current()->RemoveDispatcherForWindow(x_window_);
XDestroyWindow(x_display_, x_window_);
}
::Atom Clipboard::AuraX11Details::LookupSelectionForClipboardType(
ClipboardType type) const {
if (type == CLIPBOARD_TYPE_COPY_PASTE)
return atom_cache_.GetAtom(kClipboard);
return XA_PRIMARY;
}
const SelectionFormatMap& Clipboard::AuraX11Details::LookupStorageForAtom(
::Atom atom) {
if (atom == XA_PRIMARY)
return primary_owner_.selection_format_map();
DCHECK_EQ(atom_cache_.GetAtom(kClipboard), atom);
return clipboard_owner_.selection_format_map();
}
ui::SelectionRequestor*
Clipboard::AuraX11Details::GetSelectionRequestorForClipboardType(
ClipboardType type) {
if (type == CLIPBOARD_TYPE_COPY_PASTE)
return &clipboard_requestor_;
else
return &primary_requestor_;
}
void Clipboard::AuraX11Details::CreateNewClipboardData() {
clipboard_data_ = SelectionFormatMap();
}
void Clipboard::AuraX11Details::InsertMapping(
const std::string& key,
const scoped_refptr<base::RefCountedMemory>& memory) {
::Atom atom_key = atom_cache_.GetAtom(key.c_str());
clipboard_data_.Insert(atom_key, memory);
}
void Clipboard::AuraX11Details::TakeOwnershipOfSelection(ClipboardType type) {
if (type == CLIPBOARD_TYPE_COPY_PASTE)
return clipboard_owner_.TakeOwnershipOfSelection(clipboard_data_);
else
return primary_owner_.TakeOwnershipOfSelection(clipboard_data_);
}
SelectionData Clipboard::AuraX11Details::RequestAndWaitForTypes(
ClipboardType type,
const std::vector< ::Atom>& types) {
::Atom selection_name = LookupSelectionForClipboardType(type);
if (XGetSelectionOwner(x_display_, selection_name) == x_window_) {
const SelectionFormatMap& format_map = LookupStorageForAtom(selection_name);
for (std::vector< ::Atom>::const_iterator it = types.begin();
it != types.end(); ++it) {
SelectionFormatMap::const_iterator format_map_it = format_map.find(*it);
if (format_map_it != format_map.end())
return SelectionData(format_map_it->first, format_map_it->second);
}
} else {
TargetList targets = WaitAndGetTargetsList(type);
SelectionRequestor* receiver = GetSelectionRequestorForClipboardType(type);
std::vector< ::Atom> intersection;
ui::GetAtomIntersection(types, targets.target_list(), &intersection);
return receiver->RequestAndWaitForTypes(intersection);
}
return SelectionData();
}
TargetList Clipboard::AuraX11Details::WaitAndGetTargetsList(
ClipboardType type) {
::Atom selection_name = LookupSelectionForClipboardType(type);
std::vector< ::Atom> out;
if (XGetSelectionOwner(x_display_, selection_name) == x_window_) {
const SelectionFormatMap& format_map = LookupStorageForAtom(selection_name);
for (SelectionFormatMap::const_iterator it = format_map.begin();
it != format_map.end(); ++it) {
out.push_back(it->first);
}
} else {
scoped_refptr<base::RefCountedMemory> data;
size_t out_data_items = 0;
::Atom out_type = None;
SelectionRequestor* receiver = GetSelectionRequestorForClipboardType(type);
if (receiver->PerformBlockingConvertSelection(atom_cache_.GetAtom(kTargets),
&data,
NULL,
&out_data_items,
&out_type)) {
if (out_type == XA_ATOM) {
const ::Atom* atom_array =
reinterpret_cast<const ::Atom*>(data->front());
for (size_t i = 0; i < out_data_items; ++i)
out.push_back(atom_array[i]);
}
} else {
std::vector< ::Atom> types = GetTextAtoms();
for (std::vector< ::Atom>::const_iterator it = types.begin();
it != types.end(); ++it) {
::Atom type = None;
if (receiver->PerformBlockingConvertSelection(*it,
NULL,
NULL,
NULL,
&type) &&
type == *it) {
out.push_back(*it);
}
}
}
}
return TargetList(out, &atom_cache_);
}
std::vector< ::Atom> Clipboard::AuraX11Details::GetTextAtoms() const {
return GetTextAtomsFrom(&atom_cache_);
}
std::vector< ::Atom> Clipboard::AuraX11Details::GetAtomsForFormat(
const Clipboard::FormatType& format) {
std::vector< ::Atom> atoms;
atoms.push_back(atom_cache_.GetAtom(format.ToString().c_str()));
return atoms;
}
void Clipboard::AuraX11Details::Clear(ClipboardType type) {
if (type == CLIPBOARD_TYPE_COPY_PASTE)
clipboard_owner_.ClearSelectionOwner();
else
primary_owner_.ClearSelectionOwner();
}
uint32_t Clipboard::AuraX11Details::Dispatch(const base::NativeEvent& event) {
XEvent* xev = event;
switch (xev->type) {
case SelectionRequest: {
if (xev->xselectionrequest.selection == XA_PRIMARY)
primary_owner_.OnSelectionRequest(xev->xselectionrequest);
else
clipboard_owner_.OnSelectionRequest(xev->xselectionrequest);
break;
}
case SelectionNotify: {
if (xev->xselection.selection == XA_PRIMARY)
primary_requestor_.OnSelectionNotify(xev->xselection);
else
clipboard_requestor_.OnSelectionNotify(xev->xselection);
break;
}
case SelectionClear: {
if (xev->xselectionclear.selection == XA_PRIMARY)
primary_owner_.OnSelectionClear(xev->xselectionclear);
else
clipboard_owner_.OnSelectionClear(xev->xselectionclear);
break;
}
default:
break;
}
return POST_DISPATCH_NONE;
}
Clipboard::Clipboard()
: aurax11_details_(new AuraX11Details) {
DCHECK(CalledOnValidThread());
}
Clipboard::~Clipboard() {
DCHECK(CalledOnValidThread());
}
void Clipboard::WriteObjects(ClipboardType type, const ObjectMap& objects) {
DCHECK(CalledOnValidThread());
DCHECK(IsSupportedClipboardType(type));
aurax11_details_->CreateNewClipboardData();
for (ObjectMap::const_iterator iter = objects.begin();
iter != objects.end(); ++iter) {
DispatchObject(static_cast<ObjectType>(iter->first), iter->second);
}
aurax11_details_->TakeOwnershipOfSelection(type);
if (type == CLIPBOARD_TYPE_COPY_PASTE) {
ObjectMap::const_iterator text_iter = objects.find(CBF_TEXT);
if (text_iter != objects.end()) {
aurax11_details_->CreateNewClipboardData();
const ObjectMapParams& params_vector = text_iter->second;
if (params_vector.size()) {
const ObjectMapParam& char_vector = params_vector[0];
if (char_vector.size())
WriteText(&char_vector.front(), char_vector.size());
}
aurax11_details_->TakeOwnershipOfSelection(CLIPBOARD_TYPE_SELECTION);
}
}
}
bool Clipboard::IsFormatAvailable(const FormatType& format,
ClipboardType type) const {
DCHECK(CalledOnValidThread());
DCHECK(IsSupportedClipboardType(type));
TargetList target_list = aurax11_details_->WaitAndGetTargetsList(type);
if (format.Equals(GetPlainTextFormatType()) ||
format.Equals(GetUrlFormatType())) {
return target_list.ContainsText();
}
return target_list.ContainsFormat(format);
}
void Clipboard::Clear(ClipboardType type) {
DCHECK(CalledOnValidThread());
DCHECK(IsSupportedClipboardType(type));
aurax11_details_->Clear(type);
}
void Clipboard::ReadAvailableTypes(ClipboardType type,
std::vector<base::string16>* types,
bool* contains_filenames) const {
DCHECK(CalledOnValidThread());
if (!types || !contains_filenames) {
NOTREACHED();
return;
}
TargetList target_list = aurax11_details_->WaitAndGetTargetsList(type);
types->clear();
if (target_list.ContainsText())
types->push_back(base::UTF8ToUTF16(kMimeTypeText));
if (target_list.ContainsFormat(GetHtmlFormatType()))
types->push_back(base::UTF8ToUTF16(kMimeTypeHTML));
if (target_list.ContainsFormat(GetRtfFormatType()))
types->push_back(base::UTF8ToUTF16(kMimeTypeRTF));
if (target_list.ContainsFormat(GetBitmapFormatType()))
types->push_back(base::UTF8ToUTF16(kMimeTypePNG));
*contains_filenames = false;
SelectionData data(aurax11_details_->RequestAndWaitForTypes(
type, aurax11_details_->GetAtomsForFormat(GetWebCustomDataFormatType())));
if (data.IsValid())
ReadCustomDataTypes(data.GetData(), data.GetSize(), types);
}
void Clipboard::ReadText(ClipboardType type, base::string16* result) const {
DCHECK(CalledOnValidThread());
SelectionData data(aurax11_details_->RequestAndWaitForTypes(
type, aurax11_details_->GetTextAtoms()));
if (data.IsValid()) {
std::string text = data.GetText();
*result = base::UTF8ToUTF16(text);
}
}
void Clipboard::ReadAsciiText(ClipboardType type, std::string* result) const {
DCHECK(CalledOnValidThread());
SelectionData data(aurax11_details_->RequestAndWaitForTypes(
type, aurax11_details_->GetTextAtoms()));
if (data.IsValid())
result->assign(data.GetText());
}
void Clipboard::ReadHTML(ClipboardType type,
base::string16* markup,
std::string* src_url,
uint32* fragment_start,
uint32* fragment_end) const {
DCHECK(CalledOnValidThread());
markup->clear();
if (src_url)
src_url->clear();
*fragment_start = 0;
*fragment_end = 0;
SelectionData data(aurax11_details_->RequestAndWaitForTypes(
type, aurax11_details_->GetAtomsForFormat(GetHtmlFormatType())));
if (data.IsValid()) {
*markup = data.GetHtml();
*fragment_start = 0;
DCHECK(markup->length() <= kuint32max);
*fragment_end = static_cast<uint32>(markup->length());
}
}
void Clipboard::ReadRTF(ClipboardType type, std::string* result) const {
DCHECK(CalledOnValidThread());
SelectionData data(aurax11_details_->RequestAndWaitForTypes(
type, aurax11_details_->GetAtomsForFormat(GetRtfFormatType())));
if (data.IsValid())
data.AssignTo(result);
}
SkBitmap Clipboard::ReadImage(ClipboardType type) const {
DCHECK(CalledOnValidThread());
SelectionData data(aurax11_details_->RequestAndWaitForTypes(
type, aurax11_details_->GetAtomsForFormat(GetBitmapFormatType())));
if (data.IsValid()) {
SkBitmap bitmap;
if (gfx::PNGCodec::Decode(data.GetData(), data.GetSize(), &bitmap))
return SkBitmap(bitmap);
}
return SkBitmap();
}
void Clipboard::ReadCustomData(ClipboardType clipboard_type,
const base::string16& type,
base::string16* result) const {
DCHECK(CalledOnValidThread());
SelectionData data(aurax11_details_->RequestAndWaitForTypes(
clipboard_type,
aurax11_details_->GetAtomsForFormat(GetWebCustomDataFormatType())));
if (data.IsValid())
ReadCustomDataForType(data.GetData(), data.GetSize(), type, result);
}
void Clipboard::ReadBookmark(base::string16* title, std::string* url) const {
DCHECK(CalledOnValidThread());
NOTIMPLEMENTED();
}
void Clipboard::ReadData(const FormatType& format, std::string* result) const {
DCHECK(CalledOnValidThread());
SelectionData data(aurax11_details_->RequestAndWaitForTypes(
CLIPBOARD_TYPE_COPY_PASTE, aurax11_details_->GetAtomsForFormat(format)));
if (data.IsValid())
data.AssignTo(result);
}
uint64 Clipboard::GetSequenceNumber(ClipboardType type) {
DCHECK(CalledOnValidThread());
if (type == CLIPBOARD_TYPE_COPY_PASTE)
return SelectionChangeObserver::GetInstance()->clipboard_sequence_number();
else
return SelectionChangeObserver::GetInstance()->primary_sequence_number();
}
void Clipboard::WriteText(const char* text_data, size_t text_len) {
std::string str(text_data, text_len);
scoped_refptr<base::RefCountedMemory> mem(
base::RefCountedString::TakeString(&str));
aurax11_details_->InsertMapping(kMimeTypeText, mem);
aurax11_details_->InsertMapping(kText, mem);
aurax11_details_->InsertMapping(kString, mem);
aurax11_details_->InsertMapping(kUtf8String, mem);
}
void Clipboard::WriteHTML(const char* markup_data,
size_t markup_len,
const char* url_data,
size_t url_len) {
static const char* html_prefix = "<meta http-equiv=\"content-type\" "
"content=\"text/html; charset=utf-8\">";
std::string data = html_prefix;
data += std::string(markup_data, markup_len);
data += '\0';
scoped_refptr<base::RefCountedMemory> mem(
base::RefCountedString::TakeString(&data));
aurax11_details_->InsertMapping(kMimeTypeHTML, mem);
}
void Clipboard::WriteRTF(const char* rtf_data, size_t data_len) {
WriteData(GetRtfFormatType(), rtf_data, data_len);
}
void Clipboard::WriteBookmark(const char* title_data,
size_t title_len,
const char* url_data,
size_t url_len) {
base::string16 url = base::UTF8ToUTF16(std::string(url_data, url_len) + "\n");
base::string16 title = base::UTF8ToUTF16(std::string(title_data, title_len));
std::vector<unsigned char> data;
ui::AddString16ToVector(url, &data);
ui::AddString16ToVector(title, &data);
scoped_refptr<base::RefCountedMemory> mem(
base::RefCountedBytes::TakeVector(&data));
aurax11_details_->InsertMapping(kMimeTypeMozillaURL, mem);
}
void Clipboard::WriteWebSmartPaste() {
std::string empty;
aurax11_details_->InsertMapping(
kMimeTypeWebkitSmartPaste,
scoped_refptr<base::RefCountedMemory>(
base::RefCountedString::TakeString(&empty)));
}
void Clipboard::WriteBitmap(const SkBitmap& bitmap) {
std::vector<unsigned char> output;
if (gfx::PNGCodec::FastEncodeBGRASkBitmap(bitmap, false, &output)) {
aurax11_details_->InsertMapping(kMimeTypePNG,
base::RefCountedBytes::TakeVector(
&output));
}
}
void Clipboard::WriteData(const FormatType& format,
const char* data_data,
size_t data_len) {
if (format.Equals(GetBitmapFormatType()))
return;
std::vector<unsigned char> bytes(data_data, data_data + data_len);
scoped_refptr<base::RefCountedMemory> mem(
base::RefCountedBytes::TakeVector(&bytes));
aurax11_details_->InsertMapping(format.ToString(), mem);
}
Clipboard::FormatType Clipboard::GetFormatType(
const std::string& format_string) {
return FormatType::Deserialize(format_string);
}
const Clipboard::FormatType& Clipboard::GetUrlFormatType() {
CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeURIList));
return type;
}
const Clipboard::FormatType& Clipboard::GetUrlWFormatType() {
return GetUrlFormatType();
}
const Clipboard::FormatType& Clipboard::GetPlainTextFormatType() {
CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeText));
return type;
}
const Clipboard::FormatType& Clipboard::GetPlainTextWFormatType() {
return GetPlainTextFormatType();
}
const Clipboard::FormatType& Clipboard::GetFilenameFormatType() {
CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeFilename));
return type;
}
const Clipboard::FormatType& Clipboard::GetFilenameWFormatType() {
return Clipboard::GetFilenameFormatType();
}
const Clipboard::FormatType& Clipboard::GetHtmlFormatType() {
CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeHTML));
return type;
}
const Clipboard::FormatType& Clipboard::GetRtfFormatType() {
CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeRTF));
return type;
}
const Clipboard::FormatType& Clipboard::GetBitmapFormatType() {
CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypePNG));
return type;
}
const Clipboard::FormatType& Clipboard::GetWebKitSmartPasteFormatType() {
CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeWebkitSmartPaste));
return type;
}
const Clipboard::FormatType& Clipboard::GetWebCustomDataFormatType() {
CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeWebCustomData));
return type;
}
const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() {
CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypePepperCustomData));
return type;
}
}