| 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 #include "components/bookmarks/browser/bookmark_node_data.h" | 5 #include "components/bookmarks/browser/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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 // Don't call scw.WriteHyperlink() here, since some rich text editors will | 170 // Don't call scw.WriteHyperlink() here, since some rich text editors will |
| 171 // change fonts when such data is pasted in; besides, most such editors | 171 // change fonts when such data is pasted in; besides, most such editors |
| 172 // auto-linkify at some point anyway. | 172 // auto-linkify at some point anyway. |
| 173 | 173 |
| 174 // Also write the URL to the clipboard as text so that it can be pasted | 174 // Also write the URL to the clipboard as text so that it can be pasted |
| 175 // into text fields. We use WriteText instead of WriteURL because we don't | 175 // into text fields. We use WriteText instead of WriteURL because we don't |
| 176 // want to clobber the X clipboard when the user copies out of the omnibox | 176 // want to clobber the X clipboard when the user copies out of the omnibox |
| 177 // on Linux (on Windows and Mac, there is no difference between these | 177 // on Linux (on Windows and Mac, there is no difference between these |
| 178 // functions). | 178 // functions). |
| 179 scw.WriteText(base::UTF8ToUTF16(url)); | 179 scw.WriteText(base::UTF8ToUTF16(url)); |
| 180 } else { |
| 181 // We have either more than one URL, a folder, or a combination of URLs |
| 182 // and folders. |
| 183 base::string16 text; |
| 184 for (size_t i = 0; i < elements.size(); i++) { |
| 185 text += i == 0 ? base::ASCIIToUTF16("") : base::ASCIIToUTF16("\n"); |
| 186 if (!elements[i].is_url) { |
| 187 // Then it's a folder. Only copy the name of the folder. |
| 188 const base::string16 title = elements[i].title; |
| 189 text += title; |
| 190 } else { |
| 191 const base::string16 url = base::UTF8ToUTF16(elements[i].url.spec()); |
| 192 text += url; |
| 193 } |
| 194 } |
| 195 scw.WriteText(text); |
| 180 } | 196 } |
| 181 | 197 |
| 182 Pickle pickle; | 198 Pickle pickle; |
| 183 WriteToPickle(base::FilePath(), &pickle); | 199 WriteToPickle(base::FilePath(), &pickle); |
| 184 scw.WritePickledData(pickle, | 200 scw.WritePickledData(pickle, |
| 185 ui::Clipboard::GetFormatType(kClipboardFormatString)); | 201 ui::Clipboard::GetFormatType(kClipboardFormatString)); |
| 186 } | 202 } |
| 187 | 203 |
| 188 bool BookmarkNodeData::ReadFromClipboard(ui::ClipboardType type) { | 204 bool BookmarkNodeData::ReadFromClipboard(ui::ClipboardType type) { |
| 189 DCHECK_EQ(type, ui::CLIPBOARD_TYPE_COPY_PASTE); | 205 DCHECK_EQ(type, ui::CLIPBOARD_TYPE_COPY_PASTE); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 profile_path_ = profile_path; | 296 profile_path_ = profile_path; |
| 281 } | 297 } |
| 282 | 298 |
| 283 bool BookmarkNodeData::IsFromProfilePath( | 299 bool BookmarkNodeData::IsFromProfilePath( |
| 284 const base::FilePath& profile_path) const { | 300 const base::FilePath& profile_path) const { |
| 285 // An empty path means the data is not associated with any profile. | 301 // An empty path means the data is not associated with any profile. |
| 286 return !profile_path_.empty() && profile_path_ == profile_path; | 302 return !profile_path_.empty() && profile_path_ == profile_path; |
| 287 } | 303 } |
| 288 | 304 |
| 289 } // namespace bookmarks | 305 } // namespace bookmarks |
| OLD | NEW |