| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 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 | 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_drag_data.h" | 5 #include "chrome/browser/bookmarks/bookmark_drag_data.h" |
| 6 | 6 |
| 7 // TODO(port): Port this file. | 7 // TODO(port): Port this file. |
| 8 #if defined(TOOLKIT_VIEWS) | 8 #if defined(TOOLKIT_VIEWS) |
| 9 #include "app/os_exchange_data.h" | 9 #include "app/os_exchange_data.h" |
| 10 #else | 10 #else |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 title(node->GetTitle()), | 34 title(node->GetTitle()), |
| 35 id_(node->id()) { | 35 id_(node->id()) { |
| 36 for (int i = 0; i < node->GetChildCount(); ++i) | 36 for (int i = 0; i < node->GetChildCount(); ++i) |
| 37 children.push_back(Element(node->GetChild(i))); | 37 children.push_back(Element(node->GetChild(i))); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void BookmarkDragData::Element::WriteToPickle(Pickle* pickle) const { | 40 void BookmarkDragData::Element::WriteToPickle(Pickle* pickle) const { |
| 41 pickle->WriteBool(is_url); | 41 pickle->WriteBool(is_url); |
| 42 pickle->WriteString(url.spec()); | 42 pickle->WriteString(url.spec()); |
| 43 pickle->WriteWString(title); | 43 pickle->WriteWString(title); |
| 44 pickle->WriteInt(id_); | 44 pickle->WriteInt64(id_); |
| 45 if (!is_url) { | 45 if (!is_url) { |
| 46 pickle->WriteSize(children.size()); | 46 pickle->WriteSize(children.size()); |
| 47 for (std::vector<Element>::const_iterator i = children.begin(); | 47 for (std::vector<Element>::const_iterator i = children.begin(); |
| 48 i != children.end(); ++i) { | 48 i != children.end(); ++i) { |
| 49 i->WriteToPickle(pickle); | 49 i->WriteToPickle(pickle); |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 bool BookmarkDragData::Element::ReadFromPickle(Pickle* pickle, | 54 bool BookmarkDragData::Element::ReadFromPickle(Pickle* pickle, |
| 55 void** iterator) { | 55 void** iterator) { |
| 56 std::string url_spec; | 56 std::string url_spec; |
| 57 if (!pickle->ReadBool(iterator, &is_url) || | 57 if (!pickle->ReadBool(iterator, &is_url) || |
| 58 !pickle->ReadString(iterator, &url_spec) || | 58 !pickle->ReadString(iterator, &url_spec) || |
| 59 !pickle->ReadWString(iterator, &title) || | 59 !pickle->ReadWString(iterator, &title) || |
| 60 !pickle->ReadInt(iterator, &id_)) { | 60 !pickle->ReadInt64(iterator, &id_)) { |
| 61 return false; | 61 return false; |
| 62 } | 62 } |
| 63 url = GURL(url_spec); | 63 url = GURL(url_spec); |
| 64 children.clear(); | 64 children.clear(); |
| 65 if (!is_url) { | 65 if (!is_url) { |
| 66 size_t children_count; | 66 size_t children_count; |
| 67 if (!pickle->ReadSize(iterator, &children_count)) | 67 if (!pickle->ReadSize(iterator, &children_count)) |
| 68 return false; | 68 return false; |
| 69 children.resize(children_count); | 69 children.resize(children_count); |
| 70 for (std::vector<Element>::iterator i = children.begin(); | 70 for (std::vector<Element>::iterator i = children.begin(); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 212 |
| 213 bool BookmarkDragData::IsFromProfile(Profile* profile) const { | 213 bool BookmarkDragData::IsFromProfile(Profile* profile) const { |
| 214 // An empty path means the data is not associated with any profile. | 214 // An empty path means the data is not associated with any profile. |
| 215 return (!profile_path_.empty() && | 215 return (!profile_path_.empty() && |
| 216 #if defined(WCHAR_T_IS_UTF16) | 216 #if defined(WCHAR_T_IS_UTF16) |
| 217 profile->GetPath().ToWStringHack() == profile_path_); | 217 profile->GetPath().ToWStringHack() == profile_path_); |
| 218 #elif defined(WCHAR_T_IS_UTF32) | 218 #elif defined(WCHAR_T_IS_UTF32) |
| 219 profile->GetPath().value() == profile_path_); | 219 profile->GetPath().value() == profile_path_); |
| 220 #endif | 220 #endif |
| 221 } | 221 } |
| OLD | NEW |