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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 } | 180 } |
181 | 181 |
sky
2014/10/07 21:58:57
See style guide for handling of else. Basically yo
hichris123
2014/10/08 01:04:28
Done.
| |
182 // We have more than one element | |
sky
2014/10/07 21:58:57
This comment isn't quite right.
hichris123
2014/10/08 01:04:28
Done.
| |
183 else { | |
184 bool all_urls = true; | |
sky
2014/10/07 21:58:57
What's the rationale for this logic? Why ignore fo
hichris123
2014/10/07 22:35:55
I just tried not including folders, and it wouldn'
hichris123
2014/10/08 01:04:29
Done.
| |
185 for (Element& element : elements) { | |
186 if (!element.is_url) { | |
187 all_urls = false; | |
188 break; | |
189 } | |
190 } | |
191 | |
192 if (all_urls == true) { | |
sky
2014/10/07 21:58:57
No == true here, just if (all_urls)
hichris123
2014/10/08 01:04:28
Done.
| |
193 std::string text; | |
194 for (size_t i = 0; i < elements.size(); i++) { | |
195 const std::string url = elements[i].url.spec(); | |
196 text += i == 0 ? url : "\n" + url; | |
197 } | |
198 scw.WriteText(base::UTF8ToUTF16(text)); | |
199 } | |
200 } | |
201 | |
182 Pickle pickle; | 202 Pickle pickle; |
183 WriteToPickle(base::FilePath(), &pickle); | 203 WriteToPickle(base::FilePath(), &pickle); |
184 scw.WritePickledData(pickle, | 204 scw.WritePickledData(pickle, |
185 ui::Clipboard::GetFormatType(kClipboardFormatString)); | 205 ui::Clipboard::GetFormatType(kClipboardFormatString)); |
186 } | 206 } |
187 | 207 |
188 bool BookmarkNodeData::ReadFromClipboard(ui::ClipboardType type) { | 208 bool BookmarkNodeData::ReadFromClipboard(ui::ClipboardType type) { |
189 DCHECK_EQ(type, ui::CLIPBOARD_TYPE_COPY_PASTE); | 209 DCHECK_EQ(type, ui::CLIPBOARD_TYPE_COPY_PASTE); |
190 std::string data; | 210 std::string data; |
191 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); | 211 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
280 profile_path_ = profile_path; | 300 profile_path_ = profile_path; |
281 } | 301 } |
282 | 302 |
283 bool BookmarkNodeData::IsFromProfilePath( | 303 bool BookmarkNodeData::IsFromProfilePath( |
284 const base::FilePath& profile_path) const { | 304 const base::FilePath& profile_path) const { |
285 // An empty path means the data is not associated with any profile. | 305 // An empty path means the data is not associated with any profile. |
286 return !profile_path_.empty() && profile_path_ == profile_path; | 306 return !profile_path_.empty() && profile_path_ == profile_path; |
287 } | 307 } |
288 | 308 |
289 } // namespace bookmarks | 309 } // namespace bookmarks |
OLD | NEW |