| 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_drag_data.h" | 5 #include "chrome/browser/bookmarks/bookmark_drag_data.h" |
| 6 | 6 |
| 7 #include "app/clipboard/scoped_clipboard_writer.h" | 7 #include "app/clipboard/scoped_clipboard_writer.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 #endif // !defined(OS_MACOSX) | 201 #endif // !defined(OS_MACOSX) |
| 202 | 202 |
| 203 #if defined(TOOLKIT_VIEWS) | 203 #if defined(TOOLKIT_VIEWS) |
| 204 void BookmarkDragData::Write(Profile* profile, OSExchangeData* data) const { | 204 void BookmarkDragData::Write(Profile* profile, OSExchangeData* data) const { |
| 205 DCHECK(data); | 205 DCHECK(data); |
| 206 | 206 |
| 207 // If there is only one element and it is a URL, write the URL to the | 207 // If there is only one element and it is a URL, write the URL to the |
| 208 // clipboard. | 208 // clipboard. |
| 209 if (elements.size() == 1 && elements[0].is_url) { | 209 if (elements.size() == 1 && elements[0].is_url) { |
| 210 if (elements[0].url.SchemeIs(chrome::kJavaScriptScheme)) { | 210 if (elements[0].url.SchemeIs(chrome::kJavaScriptScheme)) { |
| 211 data->SetString(ASCIIToWide(elements[0].url.spec())); | 211 data->SetString(UTF8ToWide(elements[0].url.spec())); |
| 212 } else { | 212 } else { |
| 213 data->SetURL(elements[0].url, UTF16ToWide(elements[0].title)); | 213 data->SetURL(elements[0].url, UTF16ToWide(elements[0].title)); |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 | 216 |
| 217 Pickle data_pickle; | 217 Pickle data_pickle; |
| 218 WriteToPickle(profile, &data_pickle); | 218 WriteToPickle(profile, &data_pickle); |
| 219 | 219 |
| 220 data->SetPickledData(GetBookmarkCustomFormat(), data_pickle); | 220 data->SetPickledData(GetBookmarkCustomFormat(), data_pickle); |
| 221 } | 221 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 DCHECK(profile_path_.empty()); | 305 DCHECK(profile_path_.empty()); |
| 306 | 306 |
| 307 if (profile) | 307 if (profile) |
| 308 profile_path_ = profile->GetPath().value(); | 308 profile_path_ = profile->GetPath().value(); |
| 309 } | 309 } |
| 310 | 310 |
| 311 bool BookmarkDragData::IsFromProfile(Profile* profile) const { | 311 bool BookmarkDragData::IsFromProfile(Profile* profile) const { |
| 312 // An empty path means the data is not associated with any profile. | 312 // An empty path means the data is not associated with any profile. |
| 313 return !profile_path_.empty() && profile_path_ == profile->GetPath().value(); | 313 return !profile_path_.empty() && profile_path_ == profile->GetPath().value(); |
| 314 } | 314 } |
| OLD | NEW |