| 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/bookmarks/bookmark_drag_drop.h" | 5 #include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "components/bookmarks/browser/bookmark_model.h" | 10 #include "components/bookmarks/browser/bookmark_model.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 const std::vector<const BookmarkNode*>& nodes, | 24 const std::vector<const BookmarkNode*>& nodes, |
| 25 gfx::NativeView view, | 25 gfx::NativeView view, |
| 26 ui::DragDropTypes::DragEventSource source) { | 26 ui::DragDropTypes::DragEventSource source) { |
| 27 DCHECK(!nodes.empty()); | 27 DCHECK(!nodes.empty()); |
| 28 | 28 |
| 29 // Set up our OLE machinery. | 29 // Set up our OLE machinery. |
| 30 ui::OSExchangeData data; | 30 ui::OSExchangeData data; |
| 31 bookmarks::BookmarkNodeData drag_data(nodes); | 31 bookmarks::BookmarkNodeData drag_data(nodes); |
| 32 drag_data.Write(profile->GetPath(), &data); | 32 drag_data.Write(profile->GetPath(), &data); |
| 33 | 33 |
| 34 // Allow nested message loop so we get DnD events as we drag this around. | 34 // Allow nested run loop so we get DnD events as we drag this around. |
| 35 base::MessageLoop::ScopedNestableTaskAllower nestable_task_allower( | 35 base::MessageLoop::ScopedNestableTaskAllower nestable_task_allower( |
| 36 base::MessageLoop::current()); | 36 base::MessageLoop::current()); |
| 37 | 37 |
| 38 int operation = ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK; | 38 int operation = ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK; |
| 39 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile); | 39 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile); |
| 40 if (bookmarks::CanAllBeEditedByUser(model->client(), nodes)) | 40 if (bookmarks::CanAllBeEditedByUser(model->client(), nodes)) |
| 41 operation |= ui::DragDropTypes::DRAG_MOVE; | 41 operation |= ui::DragDropTypes::DRAG_MOVE; |
| 42 | 42 |
| 43 views::Widget* widget = views::Widget::GetWidgetForNativeView(view); | 43 views::Widget* widget = views::Widget::GetWidgetForNativeView(view); |
| 44 | 44 |
| 45 if (widget) { | 45 if (widget) { |
| 46 widget->RunShellDrag(NULL, data, gfx::Point(), operation, source); | 46 widget->RunShellDrag(NULL, data, gfx::Point(), operation, source); |
| 47 } else { | 47 } else { |
| 48 // We hit this case when we're using WebContentsViewWin or | 48 // We hit this case when we're using WebContentsViewWin or |
| 49 // WebContentsViewAura, instead of WebContentsViewViews. | 49 // WebContentsViewAura, instead of WebContentsViewViews. |
| 50 views::RunShellDrag(view, data, gfx::Point(), operation, source); | 50 views::RunShellDrag(view, data, gfx::Point(), operation, source); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 } // namespace chrome | 54 } // namespace chrome |
| OLD | NEW |