summaryrefslogtreecommitdiffstats
path: root/ui/base/clipboard/custom_data_helper.h
blob: 3b9e0e139d1da9c77398b7e0bb679a99fc628cba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) 2011 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.
//
// Due to restrictions of most operating systems, we don't directly map each
// type of custom data to a native data transfer type. Instead, we serialize
// each key-value pair into the pickle as a pair of string objects, and then
// write the binary data in the pickle to the native data transfer object.

#ifndef UI_BASE_CLIPBOARD_CUSTOM_DATA_HELPER_H_
#define UI_BASE_CLIPBOARD_CUSTOM_DATA_HELPER_H_
#pragma once

#include <map>
#include <vector>

#include "base/string16.h"
#include "ui/base/ui_export.h"

class Pickle;

#if defined(OS_MACOSX)
#ifdef __OBJC__
@class NSString;
#else
class NSString;
#endif
#endif  // defined(OS_MACOSX)

namespace ui {

#if (!defined(OS_WIN) && defined(USE_AURA)) || defined(TOOLKIT_USES_GTK)
UI_EXPORT extern const char kMimeTypeWebCustomData[];
#elif defined(OS_MACOSX)
UI_EXPORT extern NSString* const kWebCustomDataPboardType;
#endif

UI_EXPORT void ReadCustomDataTypes(const void* data,
                                   size_t data_length,
                                   std::vector<string16>* types);
UI_EXPORT void ReadCustomDataForType(const void* data,
                                     size_t data_length,
                                     const string16& type,
                                     string16* result);
UI_EXPORT void ReadCustomDataIntoMap(const void* data,
                                     size_t data_length,
                                     std::map<string16, string16>* result);

UI_EXPORT void WriteCustomDataToPickle(const std::map<string16, string16>& data,
                                       Pickle* pickle);

}  // namespace ui

#endif  // UI_BASE_CLIPBOARD_CLIPBOARD_H_