OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_BASE_DRAGDROP_GTK_DND_UTIL_H_ | 5 #ifndef UI_BASE_DRAGDROP_GTK_DND_UTIL_H_ |
6 #define UI_BASE_DRAGDROP_GTK_DND_UTIL_H_ | 6 #define UI_BASE_DRAGDROP_GTK_DND_UTIL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 | 10 |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "ui/ui_api.h" |
14 | 15 |
15 class GURL; | 16 class GURL; |
16 | 17 |
17 namespace ui { | 18 namespace ui { |
18 | 19 |
19 // Registry of all internal int codes for drag and drop. | 20 // Registry of all internal int codes for drag and drop. |
20 enum { | 21 enum { |
21 // Intra-application types. | 22 // Intra-application types. |
22 CHROME_TAB = 1 << 0, | 23 CHROME_TAB = 1 << 0, |
23 CHROME_BOOKMARK_ITEM = 1 << 1, | 24 CHROME_BOOKMARK_ITEM = 1 << 1, |
(...skipping 11 matching lines...) Expand all Loading... |
35 | 36 |
36 // Used for drag-out download. | 37 // Used for drag-out download. |
37 TEXT_PLAIN_NO_CHARSET = 1 << 8, | 38 TEXT_PLAIN_NO_CHARSET = 1 << 8, |
38 DIRECT_SAVE_FILE = 1 << 9, | 39 DIRECT_SAVE_FILE = 1 << 9, |
39 | 40 |
40 INVALID_TARGET = 1 << 10, | 41 INVALID_TARGET = 1 << 10, |
41 }; | 42 }; |
42 | 43 |
43 // Get the atom for a given target (of the above enum type). Will return NULL | 44 // Get the atom for a given target (of the above enum type). Will return NULL |
44 // for non-custom targets, such as CHROME_TEXT_PLAIN. | 45 // for non-custom targets, such as CHROME_TEXT_PLAIN. |
45 GdkAtom GetAtomForTarget(int target); | 46 UI_API GdkAtom GetAtomForTarget(int target); |
46 | 47 |
47 // Creates a target list from the given mask. The mask should be an OR of | 48 // Creates a target list from the given mask. The mask should be an OR of |
48 // CHROME_* values. The target list is returned with ref count 1; the caller | 49 // CHROME_* values. The target list is returned with ref count 1; the caller |
49 // is responsible for calling gtk_target_list_unref() when it is no longer | 50 // is responsible for calling gtk_target_list_unref() when it is no longer |
50 // needed. | 51 // needed. |
51 // Since the MIME type for WEBDROP_FILE_CONTENTS depends on the file's | 52 // Since the MIME type for WEBDROP_FILE_CONTENTS depends on the file's |
52 // contents, that flag is ignored by this function. It is the responsibility | 53 // contents, that flag is ignored by this function. It is the responsibility |
53 // of the client code to do the right thing. | 54 // of the client code to do the right thing. |
54 GtkTargetList* GetTargetListFromCodeMask(int code_mask); | 55 UI_API GtkTargetList* GetTargetListFromCodeMask(int code_mask); |
55 | 56 |
56 // Set the drag target list for |source| with the target list that | 57 // Set the drag target list for |source| with the target list that |
57 // corresponds to |code_mask|. | 58 // corresponds to |code_mask|. |
58 void SetSourceTargetListFromCodeMask(GtkWidget* source, int code_mask); | 59 UI_API void SetSourceTargetListFromCodeMask(GtkWidget* source, int code_mask); |
59 | 60 |
60 // Set the accepted targets list for |dest|. The |target_codes| array should | 61 // Set the accepted targets list for |dest|. The |target_codes| array should |
61 // be sorted in preference order and should be terminated with -1. | 62 // be sorted in preference order and should be terminated with -1. |
62 void SetDestTargetList(GtkWidget* dest, const int* target_codes); | 63 UI_API void SetDestTargetList(GtkWidget* dest, const int* target_codes); |
63 | 64 |
64 // Write a URL to the selection in the given type. | 65 // Write a URL to the selection in the given type. |
65 void WriteURLWithName(GtkSelectionData* selection_data, | 66 UI_API void WriteURLWithName(GtkSelectionData* selection_data, |
66 const GURL& url, | 67 const GURL& url, |
67 string16 title, | 68 string16 title, |
68 int type); | 69 int type); |
69 | 70 |
70 // Extracts data of type CHROME_NAMED_URL from |selection_data| into | 71 // Extracts data of type CHROME_NAMED_URL from |selection_data| into |
71 // |url| and |title|. Returns true if the url/title were safely extracted | 72 // |url| and |title|. Returns true if the url/title were safely extracted |
72 // and the url is valid. | 73 // and the url is valid. |
73 bool ExtractNamedURL(GtkSelectionData* selection_data, | 74 UI_API bool ExtractNamedURL(GtkSelectionData* selection_data, |
74 GURL* url, | 75 GURL* url, |
75 string16* title); | 76 string16* title); |
76 | 77 |
77 // Extracts data of type TEXT_URI_LIST from |selection_data| into |urls|. | 78 // Extracts data of type TEXT_URI_LIST from |selection_data| into |urls|. |
78 bool ExtractURIList(GtkSelectionData* selection_data, | 79 UI_API bool ExtractURIList(GtkSelectionData* selection_data, |
79 std::vector<GURL>* urls); | 80 std::vector<GURL>* urls); |
80 | 81 |
81 // Extracts a Netscape URL (url\ntitle) from |selection_data|. | 82 // Extracts a Netscape URL (url\ntitle) from |selection_data|. |
82 bool ExtractNetscapeURL(GtkSelectionData* selection_data, | 83 UI_API bool ExtractNetscapeURL(GtkSelectionData* selection_data, |
83 GURL* url, | 84 GURL* url, |
84 string16* title); | 85 string16* title); |
85 | 86 |
86 } // namespace ui | 87 } // namespace ui |
87 | 88 |
88 #endif // UI_BASE_DRAGDROP_GTK_DND_UTIL_H_ | 89 #endif // UI_BASE_DRAGDROP_GTK_DND_UTIL_H_ |
OLD | NEW |