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

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

Issue 1912: Renames BoomarkBarModel to BookmarkModel. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/pickle.h" 7 #include "base/pickle.h"
8 #include "chrome/browser/bookmarks/bookmark_bar_model.h" 8 #include "chrome/browser/bookmarks/bookmark_model.h"
9 #include "chrome/common/os_exchange_data.h" 9 #include "chrome/common/os_exchange_data.h"
10 10
11 static CLIPFORMAT clipboard_format = 0; 11 static CLIPFORMAT clipboard_format = 0;
12 12
13 static void RegisterFormat() { 13 static void RegisterFormat() {
14 if (clipboard_format == 0) { 14 if (clipboard_format == 0) {
15 clipboard_format = RegisterClipboardFormat(L"chrome/x-bookmark-entry"); 15 clipboard_format = RegisterClipboardFormat(L"chrome/x-bookmark-entry");
16 DCHECK(clipboard_format); 16 DCHECK(clipboard_format);
17 } 17 }
18 } 18 }
19 19
20 BookmarkDragData::BookmarkDragData() : is_url(false), is_valid(false) { 20 BookmarkDragData::BookmarkDragData() : is_url(false), is_valid(false) {
21 } 21 }
22 22
23 BookmarkDragData::BookmarkDragData(BookmarkBarNode* node) 23 BookmarkDragData::BookmarkDragData(BookmarkNode* node)
24 : is_url(node->GetType() == history::StarredEntry::URL), 24 : is_url(node->GetType() == history::StarredEntry::URL),
25 url(node->GetURL()), 25 url(node->GetURL()),
26 title(node->GetTitle()), 26 title(node->GetTitle()),
27 is_valid(true), 27 is_valid(true),
28 id_(node->id()) { 28 id_(node->id()) {
29 if (!is_url) 29 if (!is_url)
30 AddChildren(node); 30 AddChildren(node);
31 } 31 }
32 32
33 void BookmarkDragData::Write(OSExchangeData* data) const { 33 void BookmarkDragData::Write(OSExchangeData* data) const {
(...skipping 21 matching lines...) Expand all
55 if (data.GetPickledData(clipboard_format, &drag_data_pickle)) { 55 if (data.GetPickledData(clipboard_format, &drag_data_pickle)) {
56 void* data_iterator = NULL; 56 void* data_iterator = NULL;
57 if (ReadFromPickle(&drag_data_pickle, &data_iterator)) { 57 if (ReadFromPickle(&drag_data_pickle, &data_iterator)) {
58 is_valid = true; 58 is_valid = true;
59 } 59 }
60 } 60 }
61 } 61 }
62 return is_valid; 62 return is_valid;
63 } 63 }
64 64
65 BookmarkBarNode* BookmarkDragData::GetNode(BookmarkBarModel* model) const { 65 BookmarkNode* BookmarkDragData::GetNode(BookmarkModel* model) const {
66 DCHECK(!is_url && id_ && is_valid); 66 DCHECK(!is_url && id_ && is_valid);
67 return model->GetNodeByID(id_); 67 return model->GetNodeByID(id_);
68 } 68 }
69 69
70 void BookmarkDragData::WriteToPickle(Pickle* pickle) const { 70 void BookmarkDragData::WriteToPickle(Pickle* pickle) const {
71 pickle->WriteBool(is_url); 71 pickle->WriteBool(is_url);
72 pickle->WriteWString(profile_id); 72 pickle->WriteWString(profile_id);
73 pickle->WriteString(url.spec()); 73 pickle->WriteString(url.spec());
74 pickle->WriteWString(title); 74 pickle->WriteWString(title);
75 if (!is_url) { 75 if (!is_url) {
(...skipping 28 matching lines...) Expand all
104 for (std::vector<BookmarkDragData>::iterator i = children.begin(); 104 for (std::vector<BookmarkDragData>::iterator i = children.begin();
105 i != children.end(); ++i) { 105 i != children.end(); ++i) {
106 if (!i->ReadFromPickle(pickle, iterator)) 106 if (!i->ReadFromPickle(pickle, iterator))
107 return false; 107 return false;
108 } 108 }
109 } 109 }
110 is_valid = true; 110 is_valid = true;
111 return true; 111 return true;
112 } 112 }
113 113
114 void BookmarkDragData::AddChildren(BookmarkBarNode* node) { 114 void BookmarkDragData::AddChildren(BookmarkNode* node) {
115 for (int i = 0, max = node->GetChildCount(); i < max; ++i) 115 for (int i = 0, max = node->GetChildCount(); i < max; ++i)
116 children.push_back(BookmarkDragData(node->GetChild(i))); 116 children.push_back(BookmarkDragData(node->GetChild(i)));
117 } 117 }
118 118
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698