| 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 #ifndef COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_DATA_H_ | 5 #ifndef COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_DATA_H_ |
| 6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_DATA_H_ | 6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_DATA_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "components/bookmarks/browser/bookmark_node.h" | 13 #include "components/bookmarks/browser/bookmark_node.h" |
| 14 #include "ui/base/clipboard/clipboard_types.h" | 14 #include "ui/base/clipboard/clipboard_types.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 | 16 |
| 17 #if defined(TOOLKIT_VIEWS) | 17 #if defined(TOOLKIT_VIEWS) |
| 18 #include "ui/base/dragdrop/os_exchange_data.h" | 18 #include "ui/base/dragdrop/os_exchange_data.h" |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 namespace base { |
| 21 class Pickle; | 22 class Pickle; |
| 22 class PickleIterator; | 23 class PickleIterator; |
| 24 } |
| 23 | 25 |
| 24 namespace bookmarks { | 26 namespace bookmarks { |
| 25 | 27 |
| 26 class BookmarkModel; | 28 class BookmarkModel; |
| 27 | 29 |
| 28 // BookmarkNodeData is used to represent the following: | 30 // BookmarkNodeData is used to represent the following: |
| 29 // | 31 // |
| 30 // . A single URL. | 32 // . A single URL. |
| 31 // . A single node from the bookmark model. | 33 // . A single node from the bookmark model. |
| 32 // . A set of nodes from the bookmark model. | 34 // . A set of nodes from the bookmark model. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 72 |
| 71 // Meta info for the bookmark node. | 73 // Meta info for the bookmark node. |
| 72 BookmarkNode::MetaInfoMap meta_info_map; | 74 BookmarkNode::MetaInfoMap meta_info_map; |
| 73 | 75 |
| 74 int64 id() const { return id_; } | 76 int64 id() const { return id_; } |
| 75 | 77 |
| 76 private: | 78 private: |
| 77 friend struct BookmarkNodeData; | 79 friend struct BookmarkNodeData; |
| 78 | 80 |
| 79 // For reading/writing this Element. | 81 // For reading/writing this Element. |
| 80 void WriteToPickle(Pickle* pickle) const; | 82 void WriteToPickle(base::Pickle* pickle) const; |
| 81 bool ReadFromPickle(PickleIterator* iterator); | 83 bool ReadFromPickle(base::PickleIterator* iterator); |
| 82 | 84 |
| 83 // ID of the node. | 85 // ID of the node. |
| 84 int64 id_; | 86 int64 id_; |
| 85 }; | 87 }; |
| 86 | 88 |
| 87 // The MIME type for the clipboard format for BookmarkNodeData. | 89 // The MIME type for the clipboard format for BookmarkNodeData. |
| 88 static const char* kClipboardFormatString; | 90 static const char* kClipboardFormatString; |
| 89 | 91 |
| 90 BookmarkNodeData(); | 92 BookmarkNodeData(); |
| 91 | 93 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 121 // |profile_path| is used to identify which profile the data came from. Use an | 123 // |profile_path| is used to identify which profile the data came from. Use an |
| 122 // empty path to indicate that the data is not associated with any profile. | 124 // empty path to indicate that the data is not associated with any profile. |
| 123 void Write(const base::FilePath& profile_path, | 125 void Write(const base::FilePath& profile_path, |
| 124 ui::OSExchangeData* data) const; | 126 ui::OSExchangeData* data) const; |
| 125 | 127 |
| 126 // Restores this data from the clipboard, returning true on success. | 128 // Restores this data from the clipboard, returning true on success. |
| 127 bool Read(const ui::OSExchangeData& data); | 129 bool Read(const ui::OSExchangeData& data); |
| 128 #endif | 130 #endif |
| 129 | 131 |
| 130 // Writes the data for a drag to |pickle|. | 132 // Writes the data for a drag to |pickle|. |
| 131 void WriteToPickle(const base::FilePath& profile_path, Pickle* pickle) const; | 133 void WriteToPickle(const base::FilePath& profile_path, |
| 134 base::Pickle* pickle) const; |
| 132 | 135 |
| 133 // Reads the data for a drag from a |pickle|. | 136 // Reads the data for a drag from a |pickle|. |
| 134 bool ReadFromPickle(Pickle* pickle); | 137 bool ReadFromPickle(base::Pickle* pickle); |
| 135 | 138 |
| 136 // Returns the nodes represented by this DragData. If this DragData was | 139 // Returns the nodes represented by this DragData. If this DragData was |
| 137 // created from the same profile then the nodes from the model are returned. | 140 // created from the same profile then the nodes from the model are returned. |
| 138 // If the nodes can't be found (may have been deleted), an empty vector is | 141 // If the nodes can't be found (may have been deleted), an empty vector is |
| 139 // returned. | 142 // returned. |
| 140 std::vector<const BookmarkNode*> GetNodes( | 143 std::vector<const BookmarkNode*> GetNodes( |
| 141 BookmarkModel* model, | 144 BookmarkModel* model, |
| 142 const base::FilePath& profile_path) const; | 145 const base::FilePath& profile_path) const; |
| 143 | 146 |
| 144 // Convenience for getting the first node. Returns NULL if the data doesn't | 147 // Convenience for getting the first node. Returns NULL if the data doesn't |
| (...skipping 25 matching lines...) Expand all Loading... |
| 170 std::vector<Element> elements; | 173 std::vector<Element> elements; |
| 171 | 174 |
| 172 private: | 175 private: |
| 173 // Path of the profile we originated from. | 176 // Path of the profile we originated from. |
| 174 base::FilePath profile_path_; | 177 base::FilePath profile_path_; |
| 175 }; | 178 }; |
| 176 | 179 |
| 177 } // namespace bookmarks | 180 } // namespace bookmarks |
| 178 | 181 |
| 179 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_DATA_H_ | 182 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_DATA_H_ |
| OLD | NEW |