OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/bookmarks/bookmark_utils.h" | 5 #include "chrome/browser/bookmarks/bookmark_utils.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/i18n/case_conversion.h" | 11 #include "base/i18n/case_conversion.h" |
12 #include "base/i18n/string_search.h" | 12 #include "base/i18n/string_search.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/string16.h" | 14 #include "base/string16.h" |
15 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
16 #include "base/time.h" | 16 #include "base/time.h" |
17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
18 #include "chrome/browser/bookmarks/bookmark_model.h" | 18 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
19 #include "chrome/browser/bookmarks/bookmark_node_data.h" | 20 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
20 #include "chrome/browser/history/query_parser.h" | 21 #include "chrome/browser/history/query_parser.h" |
21 #include "chrome/browser/prefs/pref_service.h" | 22 #include "chrome/browser/prefs/pref_service.h" |
22 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
24 #include "chrome/browser/ui/browser_tabstrip.h" | 25 #include "chrome/browser/ui/browser_tabstrip.h" |
25 #include "chrome/browser/ui/simple_message_box.h" | 26 #include "chrome/browser/ui/simple_message_box.h" |
26 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
27 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
28 #include "grit/chromium_strings.h" | 29 #include "grit/chromium_strings.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 // User is dragging from another app, copy. | 227 // User is dragging from another app, copy. |
227 return PreferredDropOperation(event.source_operations(), | 228 return PreferredDropOperation(event.source_operations(), |
228 ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK); | 229 ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK); |
229 } | 230 } |
230 #endif // defined(TOOLKIT_VIEWS) | 231 #endif // defined(TOOLKIT_VIEWS) |
231 | 232 |
232 int PerformBookmarkDrop(Profile* profile, | 233 int PerformBookmarkDrop(Profile* profile, |
233 const BookmarkNodeData& data, | 234 const BookmarkNodeData& data, |
234 const BookmarkNode* parent_node, | 235 const BookmarkNode* parent_node, |
235 int index) { | 236 int index) { |
236 BookmarkModel* model = profile->GetBookmarkModel(); | 237 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); |
237 if (data.IsFromProfile(profile)) { | 238 if (data.IsFromProfile(profile)) { |
238 const std::vector<const BookmarkNode*> dragged_nodes = | 239 const std::vector<const BookmarkNode*> dragged_nodes = |
239 data.GetNodes(profile); | 240 data.GetNodes(profile); |
240 if (!dragged_nodes.empty()) { | 241 if (!dragged_nodes.empty()) { |
241 // Drag from same profile. Move nodes. | 242 // Drag from same profile. Move nodes. |
242 for (size_t i = 0; i < dragged_nodes.size(); ++i) { | 243 for (size_t i = 0; i < dragged_nodes.size(); ++i) { |
243 model->Move(dragged_nodes[i], parent_node, index); | 244 model->Move(dragged_nodes[i], parent_node, index); |
244 index = parent_node->GetIndexOf(dragged_nodes[i]) + 1; | 245 index = parent_node->GetIndexOf(dragged_nodes[i]) + 1; |
245 } | 246 } |
246 return ui::DragDropTypes::DRAG_MOVE; | 247 return ui::DragDropTypes::DRAG_MOVE; |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 void DisableBookmarkBarViewAnimationsForTesting(bool disabled) { | 717 void DisableBookmarkBarViewAnimationsForTesting(bool disabled) { |
717 g_bookmark_bar_view_animations_disabled = disabled; | 718 g_bookmark_bar_view_animations_disabled = disabled; |
718 } | 719 } |
719 | 720 |
720 bool IsBookmarkBarViewAnimationsDisabled() { | 721 bool IsBookmarkBarViewAnimationsDisabled() { |
721 return g_bookmark_bar_view_animations_disabled; | 722 return g_bookmark_bar_view_animations_disabled; |
722 } | 723 } |
723 #endif | 724 #endif |
724 | 725 |
725 } // namespace bookmark_utils | 726 } // namespace bookmark_utils |
OLD | NEW |