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

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

Issue 1029004: GTK: implement extension bookmark manager drag api.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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 | Annotate | Revision Log
OLDNEW
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 return format; 82 return format;
83 } 83 }
84 #endif 84 #endif
85 85
86 BookmarkDragData::BookmarkDragData(const BookmarkNode* node) { 86 BookmarkDragData::BookmarkDragData(const BookmarkNode* node) {
87 elements.push_back(Element(node)); 87 elements.push_back(Element(node));
88 } 88 }
89 89
90 BookmarkDragData::BookmarkDragData( 90 BookmarkDragData::BookmarkDragData(
91 const std::vector<const BookmarkNode*>& nodes) { 91 const std::vector<const BookmarkNode*>& nodes) {
92 ReadFromVector(nodes);
93 }
94
95 bool BookmarkDragData::ReadFromVector(
96 const std::vector<const BookmarkNode*>& nodes) {
97 Clear();
98
99 if (nodes.empty())
100 return false;
101
92 for (size_t i = 0; i < nodes.size(); ++i) 102 for (size_t i = 0; i < nodes.size(); ++i)
93 elements.push_back(Element(nodes[i])); 103 elements.push_back(Element(nodes[i]));
104
105 return true;
94 } 106 }
95 107
96 #if !defined(OS_MACOSX) 108 #if !defined(OS_MACOSX)
97 void BookmarkDragData::WriteToClipboard(Profile* profile) const { 109 void BookmarkDragData::WriteToClipboard(Profile* profile) const {
98 ScopedClipboardWriter scw(g_browser_process->clipboard()); 110 ScopedClipboardWriter scw(g_browser_process->clipboard());
99 111
100 // If there is only one element and it is a URL, write the URL to the 112 // If there is only one element and it is a URL, write the URL to the
101 // clipboard. 113 // clipboard.
102 if (elements.size() == 1 && elements[0].is_url) { 114 if (elements.size() == 1 && elements[0].is_url) {
103 const string16& title = elements[0].title; 115 const string16& title = elements[0].title;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 const BookmarkNode* BookmarkDragData::GetFirstNode(Profile* profile) const { 277 const BookmarkNode* BookmarkDragData::GetFirstNode(Profile* profile) const {
266 std::vector<const BookmarkNode*> nodes = GetNodes(profile); 278 std::vector<const BookmarkNode*> nodes = GetNodes(profile);
267 return nodes.size() == 1 ? nodes[0] : NULL; 279 return nodes.size() == 1 ? nodes[0] : NULL;
268 } 280 }
269 281
270 void BookmarkDragData::Clear() { 282 void BookmarkDragData::Clear() {
271 profile_path_.clear(); 283 profile_path_.clear();
272 elements.clear(); 284 elements.clear();
273 } 285 }
274 286
287 void BookmarkDragData::SetOriginatingProfile(Profile* profile) {
288 DCHECK(profile_path_.empty());
289
290 if (profile)
291 profile_path_ = profile->GetPath().value();
292 }
293
275 bool BookmarkDragData::IsFromProfile(Profile* profile) const { 294 bool BookmarkDragData::IsFromProfile(Profile* profile) const {
276 // An empty path means the data is not associated with any profile. 295 // An empty path means the data is not associated with any profile.
277 return (!profile_path_.empty() && 296 return !profile_path_.empty() && profile_path_ == profile->GetPath().value();
278 #if defined(WCHAR_T_IS_UTF16)
279 profile->GetPath().ToWStringHack() == profile_path_);
280 #elif defined(WCHAR_T_IS_UTF32)
281 profile->GetPath().value() == profile_path_);
282 #endif
283 } 297 }
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_drag_data.h ('k') | chrome/browser/bookmarks/bookmark_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698