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/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h" | 11 #include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h" |
12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
13 #include "components/bookmarks/browser/bookmark_model.h" | 13 #include "components/bookmarks/browser/bookmark_model.h" |
14 #include "components/bookmarks/browser/bookmark_node_data.h" | 14 #include "components/bookmarks/browser/bookmark_node_data.h" |
15 #include "components/bookmarks/browser/bookmark_utils.h" | 15 #include "components/bookmarks/browser/bookmark_utils.h" |
16 #include "components/user_prefs/user_prefs.h" | 16 #include "components/user_prefs/user_prefs.h" |
17 #include "ui/base/dragdrop/drag_drop_types.h" | 17 #include "ui/base/dragdrop/drag_drop_types.h" |
18 #include "ui/base/dragdrop/os_exchange_data.h" | 18 #include "ui/base/dragdrop/os_exchange_data.h" |
19 #include "ui/events/event.h" | 19 #include "ui/events/event.h" |
20 #include "ui/views/drag_utils.h" | 20 #include "ui/views/drag_utils.h" |
21 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
22 | 22 |
23 using bookmarks::BookmarkNodeData; | 23 using bookmarks::BookmarkNodeData; |
24 | 24 |
25 namespace chrome { | 25 namespace chrome { |
26 | 26 |
| 27 #if !defined(OS_MACOSX) |
27 void DragBookmarks(Profile* profile, | 28 void DragBookmarks(Profile* profile, |
28 const std::vector<const BookmarkNode*>& nodes, | 29 const std::vector<const BookmarkNode*>& nodes, |
29 gfx::NativeView view, | 30 gfx::NativeView view, |
30 ui::DragDropTypes::DragEventSource source) { | 31 ui::DragDropTypes::DragEventSource source) { |
31 DCHECK(!nodes.empty()); | 32 DCHECK(!nodes.empty()); |
32 | 33 |
33 // Set up our OLE machinery. | 34 // Set up our OLE machinery. |
34 ui::OSExchangeData data; | 35 ui::OSExchangeData data; |
35 BookmarkNodeData drag_data(nodes); | 36 BookmarkNodeData drag_data(nodes); |
36 drag_data.Write(profile->GetPath(), &data); | 37 drag_data.Write(profile->GetPath(), &data); |
(...skipping 12 matching lines...) Loading... |
49 if (widget) { | 50 if (widget) { |
50 widget->RunShellDrag(NULL, data, gfx::Point(), operation, source); | 51 widget->RunShellDrag(NULL, data, gfx::Point(), operation, source); |
51 } else { | 52 } else { |
52 // We hit this case when we're using WebContentsViewWin or | 53 // We hit this case when we're using WebContentsViewWin or |
53 // WebContentsViewAura, instead of WebContentsViewViews. | 54 // WebContentsViewAura, instead of WebContentsViewViews. |
54 views::RunShellDrag(view, data, gfx::Point(), operation, source); | 55 views::RunShellDrag(view, data, gfx::Point(), operation, source); |
55 } | 56 } |
56 | 57 |
57 base::MessageLoop::current()->SetNestableTasksAllowed(was_nested); | 58 base::MessageLoop::current()->SetNestableTasksAllowed(was_nested); |
58 } | 59 } |
| 60 #endif |
59 | 61 |
60 int GetBookmarkDragOperation(content::BrowserContext* browser_context, | 62 int GetBookmarkDragOperation(content::BrowserContext* browser_context, |
61 const BookmarkNode* node) { | 63 const BookmarkNode* node) { |
62 PrefService* prefs = user_prefs::UserPrefs::Get(browser_context); | 64 PrefService* prefs = user_prefs::UserPrefs::Get(browser_context); |
63 Profile* profile = Profile::FromBrowserContext(browser_context); | 65 Profile* profile = Profile::FromBrowserContext(browser_context); |
64 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); | 66 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); |
65 | 67 |
66 int move = ui::DragDropTypes::DRAG_MOVE; | 68 int move = ui::DragDropTypes::DRAG_MOVE; |
67 if (!prefs->GetBoolean(bookmarks::prefs::kEditBookmarksEnabled) || | 69 if (!prefs->GetBoolean(bookmarks::prefs::kEditBookmarksEnabled) || |
68 !model->client()->CanBeEditedByUser(node)) { | 70 !model->client()->CanBeEditedByUser(node)) { |
(...skipping 84 matching lines...) Loading... |
153 if (drop_parent->HasAncestor(node)) | 155 if (drop_parent->HasAncestor(node)) |
154 return false; | 156 return false; |
155 } | 157 } |
156 return true; | 158 return true; |
157 } | 159 } |
158 // From another profile, always accept. | 160 // From another profile, always accept. |
159 return true; | 161 return true; |
160 } | 162 } |
161 | 163 |
162 } // namespace chrome | 164 } // namespace chrome |
OLD | NEW |