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

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

Issue 8801038: Make Clipboard::FormatType an opaque handle type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/common/clipboard_messages.h » ('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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // Also write the URL to the clipboard as text so that it can be pasted 154 // Also write the URL to the clipboard as text so that it can be pasted
155 // into text fields. We use WriteText instead of WriteURL because we don't 155 // into text fields. We use WriteText instead of WriteURL because we don't
156 // want to clobber the X clipboard when the user copies out of the omnibox 156 // want to clobber the X clipboard when the user copies out of the omnibox
157 // on Linux (on Windows and Mac, there is no difference between these 157 // on Linux (on Windows and Mac, there is no difference between these
158 // functions). 158 // functions).
159 scw.WriteText(UTF8ToUTF16(url)); 159 scw.WriteText(UTF8ToUTF16(url));
160 } 160 }
161 161
162 Pickle pickle; 162 Pickle pickle;
163 WriteToPickle(profile, &pickle); 163 WriteToPickle(profile, &pickle);
164 scw.WritePickledData(pickle, kClipboardFormatString); 164 scw.WritePickledData(
165 pickle, ui::Clipboard::GetFormatType(kClipboardFormatString));
165 } 166 }
166 167
167 bool BookmarkNodeData::ReadFromClipboard() { 168 bool BookmarkNodeData::ReadFromClipboard() {
168 std::string data; 169 std::string data;
169 ui::Clipboard* clipboard = g_browser_process->clipboard(); 170 ui::Clipboard* clipboard = g_browser_process->clipboard();
170 clipboard->ReadData(kClipboardFormatString, &data); 171 clipboard->ReadData(ui::Clipboard::GetFormatType(kClipboardFormatString),
172 &data);
171 173
172 if (!data.empty()) { 174 if (!data.empty()) {
173 Pickle pickle(data.data(), data.size()); 175 Pickle pickle(data.data(), data.size());
174 if (ReadFromPickle(&pickle)) 176 if (ReadFromPickle(&pickle))
175 return true; 177 return true;
176 } 178 }
177 179
178 string16 title; 180 string16 title;
179 std::string url; 181 std::string url;
180 clipboard->ReadBookmark(&title, &url); 182 clipboard->ReadBookmark(&title, &url);
181 if (!url.empty()) { 183 if (!url.empty()) {
182 Element element; 184 Element element;
183 element.is_url = true; 185 element.is_url = true;
184 element.url = GURL(url); 186 element.url = GURL(url);
185 element.title = title; 187 element.title = title;
186 188
187 elements.clear(); 189 elements.clear();
188 elements.push_back(element); 190 elements.push_back(element);
189 return true; 191 return true;
190 } 192 }
191 193
192 return false; 194 return false;
193 } 195 }
194 196
195 bool BookmarkNodeData::ClipboardContainsBookmarks() { 197 bool BookmarkNodeData::ClipboardContainsBookmarks() {
196 return g_browser_process->clipboard()->IsFormatAvailableByString( 198 return g_browser_process->clipboard()->IsFormatAvailable(
197 BookmarkNodeData::kClipboardFormatString, ui::Clipboard::BUFFER_STANDARD); 199 ui::Clipboard::GetFormatType(kClipboardFormatString),
200 ui::Clipboard::BUFFER_STANDARD);
198 } 201 }
199 #else 202 #else
200 void BookmarkNodeData::WriteToClipboard(Profile* profile) const { 203 void BookmarkNodeData::WriteToClipboard(Profile* profile) const {
201 bookmark_pasteboard_helper_mac::WriteToPasteboard( 204 bookmark_pasteboard_helper_mac::WriteToPasteboard(
202 bookmark_pasteboard_helper_mac::kCopyPastePasteboard, 205 bookmark_pasteboard_helper_mac::kCopyPastePasteboard,
203 elements, 206 elements,
204 profile_path_.value()); 207 profile_path_.value());
205 } 208 }
206 209
207 bool BookmarkNodeData::ReadFromClipboard() { 210 bool BookmarkNodeData::ReadFromClipboard() {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 DCHECK(profile_path_.empty()); 343 DCHECK(profile_path_.empty());
341 344
342 if (profile) 345 if (profile)
343 profile_path_ = profile->GetPath(); 346 profile_path_ = profile->GetPath();
344 } 347 }
345 348
346 bool BookmarkNodeData::IsFromProfile(Profile* profile) const { 349 bool BookmarkNodeData::IsFromProfile(Profile* profile) const {
347 // An empty path means the data is not associated with any profile. 350 // An empty path means the data is not associated with any profile.
348 return !profile_path_.empty() && profile_path_ == profile->GetPath(); 351 return !profile_path_.empty() && profile_path_ == profile->GetPath();
349 } 352 }
OLDNEW
« no previous file with comments | « no previous file | content/common/clipboard_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698