Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/bookmarks/browser/bookmark_utils.h" | 5 #include "components/bookmarks/browser/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/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 | 200 |
| 201 if (index == -1) | 201 if (index == -1) |
| 202 index = parent->child_count(); | 202 index = parent->child_count(); |
| 203 ScopedGroupBookmarkActions group_paste(model); | 203 ScopedGroupBookmarkActions group_paste(model); |
| 204 CloneBookmarkNode(model, bookmark_data.elements, parent, index, true); | 204 CloneBookmarkNode(model, bookmark_data.elements, parent, index, true); |
| 205 } | 205 } |
| 206 | 206 |
| 207 bool CanPasteFromClipboard(BookmarkModel* model, const BookmarkNode* node) { | 207 bool CanPasteFromClipboard(BookmarkModel* model, const BookmarkNode* node) { |
| 208 if (!node || !model->client()->CanBeEditedByUser(node)) | 208 if (!node || !model->client()->CanBeEditedByUser(node)) |
| 209 return false; | 209 return false; |
| 210 return BookmarkNodeData::ClipboardContainsBookmarks(); | 210 if (BookmarkNodeData::ClipboardContainsBookmarks()) |
| 211 return true; | |
| 212 if (BookmarkNodeData::ClipboardContainsURLs()) | |
| 213 return BookmarkNodeData::WriteBookmarkToClipboardFromURL(); | |
|
sky
2014/08/05 16:53:49
CanPaste shouldn't modify the clipboard.
| |
| 214 return false; | |
| 211 } | 215 } |
| 212 | 216 |
| 213 std::vector<const BookmarkNode*> GetMostRecentlyModifiedUserFolders( | 217 std::vector<const BookmarkNode*> GetMostRecentlyModifiedUserFolders( |
| 214 BookmarkModel* model, | 218 BookmarkModel* model, |
| 215 size_t max_count) { | 219 size_t max_count) { |
| 216 std::vector<const BookmarkNode*> nodes; | 220 std::vector<const BookmarkNode*> nodes; |
| 217 ui::TreeNodeIterator<const BookmarkNode> iterator(model->root_node(), | 221 ui::TreeNodeIterator<const BookmarkNode> iterator(model->root_node(), |
| 218 PruneInvisibleFolders); | 222 PruneInvisibleFolders); |
| 219 | 223 |
| 220 while (iterator.has_next()) { | 224 while (iterator.has_next()) { |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 437 } | 441 } |
| 438 return false; | 442 return false; |
| 439 } | 443 } |
| 440 | 444 |
| 441 const BookmarkNode* GetBookmarkNodeByID(const BookmarkModel* model, int64 id) { | 445 const BookmarkNode* GetBookmarkNodeByID(const BookmarkModel* model, int64 id) { |
| 442 // TODO(sky): TreeNode needs a method that visits all nodes using a predicate. | 446 // TODO(sky): TreeNode needs a method that visits all nodes using a predicate. |
| 443 return GetNodeByID(model->root_node(), id); | 447 return GetNodeByID(model->root_node(), id); |
| 444 } | 448 } |
| 445 | 449 |
| 446 } // namespace bookmarks | 450 } // namespace bookmarks |
| OLD | NEW |