| 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 #include "ui/base/ui_export.h" |
| 15 | 15 |
| 16 class GURL; | 16 class GURL; |
| 17 | 17 |
| 18 namespace ui { | 18 namespace ui { |
| 19 | 19 |
| 20 // Registry of all internal int codes for drag and drop. | 20 // Registry of all internal int codes for drag and drop. |
| 21 enum { | 21 enum { |
| 22 // Intra-application types. | 22 // Intra-application types. |
| 23 CHROME_TAB = 1 << 0, | 23 CHROME_TAB = 1 << 0, |
| 24 CHROME_BOOKMARK_ITEM = 1 << 1, | 24 CHROME_BOOKMARK_ITEM = 1 << 1, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 // Used for drag-out download. | 37 // Used for drag-out download. |
| 38 TEXT_PLAIN_NO_CHARSET = 1 << 8, | 38 TEXT_PLAIN_NO_CHARSET = 1 << 8, |
| 39 DIRECT_SAVE_FILE = 1 << 9, | 39 DIRECT_SAVE_FILE = 1 << 9, |
| 40 | 40 |
| 41 INVALID_TARGET = 1 << 10, | 41 INVALID_TARGET = 1 << 10, |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 // 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 |
| 45 // for non-custom targets, such as CHROME_TEXT_PLAIN. | 45 // for non-custom targets, such as CHROME_TEXT_PLAIN. |
| 46 UI_API GdkAtom GetAtomForTarget(int target); | 46 UI_EXPORT GdkAtom GetAtomForTarget(int target); |
| 47 | 47 |
| 48 // 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 |
| 49 // 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 |
| 50 // 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 |
| 51 // needed. | 51 // needed. |
| 52 // 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 |
| 53 // 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 |
| 54 // of the client code to do the right thing. | 54 // of the client code to do the right thing. |
| 55 UI_API GtkTargetList* GetTargetListFromCodeMask(int code_mask); | 55 UI_EXPORT GtkTargetList* GetTargetListFromCodeMask(int code_mask); |
| 56 | 56 |
| 57 // 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 |
| 58 // corresponds to |code_mask|. | 58 // corresponds to |code_mask|. |
| 59 UI_API void SetSourceTargetListFromCodeMask(GtkWidget* source, int code_mask); | 59 UI_EXPORT void SetSourceTargetListFromCodeMask(GtkWidget* source, |
| 60 int code_mask); |
| 60 | 61 |
| 61 // Set the accepted targets list for |dest|. The |target_codes| array should | 62 // Set the accepted targets list for |dest|. The |target_codes| array should |
| 62 // be sorted in preference order and should be terminated with -1. | 63 // be sorted in preference order and should be terminated with -1. |
| 63 UI_API void SetDestTargetList(GtkWidget* dest, const int* target_codes); | 64 UI_EXPORT void SetDestTargetList(GtkWidget* dest, const int* target_codes); |
| 64 | 65 |
| 65 // Write a URL to the selection in the given type. | 66 // Write a URL to the selection in the given type. |
| 66 UI_API void WriteURLWithName(GtkSelectionData* selection_data, | 67 UI_EXPORT void WriteURLWithName(GtkSelectionData* selection_data, |
| 67 const GURL& url, | 68 const GURL& url, |
| 68 string16 title, | 69 string16 title, |
| 69 int type); | 70 int type); |
| 70 | 71 |
| 71 // Extracts data of type CHROME_NAMED_URL from |selection_data| into | 72 // Extracts data of type CHROME_NAMED_URL from |selection_data| into |
| 72 // |url| and |title|. Returns true if the url/title were safely extracted | 73 // |url| and |title|. Returns true if the url/title were safely extracted |
| 73 // and the url is valid. | 74 // and the url is valid. |
| 74 UI_API bool ExtractNamedURL(GtkSelectionData* selection_data, | 75 UI_EXPORT bool ExtractNamedURL(GtkSelectionData* selection_data, |
| 75 GURL* url, | |
| 76 string16* title); | |
| 77 | |
| 78 // Extracts data of type TEXT_URI_LIST from |selection_data| into |urls|. | |
| 79 UI_API bool ExtractURIList(GtkSelectionData* selection_data, | |
| 80 std::vector<GURL>* urls); | |
| 81 | |
| 82 // Extracts a Netscape URL (url\ntitle) from |selection_data|. | |
| 83 UI_API bool ExtractNetscapeURL(GtkSelectionData* selection_data, | |
| 84 GURL* url, | 76 GURL* url, |
| 85 string16* title); | 77 string16* title); |
| 86 | 78 |
| 79 // Extracts data of type TEXT_URI_LIST from |selection_data| into |urls|. |
| 80 UI_EXPORT bool ExtractURIList(GtkSelectionData* selection_data, |
| 81 std::vector<GURL>* urls); |
| 82 |
| 83 // Extracts a Netscape URL (url\ntitle) from |selection_data|. |
| 84 UI_EXPORT bool ExtractNetscapeURL(GtkSelectionData* selection_data, |
| 85 GURL* url, |
| 86 string16* title); |
| 87 |
| 87 } // namespace ui | 88 } // namespace ui |
| 88 | 89 |
| 89 #endif // UI_BASE_DRAGDROP_GTK_DND_UTIL_H_ | 90 #endif // UI_BASE_DRAGDROP_GTK_DND_UTIL_H_ |
| OLD | NEW |