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

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

Issue 549224: Support reordering of Browser Actions within the container. Currently does no... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 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) 2009 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"
11 #include "chrome/browser/bookmarks/bookmark_model.h" 11 #include "chrome/browser/bookmarks/bookmark_model.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 element.is_url = true; 183 element.is_url = true;
184 elements.push_back(element); 184 elements.push_back(element);
185 } 185 }
186 } 186 }
187 187
188 return is_valid(); 188 return is_valid();
189 } 189 }
190 #endif 190 #endif
191 191
192 void BookmarkDragData::WriteToPickle(Profile* profile, Pickle* pickle) const { 192 void BookmarkDragData::WriteToPickle(Profile* profile, Pickle* pickle) const {
193 #if defined(WCHAR_T_IS_UTF16) 193 FilePath path = profile ? profile->GetPath() : FilePath();
194 pickle->WriteWString( 194 FilePath::WriteStringTypeToPickle(pickle, path.value());
195 profile ? profile->GetPath().ToWStringHack() : std::wstring());
196 #elif defined(WCHAR_T_IS_UTF32)
197 pickle->WriteString(
198 profile ? profile->GetPath().value() : std::string());
199 #else
200 NOTIMPLEMENTED() << "Impossible encoding situation!";
201 #endif
202
203 pickle->WriteSize(elements.size()); 195 pickle->WriteSize(elements.size());
204 196
205 for (size_t i = 0; i < elements.size(); ++i) 197 for (size_t i = 0; i < elements.size(); ++i)
206 elements[i].WriteToPickle(pickle); 198 elements[i].WriteToPickle(pickle);
207 } 199 }
208 200
209 bool BookmarkDragData::ReadFromPickle(Pickle* pickle) { 201 bool BookmarkDragData::ReadFromPickle(Pickle* pickle) {
210 void* data_iterator = NULL; 202 void* data_iterator = NULL;
211 size_t element_count; 203 size_t element_count;
212 #if defined(WCHAR_T_IS_UTF16) 204 if (FilePath::ReadStringTypeFromPickle(pickle, &data_iterator,
213 if (pickle->ReadWString(&data_iterator, &profile_path_) && 205 &profile_path_) &&
214 #elif defined(WCHAR_T_IS_UTF32)
215 if (pickle->ReadString(&data_iterator, &profile_path_) &&
216 #else
217 NOTIMPLEMENTED() << "Impossible encoding situation!";
218 if (false &&
219 #endif
220 pickle->ReadSize(&data_iterator, &element_count)) { 206 pickle->ReadSize(&data_iterator, &element_count)) {
221 std::vector<Element> tmp_elements; 207 std::vector<Element> tmp_elements;
222 tmp_elements.resize(element_count); 208 tmp_elements.resize(element_count);
223 for (size_t i = 0; i < element_count; ++i) { 209 for (size_t i = 0; i < element_count; ++i) {
224 if (!tmp_elements[i].ReadFromPickle(pickle, &data_iterator)) { 210 if (!tmp_elements[i].ReadFromPickle(pickle, &data_iterator)) {
225 return false; 211 return false;
226 } 212 }
227 } 213 }
228 elements.swap(tmp_elements); 214 elements.swap(tmp_elements);
229 } 215 }
(...skipping 27 matching lines...) Expand all
257 243
258 bool BookmarkDragData::IsFromProfile(Profile* profile) const { 244 bool BookmarkDragData::IsFromProfile(Profile* profile) const {
259 // An empty path means the data is not associated with any profile. 245 // An empty path means the data is not associated with any profile.
260 return (!profile_path_.empty() && 246 return (!profile_path_.empty() &&
261 #if defined(WCHAR_T_IS_UTF16) 247 #if defined(WCHAR_T_IS_UTF16)
262 profile->GetPath().ToWStringHack() == profile_path_); 248 profile->GetPath().ToWStringHack() == profile_path_);
263 #elif defined(WCHAR_T_IS_UTF32) 249 #elif defined(WCHAR_T_IS_UTF32)
264 profile->GetPath().value() == profile_path_); 250 profile->GetPath().value() == profile_path_);
265 #endif 251 #endif
266 } 252 }
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_drag_data.h ('k') | chrome/browser/extensions/extension_toolbar_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698