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

Side by Side Diff: chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc

Issue 870293002: bookmarks: BookmarkNodeData's size() cleanups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: size() Created 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/api/bookmark_manager_private/bookmark_manage r_private_api.h" 5 #include "chrome/browser/extensions/api/bookmark_manager_private/bookmark_manage r_private_api.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 if (node_data->same_profile) { 156 if (node_data->same_profile) {
157 std::vector<const BookmarkNode*> nodes = data.GetNodes( 157 std::vector<const BookmarkNode*> nodes = data.GetNodes(
158 BookmarkModelFactory::GetForProfile(profile), profile_path); 158 BookmarkModelFactory::GetForProfile(profile), profile_path);
159 for (size_t i = 0; i < nodes.size(); ++i) { 159 for (size_t i = 0; i < nodes.size(); ++i) {
160 node_data->elements.push_back( 160 node_data->elements.push_back(
161 CreateNodeDataElementFromBookmarkNode(*nodes[i])); 161 CreateNodeDataElementFromBookmarkNode(*nodes[i]));
162 } 162 }
163 } else { 163 } else {
164 // We do not have a node IDs when the data comes from a different profile. 164 // We do not have a node IDs when the data comes from a different profile.
165 std::vector<BookmarkNodeData::Element> elements = data.elements; 165 for (size_t i = 0; i < data.size(); ++i)
166 for (size_t i = 0; i < elements.size(); ++i) 166 node_data->elements.push_back(CreateApiNodeDataElement(data.elements[i]));
167 node_data->elements.push_back(CreateApiNodeDataElement(elements[i]));
168 } 167 }
169 return node_data.Pass(); 168 return node_data.Pass();
170 } 169 }
171 170
172 } // namespace 171 } // namespace
173 172
174 BookmarkManagerPrivateEventRouter::BookmarkManagerPrivateEventRouter( 173 BookmarkManagerPrivateEventRouter::BookmarkManagerPrivateEventRouter(
175 content::BrowserContext* browser_context, 174 content::BrowserContext* browser_context,
176 BookmarkModel* bookmark_model) 175 BookmarkModel* bookmark_model)
177 : browser_context_(browser_context), bookmark_model_(bookmark_model) { 176 : browser_context_(browser_context), bookmark_model_(bookmark_model) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 EventRouter* event_router = EventRouter::Get(profile_); 301 EventRouter* event_router = EventRouter::Get(profile_);
303 if (!event_router) 302 if (!event_router)
304 return; 303 return;
305 304
306 scoped_ptr<Event> event(new Event(event_name, args.Pass())); 305 scoped_ptr<Event> event(new Event(event_name, args.Pass()));
307 event_router->BroadcastEvent(event.Pass()); 306 event_router->BroadcastEvent(event.Pass());
308 } 307 }
309 308
310 void BookmarkManagerPrivateDragEventRouter::OnDragEnter( 309 void BookmarkManagerPrivateDragEventRouter::OnDragEnter(
311 const BookmarkNodeData& data) { 310 const BookmarkNodeData& data) {
312 if (data.size() == 0) 311 if (!data.is_valid())
313 return; 312 return;
314 DispatchEvent(bookmark_manager_private::OnDragEnter::kEventName, 313 DispatchEvent(bookmark_manager_private::OnDragEnter::kEventName,
315 bookmark_manager_private::OnDragEnter::Create( 314 bookmark_manager_private::OnDragEnter::Create(
316 *CreateApiBookmarkNodeData(profile_, data))); 315 *CreateApiBookmarkNodeData(profile_, data)));
317 } 316 }
318 317
319 void BookmarkManagerPrivateDragEventRouter::OnDragOver( 318 void BookmarkManagerPrivateDragEventRouter::OnDragOver(
320 const BookmarkNodeData& data) { 319 const BookmarkNodeData& data) {
321 // Intentionally empty since these events happens too often and floods the 320 // Intentionally empty since these events happens too often and floods the
322 // message queue. We do not need this event for the bookmark manager anyway. 321 // message queue. We do not need this event for the bookmark manager anyway.
323 } 322 }
324 323
325 void BookmarkManagerPrivateDragEventRouter::OnDragLeave( 324 void BookmarkManagerPrivateDragEventRouter::OnDragLeave(
326 const BookmarkNodeData& data) { 325 const BookmarkNodeData& data) {
327 if (data.size() == 0) 326 if (!data.is_valid())
328 return; 327 return;
329 DispatchEvent(bookmark_manager_private::OnDragLeave::kEventName, 328 DispatchEvent(bookmark_manager_private::OnDragLeave::kEventName,
330 bookmark_manager_private::OnDragLeave::Create( 329 bookmark_manager_private::OnDragLeave::Create(
331 *CreateApiBookmarkNodeData(profile_, data))); 330 *CreateApiBookmarkNodeData(profile_, data)));
332 } 331 }
333 332
334 void BookmarkManagerPrivateDragEventRouter::OnDrop( 333 void BookmarkManagerPrivateDragEventRouter::OnDrop(
335 const BookmarkNodeData& data) { 334 const BookmarkNodeData& data) {
336 if (data.size() == 0) 335 if (!data.is_valid())
337 return; 336 return;
338 DispatchEvent(bookmark_manager_private::OnDrop::kEventName, 337 DispatchEvent(bookmark_manager_private::OnDrop::kEventName,
339 bookmark_manager_private::OnDrop::Create( 338 bookmark_manager_private::OnDrop::Create(
340 *CreateApiBookmarkNodeData(profile_, data))); 339 *CreateApiBookmarkNodeData(profile_, data)));
341 340
342 // Make a copy that is owned by this instance. 341 // Make a copy that is owned by this instance.
343 ClearBookmarkNodeData(); 342 ClearBookmarkNodeData();
344 bookmark_drag_data_ = data; 343 bookmark_drag_data_ = data;
345 } 344 }
346 345
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 833
835 enhanced_bookmarks::EnhancedBookmarkModel* model = 834 enhanced_bookmarks::EnhancedBookmarkModel* model =
836 enhanced_bookmarks::EnhancedBookmarkModelFactory::GetForBrowserContext( 835 enhanced_bookmarks::EnhancedBookmarkModelFactory::GetForBrowserContext(
837 browser_context()); 836 browser_context());
838 model->SetVersionSuffix(params->version); 837 model->SetVersionSuffix(params->version);
839 838
840 return true; 839 return true;
841 } 840 }
842 841
843 } // namespace extensions 842 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698