OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_node_data.h" | 5 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 i != children.end(); ++i) { | 74 i != children.end(); ++i) { |
75 if (!i->ReadFromPickle(pickle, iterator)) | 75 if (!i->ReadFromPickle(pickle, iterator)) |
76 return false; | 76 return false; |
77 } | 77 } |
78 } | 78 } |
79 return true; | 79 return true; |
80 } | 80 } |
81 | 81 |
82 #if defined(TOOLKIT_VIEWS) | 82 #if defined(TOOLKIT_VIEWS) |
83 // static | 83 // static |
84 OSExchangeData::CustomFormat BookmarkNodeData::GetBookmarkCustomFormat() { | 84 ui::OSExchangeData::CustomFormat BookmarkNodeData::GetBookmarkCustomFormat() { |
85 static OSExchangeData::CustomFormat format; | 85 static ui::OSExchangeData::CustomFormat format; |
86 static bool format_valid = false; | 86 static bool format_valid = false; |
87 | 87 |
88 if (!format_valid) { | 88 if (!format_valid) { |
89 format_valid = true; | 89 format_valid = true; |
90 format = OSExchangeData::RegisterCustomFormat( | 90 format = ui::OSExchangeData::RegisterCustomFormat( |
91 BookmarkNodeData::kClipboardFormatString); | 91 BookmarkNodeData::kClipboardFormatString); |
92 } | 92 } |
93 return format; | 93 return format; |
94 } | 94 } |
95 #endif | 95 #endif |
96 | 96 |
97 BookmarkNodeData::BookmarkNodeData() { | 97 BookmarkNodeData::BookmarkNodeData() { |
98 } | 98 } |
99 | 99 |
100 BookmarkNodeData::BookmarkNodeData(const BookmarkNode* node) { | 100 BookmarkNodeData::BookmarkNodeData(const BookmarkNode* node) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 return bookmark_pasteboard_helper_mac::ReadFromDragClipboard(elements, | 210 return bookmark_pasteboard_helper_mac::ReadFromDragClipboard(elements, |
211 &profile_path_); | 211 &profile_path_); |
212 } | 212 } |
213 | 213 |
214 bool BookmarkNodeData::ClipboardContainsBookmarks() { | 214 bool BookmarkNodeData::ClipboardContainsBookmarks() { |
215 return bookmark_pasteboard_helper_mac::ClipboardContainsBookmarks(); | 215 return bookmark_pasteboard_helper_mac::ClipboardContainsBookmarks(); |
216 } | 216 } |
217 #endif // !defined(OS_MACOSX) | 217 #endif // !defined(OS_MACOSX) |
218 | 218 |
219 #if defined(TOOLKIT_VIEWS) | 219 #if defined(TOOLKIT_VIEWS) |
220 void BookmarkNodeData::Write(Profile* profile, OSExchangeData* data) const { | 220 void BookmarkNodeData::Write(Profile* profile, ui::OSExchangeData* data) const { |
221 DCHECK(data); | 221 DCHECK(data); |
222 | 222 |
223 // If there is only one element and it is a URL, write the URL to the | 223 // If there is only one element and it is a URL, write the URL to the |
224 // clipboard. | 224 // clipboard. |
225 if (elements.size() == 1 && elements[0].is_url) { | 225 if (elements.size() == 1 && elements[0].is_url) { |
226 if (elements[0].url.SchemeIs(chrome::kJavaScriptScheme)) { | 226 if (elements[0].url.SchemeIs(chrome::kJavaScriptScheme)) { |
227 data->SetString(UTF8ToWide(elements[0].url.spec())); | 227 data->SetString(UTF8ToWide(elements[0].url.spec())); |
228 } else { | 228 } else { |
229 data->SetURL(elements[0].url, UTF16ToWide(elements[0].title)); | 229 data->SetURL(elements[0].url, UTF16ToWide(elements[0].title)); |
230 } | 230 } |
231 } | 231 } |
232 | 232 |
233 Pickle data_pickle; | 233 Pickle data_pickle; |
234 WriteToPickle(profile, &data_pickle); | 234 WriteToPickle(profile, &data_pickle); |
235 | 235 |
236 data->SetPickledData(GetBookmarkCustomFormat(), data_pickle); | 236 data->SetPickledData(GetBookmarkCustomFormat(), data_pickle); |
237 } | 237 } |
238 | 238 |
239 bool BookmarkNodeData::Read(const OSExchangeData& data) { | 239 bool BookmarkNodeData::Read(const ui::OSExchangeData& data) { |
240 elements.clear(); | 240 elements.clear(); |
241 | 241 |
242 profile_path_.clear(); | 242 profile_path_.clear(); |
243 | 243 |
244 if (data.HasCustomFormat(GetBookmarkCustomFormat())) { | 244 if (data.HasCustomFormat(GetBookmarkCustomFormat())) { |
245 Pickle drag_data_pickle; | 245 Pickle drag_data_pickle; |
246 if (data.GetPickledData(GetBookmarkCustomFormat(), &drag_data_pickle)) { | 246 if (data.GetPickledData(GetBookmarkCustomFormat(), &drag_data_pickle)) { |
247 if (!ReadFromPickle(&drag_data_pickle)) | 247 if (!ReadFromPickle(&drag_data_pickle)) |
248 return false; | 248 return false; |
249 } | 249 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 DCHECK(profile_path_.empty()); | 321 DCHECK(profile_path_.empty()); |
322 | 322 |
323 if (profile) | 323 if (profile) |
324 profile_path_ = profile->GetPath().value(); | 324 profile_path_ = profile->GetPath().value(); |
325 } | 325 } |
326 | 326 |
327 bool BookmarkNodeData::IsFromProfile(Profile* profile) const { | 327 bool BookmarkNodeData::IsFromProfile(Profile* profile) const { |
328 // An empty path means the data is not associated with any profile. | 328 // An empty path means the data is not associated with any profile. |
329 return !profile_path_.empty() && profile_path_ == profile->GetPath().value(); | 329 return !profile_path_.empty() && profile_path_ == profile->GetPath().value(); |
330 } | 330 } |
OLD | NEW |