| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_BOOKMARK_DRAG_DATA_ | |
| 6 #define CHROME_BROWSER_BOOKMARK_DRAG_DATA_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "chrome/browser/history/history.h" | |
| 11 #include "googleurl/src/gurl.h" | |
| 12 | |
| 13 class BookmarkBarModel; | |
| 14 class BookmarkBarNode; | |
| 15 class OSExchangeData; | |
| 16 class Pickle; | |
| 17 | |
| 18 // BookmarkDragData is used by the bookmark bar to represent a dragged | |
| 19 // URL or starred group on the clipboard during drag and drop. | |
| 20 // | |
| 21 // Typical usage when writing data for a drag is: | |
| 22 // BookmarkDragData data(node_user_is_dragging); | |
| 23 // data.profile_id = profile_id; | |
| 24 // data.Write(os_exchange_data_for_drag); | |
| 25 // | |
| 26 // Typical usage to read is: | |
| 27 // BookmarkDragData data; | |
| 28 // if (data.Read(os_exchange_data)) | |
| 29 // // data is valid | |
| 30 | |
| 31 struct BookmarkDragData { | |
| 32 BookmarkDragData(); | |
| 33 | |
| 34 // Created a BookmarkDragData populated from node. | |
| 35 explicit BookmarkDragData(BookmarkBarNode* node); | |
| 36 | |
| 37 // Writes this BookmarkDragData to data. If BookmarkDragData is a URL, | |
| 38 // this writes out the URL and URL title clipboard data as well. | |
| 39 void Write(OSExchangeData* data) const; | |
| 40 | |
| 41 // Restores this data from the clipboard, returning true on success. | |
| 42 bool Read(const OSExchangeData& data); | |
| 43 | |
| 44 // Returns the node represented by this drag data from root. If the | |
| 45 // path can not be found, NULL is returned. | |
| 46 // | |
| 47 // This is only valid for groups. | |
| 48 BookmarkBarNode* BookmarkDragData::GetNode(BookmarkBarModel* model) const; | |
| 49 | |
| 50 // If true, this entry represents a StarredEntry of type URL. | |
| 51 bool is_url; | |
| 52 | |
| 53 // ID of the profile we originated from. | |
| 54 std::wstring profile_id; | |
| 55 | |
| 56 // The URL, only valid if is_url is true. | |
| 57 GURL url; | |
| 58 | |
| 59 // Title of the entry | |
| 60 std::wstring title; | |
| 61 | |
| 62 // Children, only used for non-URL nodes. | |
| 63 std::vector<BookmarkDragData> children; | |
| 64 | |
| 65 // If true our data is valid. | |
| 66 bool is_valid; | |
| 67 | |
| 68 private: | |
| 69 // Writes the data to a Pickle. | |
| 70 void WriteToPickle(Pickle* pickle) const; | |
| 71 | |
| 72 bool ReadFromPickle(Pickle* pickle, void** iterator); | |
| 73 | |
| 74 // Adds to children an entry for each child of node. | |
| 75 void AddChildren(BookmarkBarNode* node); | |
| 76 | |
| 77 // ID (node->id()) of the node this BookmarkDragData was created from. | |
| 78 int id_; | |
| 79 }; | |
| 80 | |
| 81 #endif // CHROME_BROWSER_BOOKMARK_DRAG_DATA_ | |
| 82 | |
| OLD | NEW |