Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: components/bookmarks/browser/bookmark_node_data.cc

Issue 634523004: Allow copying of multiple bookmarks from within the bookmark manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unused variable warning Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « AUTHORS ('k') | components/bookmarks/browser/bookmark_node_data_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « AUTHORS ('k') | components/bookmarks/browser/bookmark_node_data_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698