OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/views/bookmarks/bookmark_drag_drop_views.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_drag_drop_views.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "chrome/browser/bookmarks/bookmark_model.h" | 9 #include "chrome/browser/bookmarks/bookmark_model.h" |
10 #include "chrome/browser/bookmarks/bookmark_node_data.h" | 10 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 const std::vector<const BookmarkNode*>& nodes, | 23 const std::vector<const BookmarkNode*>& nodes, |
24 gfx::NativeView view) { | 24 gfx::NativeView view) { |
25 DCHECK(!nodes.empty()); | 25 DCHECK(!nodes.empty()); |
26 | 26 |
27 // Set up our OLE machinery | 27 // Set up our OLE machinery |
28 ui::OSExchangeData data; | 28 ui::OSExchangeData data; |
29 BookmarkNodeData drag_data(nodes); | 29 BookmarkNodeData drag_data(nodes); |
30 drag_data.Write(profile, &data); | 30 drag_data.Write(profile, &data); |
31 | 31 |
32 // Allow nested message loop so we get DnD events as we drag this around. | 32 // Allow nested message loop so we get DnD events as we drag this around. |
33 bool was_nested = MessageLoop::current()->IsNested(); | 33 bool was_nested = base::MessageLoop::current()->IsNested(); |
34 MessageLoop::current()->SetNestableTasksAllowed(true); | 34 base::MessageLoop::current()->SetNestableTasksAllowed(true); |
35 | 35 |
36 int operation = ui::DragDropTypes::DRAG_COPY | | 36 int operation = ui::DragDropTypes::DRAG_COPY | |
37 ui::DragDropTypes::DRAG_MOVE | | 37 ui::DragDropTypes::DRAG_MOVE | |
38 ui::DragDropTypes::DRAG_LINK; | 38 ui::DragDropTypes::DRAG_LINK; |
39 views::Widget* widget = views::Widget::GetWidgetForNativeView(view); | 39 views::Widget* widget = views::Widget::GetWidgetForNativeView(view); |
40 // TODO(varunjain): Properly determine and send DRAG_EVENT_SOURCE below. | 40 // TODO(varunjain): Properly determine and send DRAG_EVENT_SOURCE below. |
41 if (widget) { | 41 if (widget) { |
42 widget->RunShellDrag(NULL, data, gfx::Point(), operation, | 42 widget->RunShellDrag(NULL, data, gfx::Point(), operation, |
43 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); | 43 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); |
44 } else { | 44 } else { |
45 // We hit this case when we're using WebContentsViewWin or | 45 // We hit this case when we're using WebContentsViewWin or |
46 // WebContentsViewAura, instead of WebContentsViewViews. | 46 // WebContentsViewAura, instead of WebContentsViewViews. |
47 views::RunShellDrag(view, data, gfx::Point(), operation, | 47 views::RunShellDrag(view, data, gfx::Point(), operation, |
48 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); | 48 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); |
49 } | 49 } |
50 | 50 |
51 MessageLoop::current()->SetNestableTasksAllowed(was_nested); | 51 base::MessageLoop::current()->SetNestableTasksAllowed(was_nested); |
52 } | 52 } |
53 | 53 |
54 int GetBookmarkDragOperation(content::BrowserContext* browser_context, | 54 int GetBookmarkDragOperation(content::BrowserContext* browser_context, |
55 const BookmarkNode* node) { | 55 const BookmarkNode* node) { |
56 PrefService* prefs = components::UserPrefs::Get(browser_context); | 56 PrefService* prefs = components::UserPrefs::Get(browser_context); |
57 | 57 |
58 int move = ui::DragDropTypes::DRAG_MOVE; | 58 int move = ui::DragDropTypes::DRAG_MOVE; |
59 if (!prefs->GetBoolean(prefs::kEditBookmarksEnabled)) | 59 if (!prefs->GetBoolean(prefs::kEditBookmarksEnabled)) |
60 move = ui::DragDropTypes::DRAG_NONE; | 60 move = ui::DragDropTypes::DRAG_NONE; |
61 if (node->is_url()) | 61 if (node->is_url()) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 if (drop_parent->HasAncestor(node)) | 124 if (drop_parent->HasAncestor(node)) |
125 return false; | 125 return false; |
126 } | 126 } |
127 return true; | 127 return true; |
128 } | 128 } |
129 // From the same profile, always accept. | 129 // From the same profile, always accept. |
130 return true; | 130 return true; |
131 } | 131 } |
132 | 132 |
133 } // namespace chrome | 133 } // namespace chrome |
OLD | NEW |