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 #include "chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h" | 5 #include "chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "chrome/common/extensions/extension_constants.h" | 35 #include "chrome/common/extensions/extension_constants.h" |
36 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
37 #include "content/browser/tab_contents/tab_contents.h" | 37 #include "content/browser/tab_contents/tab_contents.h" |
38 #include "content/browser/tab_contents/tab_contents_view.h" | 38 #include "content/browser/tab_contents/tab_contents_view.h" |
39 #include "content/browser/user_metrics.h" | 39 #include "content/browser/user_metrics.h" |
40 #include "content/public/browser/notification_details.h" | 40 #include "content/public/browser/notification_details.h" |
41 #include "content/public/browser/notification_source.h" | 41 #include "content/public/browser/notification_source.h" |
42 #include "grit/generated_resources.h" | 42 #include "grit/generated_resources.h" |
43 #include "grit/theme_resources.h" | 43 #include "grit/theme_resources.h" |
44 #include "grit/ui_resources.h" | 44 #include "grit/ui_resources.h" |
| 45 #include "ui/base/dragdrop/drag_drop_types.h" |
45 #include "ui/base/dragdrop/gtk_dnd_util.h" | 46 #include "ui/base/dragdrop/gtk_dnd_util.h" |
46 #include "ui/base/l10n/l10n_util.h" | 47 #include "ui/base/l10n/l10n_util.h" |
47 #include "ui/base/resource/resource_bundle.h" | 48 #include "ui/base/resource/resource_bundle.h" |
48 #include "ui/gfx/canvas_skia_paint.h" | 49 #include "ui/gfx/canvas_skia_paint.h" |
49 #include "ui/gfx/gtk_util.h" | 50 #include "ui/gfx/gtk_util.h" |
50 #include "ui/gfx/image/cairo_cached_surface.h" | 51 #include "ui/gfx/image/cairo_cached_surface.h" |
51 #include "ui/gfx/image/image.h" | 52 #include "ui/gfx/image/image.h" |
52 | 53 |
53 namespace { | 54 namespace { |
54 | 55 |
(...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1266 } else { | 1267 } else { |
1267 index = GetToolbarIndexForDragOverFolder(widget, x); | 1268 index = GetToolbarIndexForDragOverFolder(widget, x); |
1268 if (index < 0) { | 1269 if (index < 0) { |
1269 dest_node = GetNodeForToolButton(widget); | 1270 dest_node = GetNodeForToolButton(widget); |
1270 index = dest_node->child_count(); | 1271 index = dest_node->child_count(); |
1271 } | 1272 } |
1272 } | 1273 } |
1273 | 1274 |
1274 switch (target_type) { | 1275 switch (target_type) { |
1275 case ui::CHROME_BOOKMARK_ITEM: { | 1276 case ui::CHROME_BOOKMARK_ITEM: { |
1276 std::vector<const BookmarkNode*> nodes = | 1277 Pickle pickle(reinterpret_cast<char*>(selection_data->data), |
1277 bookmark_utils::GetNodesFromSelection(context, selection_data, | 1278 selection_data->length); |
1278 target_type, | 1279 BookmarkNodeData drag_data; |
1279 browser_->profile(), | 1280 DCHECK(drag_data.ReadFromPickle(&pickle)); |
1280 &delete_selection_data, | 1281 dnd_success = bookmark_utils::PerformBookmarkDrop( |
1281 &dnd_success); | 1282 browser_->profile(), |
1282 DCHECK(!nodes.empty()); | 1283 drag_data, |
1283 for (std::vector<const BookmarkNode*>::iterator it = nodes.begin(); | 1284 dest_node, |
1284 it != nodes.end(); ++it) { | 1285 index) != ui::DragDropTypes::DRAG_NONE; |
1285 model_->Move(*it, dest_node, index); | |
1286 index = dest_node->GetIndexOf(*it) + 1; | |
1287 } | |
1288 break; | 1286 break; |
1289 } | 1287 } |
1290 | 1288 |
1291 case ui::CHROME_NAMED_URL: { | 1289 case ui::CHROME_NAMED_URL: { |
1292 dnd_success = bookmark_utils::CreateNewBookmarkFromNamedUrl( | 1290 dnd_success = bookmark_utils::CreateNewBookmarkFromNamedUrl( |
1293 selection_data, model_, dest_node, index); | 1291 selection_data, model_, dest_node, index); |
1294 break; | 1292 break; |
1295 } | 1293 } |
1296 | 1294 |
1297 case ui::TEXT_URI_LIST: { | 1295 case ui::TEXT_URI_LIST: { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1438 void BookmarkBarGtk::OnEditBookmarksEnabledChanged() { | 1436 void BookmarkBarGtk::OnEditBookmarksEnabledChanged() { |
1439 GtkDestDefaults dest_defaults = | 1437 GtkDestDefaults dest_defaults = |
1440 *edit_bookmarks_enabled_ ? GTK_DEST_DEFAULT_ALL : | 1438 *edit_bookmarks_enabled_ ? GTK_DEST_DEFAULT_ALL : |
1441 GTK_DEST_DEFAULT_DROP; | 1439 GTK_DEST_DEFAULT_DROP; |
1442 gtk_drag_dest_set(overflow_button_, dest_defaults, NULL, 0, kDragAction); | 1440 gtk_drag_dest_set(overflow_button_, dest_defaults, NULL, 0, kDragAction); |
1443 gtk_drag_dest_set(other_bookmarks_button_, dest_defaults, | 1441 gtk_drag_dest_set(other_bookmarks_button_, dest_defaults, |
1444 NULL, 0, kDragAction); | 1442 NULL, 0, kDragAction); |
1445 ui::SetDestTargetList(overflow_button_, kDestTargetList); | 1443 ui::SetDestTargetList(overflow_button_, kDestTargetList); |
1446 ui::SetDestTargetList(other_bookmarks_button_, kDestTargetList); | 1444 ui::SetDestTargetList(other_bookmarks_button_, kDestTargetList); |
1447 } | 1445 } |
OLD | NEW |