| OLD | NEW |
| 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_model.h" | 8 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 9 #include "chrome/browser/profile.h" | 9 #include "chrome/browser/profile.h" |
| 10 #include "chrome/common/os_exchange_data.h" | 10 #include "chrome/common/os_exchange_data.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 element.is_url = true; | 128 element.is_url = true; |
| 129 elements.push_back(element); | 129 elements.push_back(element); |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 return is_valid(); | 132 return is_valid(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 std::vector<BookmarkNode*> BookmarkDragData::GetNodes(Profile* profile) const { | 135 std::vector<BookmarkNode*> BookmarkDragData::GetNodes(Profile* profile) const { |
| 136 std::vector<BookmarkNode*> nodes; | 136 std::vector<BookmarkNode*> nodes; |
| 137 | 137 |
| 138 if (profile->GetPath() != profile_path_) | 138 if (!IsFromProfile(profile)) |
| 139 return nodes; | 139 return nodes; |
| 140 | 140 |
| 141 for (size_t i = 0; i < elements.size(); ++i) { | 141 for (size_t i = 0; i < elements.size(); ++i) { |
| 142 BookmarkNode* node = | 142 BookmarkNode* node = |
| 143 profile->GetBookmarkModel()->GetNodeByID(elements[i].id_); | 143 profile->GetBookmarkModel()->GetNodeByID(elements[i].id_); |
| 144 if (!node) { | 144 if (!node) { |
| 145 nodes.clear(); | 145 nodes.clear(); |
| 146 return nodes; | 146 return nodes; |
| 147 } | 147 } |
| 148 nodes.push_back(node); | 148 nodes.push_back(node); |
| 149 } | 149 } |
| 150 return nodes; | 150 return nodes; |
| 151 } | 151 } |
| 152 | 152 |
| 153 BookmarkNode* BookmarkDragData::GetFirstNode(Profile* profile) const { | 153 BookmarkNode* BookmarkDragData::GetFirstNode(Profile* profile) const { |
| 154 std::vector<BookmarkNode*> nodes = GetNodes(profile); | 154 std::vector<BookmarkNode*> nodes = GetNodes(profile); |
| 155 return nodes.size() == 1 ? nodes[0] : NULL; | 155 return nodes.size() == 1 ? nodes[0] : NULL; |
| 156 } | 156 } |
| 157 |
| 158 bool BookmarkDragData::IsFromProfile(Profile* profile) const { |
| 159 return (profile->GetPath() == profile_path_); |
| 160 } |
| OLD | NEW |