| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/browser/gtk/bookmark_utils_gtk.h" | 5 #include "chrome/browser/gtk/bookmark_utils_gtk.h" |
| 6 | 6 |
| 7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
| 8 #include "base/gfx/gtk_util.h" | 8 #include "base/gfx/gtk_util.h" |
| 9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "chrome/browser/bookmarks/bookmark_drag_data.h" | 11 #include "chrome/browser/bookmarks/bookmark_drag_data.h" |
| 12 #include "chrome/browser/bookmarks/bookmark_model.h" | 12 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 13 #include "chrome/browser/gtk/dnd_registry.h" | |
| 14 #include "chrome/browser/gtk/gtk_chrome_button.h" | 13 #include "chrome/browser/gtk/gtk_chrome_button.h" |
| 14 #include "chrome/browser/gtk/gtk_dnd_util.h" |
| 15 #include "chrome/browser/profile.h" | 15 #include "chrome/browser/profile.h" |
| 16 #include "grit/app_resources.h" | 16 #include "grit/app_resources.h" |
| 17 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 18 #include "grit/theme_resources.h" | 18 #include "grit/theme_resources.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 // Used in gtk_selection_data_set(). (I assume from this parameter that gtk has | 22 // Used in gtk_selection_data_set(). (I assume from this parameter that gtk has |
| 23 // to some really exotic hardware...) | 23 // to some really exotic hardware...) |
| 24 const int kBitsInAByte = 8; | 24 const int kBitsInAByte = 8; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 std::vector<const BookmarkNode*> nodes; | 179 std::vector<const BookmarkNode*> nodes; |
| 180 nodes.push_back(node); | 180 nodes.push_back(node); |
| 181 WriteBookmarksToSelection(nodes, selection_data, target_type, profile); | 181 WriteBookmarksToSelection(nodes, selection_data, target_type, profile); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void WriteBookmarksToSelection(const std::vector<const BookmarkNode*>& nodes, | 184 void WriteBookmarksToSelection(const std::vector<const BookmarkNode*>& nodes, |
| 185 GtkSelectionData* selection_data, | 185 GtkSelectionData* selection_data, |
| 186 guint target_type, | 186 guint target_type, |
| 187 Profile* profile) { | 187 Profile* profile) { |
| 188 switch (target_type) { | 188 switch (target_type) { |
| 189 case dnd::X_CHROME_BOOKMARK_ITEM: { | 189 case GtkDndUtil::X_CHROME_BOOKMARK_ITEM: { |
| 190 BookmarkDragData data(nodes); | 190 BookmarkDragData data(nodes); |
| 191 Pickle pickle; | 191 Pickle pickle; |
| 192 data.WriteToPickle(profile, &pickle); | 192 data.WriteToPickle(profile, &pickle); |
| 193 | 193 |
| 194 gtk_selection_data_set(selection_data, selection_data->target, | 194 gtk_selection_data_set(selection_data, selection_data->target, |
| 195 kBitsInAByte, | 195 kBitsInAByte, |
| 196 static_cast<const guchar*>(pickle.data()), | 196 static_cast<const guchar*>(pickle.data()), |
| 197 pickle.size()); | 197 pickle.size()); |
| 198 break; | 198 break; |
| 199 } | 199 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 212 gboolean* dnd_success) { | 212 gboolean* dnd_success) { |
| 213 *delete_selection_data = FALSE; | 213 *delete_selection_data = FALSE; |
| 214 *dnd_success = FALSE; | 214 *dnd_success = FALSE; |
| 215 | 215 |
| 216 if ((selection_data != NULL) && (selection_data->length >= 0)) { | 216 if ((selection_data != NULL) && (selection_data->length >= 0)) { |
| 217 if (context->action == GDK_ACTION_MOVE) { | 217 if (context->action == GDK_ACTION_MOVE) { |
| 218 *delete_selection_data = TRUE; | 218 *delete_selection_data = TRUE; |
| 219 } | 219 } |
| 220 | 220 |
| 221 switch (target_type) { | 221 switch (target_type) { |
| 222 case dnd::X_CHROME_BOOKMARK_ITEM: { | 222 case GtkDndUtil::X_CHROME_BOOKMARK_ITEM: { |
| 223 *dnd_success = TRUE; | 223 *dnd_success = TRUE; |
| 224 Pickle pickle(reinterpret_cast<char*>(selection_data->data), | 224 Pickle pickle(reinterpret_cast<char*>(selection_data->data), |
| 225 selection_data->length); | 225 selection_data->length); |
| 226 BookmarkDragData drag_data; | 226 BookmarkDragData drag_data; |
| 227 drag_data.ReadFromPickle(&pickle); | 227 drag_data.ReadFromPickle(&pickle); |
| 228 return drag_data.GetNodes(profile); | 228 return drag_data.GetNodes(profile); |
| 229 } | 229 } |
| 230 default: { | 230 default: { |
| 231 DLOG(ERROR) << "Unsupported drag received type: " << target_type; | 231 DLOG(ERROR) << "Unsupported drag received type: " << target_type; |
| 232 } | 232 } |
| 233 } | 233 } |
| 234 } | 234 } |
| 235 | 235 |
| 236 return std::vector<const BookmarkNode*>(); | 236 return std::vector<const BookmarkNode*>(); |
| 237 } | 237 } |
| 238 | 238 |
| 239 } // namespace bookmark_utils | 239 } // namespace bookmark_utils |
| OLD | NEW |