| OLD | NEW |
| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 if (node_data->same_profile) { | 157 if (node_data->same_profile) { |
| 158 std::vector<const BookmarkNode*> nodes = data.GetNodes( | 158 std::vector<const BookmarkNode*> nodes = data.GetNodes( |
| 159 BookmarkModelFactory::GetForProfile(profile), profile_path); | 159 BookmarkModelFactory::GetForProfile(profile), profile_path); |
| 160 for (size_t i = 0; i < nodes.size(); ++i) { | 160 for (size_t i = 0; i < nodes.size(); ++i) { |
| 161 node_data->elements.push_back( | 161 node_data->elements.push_back( |
| 162 CreateNodeDataElementFromBookmarkNode(*nodes[i])); | 162 CreateNodeDataElementFromBookmarkNode(*nodes[i])); |
| 163 } | 163 } |
| 164 } else { | 164 } else { |
| 165 // We do not have a node IDs when the data comes from a different profile. | 165 // We do not have a node IDs when the data comes from a different profile. |
| 166 std::vector<BookmarkNodeData::Element> elements = data.elements; | 166 for (size_t i = 0; i < data.size(); ++i) |
| 167 for (size_t i = 0; i < elements.size(); ++i) | 167 node_data->elements.push_back(CreateApiNodeDataElement(data.elements[i])); |
| 168 node_data->elements.push_back(CreateApiNodeDataElement(elements[i])); | |
| 169 } | 168 } |
| 170 return node_data.Pass(); | 169 return node_data.Pass(); |
| 171 } | 170 } |
| 172 | 171 |
| 173 } // namespace | 172 } // namespace |
| 174 | 173 |
| 175 BookmarkManagerPrivateEventRouter::BookmarkManagerPrivateEventRouter( | 174 BookmarkManagerPrivateEventRouter::BookmarkManagerPrivateEventRouter( |
| 176 content::BrowserContext* browser_context, | 175 content::BrowserContext* browser_context, |
| 177 BookmarkModel* bookmark_model) | 176 BookmarkModel* bookmark_model) |
| 178 : browser_context_(browser_context), bookmark_model_(bookmark_model) { | 177 : browser_context_(browser_context), bookmark_model_(bookmark_model) { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 EventRouter* event_router = EventRouter::Get(profile_); | 302 EventRouter* event_router = EventRouter::Get(profile_); |
| 304 if (!event_router) | 303 if (!event_router) |
| 305 return; | 304 return; |
| 306 | 305 |
| 307 scoped_ptr<Event> event(new Event(event_name, args.Pass())); | 306 scoped_ptr<Event> event(new Event(event_name, args.Pass())); |
| 308 event_router->BroadcastEvent(event.Pass()); | 307 event_router->BroadcastEvent(event.Pass()); |
| 309 } | 308 } |
| 310 | 309 |
| 311 void BookmarkManagerPrivateDragEventRouter::OnDragEnter( | 310 void BookmarkManagerPrivateDragEventRouter::OnDragEnter( |
| 312 const BookmarkNodeData& data) { | 311 const BookmarkNodeData& data) { |
| 313 if (data.size() == 0) | 312 if (!data.is_valid()) |
| 314 return; | 313 return; |
| 315 DispatchEvent(bookmark_manager_private::OnDragEnter::kEventName, | 314 DispatchEvent(bookmark_manager_private::OnDragEnter::kEventName, |
| 316 bookmark_manager_private::OnDragEnter::Create( | 315 bookmark_manager_private::OnDragEnter::Create( |
| 317 *CreateApiBookmarkNodeData(profile_, data))); | 316 *CreateApiBookmarkNodeData(profile_, data))); |
| 318 } | 317 } |
| 319 | 318 |
| 320 void BookmarkManagerPrivateDragEventRouter::OnDragOver( | 319 void BookmarkManagerPrivateDragEventRouter::OnDragOver( |
| 321 const BookmarkNodeData& data) { | 320 const BookmarkNodeData& data) { |
| 322 // Intentionally empty since these events happens too often and floods the | 321 // Intentionally empty since these events happens too often and floods the |
| 323 // message queue. We do not need this event for the bookmark manager anyway. | 322 // message queue. We do not need this event for the bookmark manager anyway. |
| 324 } | 323 } |
| 325 | 324 |
| 326 void BookmarkManagerPrivateDragEventRouter::OnDragLeave( | 325 void BookmarkManagerPrivateDragEventRouter::OnDragLeave( |
| 327 const BookmarkNodeData& data) { | 326 const BookmarkNodeData& data) { |
| 328 if (data.size() == 0) | 327 if (!data.is_valid()) |
| 329 return; | 328 return; |
| 330 DispatchEvent(bookmark_manager_private::OnDragLeave::kEventName, | 329 DispatchEvent(bookmark_manager_private::OnDragLeave::kEventName, |
| 331 bookmark_manager_private::OnDragLeave::Create( | 330 bookmark_manager_private::OnDragLeave::Create( |
| 332 *CreateApiBookmarkNodeData(profile_, data))); | 331 *CreateApiBookmarkNodeData(profile_, data))); |
| 333 } | 332 } |
| 334 | 333 |
| 335 void BookmarkManagerPrivateDragEventRouter::OnDrop( | 334 void BookmarkManagerPrivateDragEventRouter::OnDrop( |
| 336 const BookmarkNodeData& data) { | 335 const BookmarkNodeData& data) { |
| 337 if (data.size() == 0) | 336 if (!data.is_valid()) |
| 338 return; | 337 return; |
| 339 DispatchEvent(bookmark_manager_private::OnDrop::kEventName, | 338 DispatchEvent(bookmark_manager_private::OnDrop::kEventName, |
| 340 bookmark_manager_private::OnDrop::Create( | 339 bookmark_manager_private::OnDrop::Create( |
| 341 *CreateApiBookmarkNodeData(profile_, data))); | 340 *CreateApiBookmarkNodeData(profile_, data))); |
| 342 | 341 |
| 343 // Make a copy that is owned by this instance. | 342 // Make a copy that is owned by this instance. |
| 344 ClearBookmarkNodeData(); | 343 ClearBookmarkNodeData(); |
| 345 bookmark_drag_data_ = data; | 344 bookmark_drag_data_ = data; |
| 346 } | 345 } |
| 347 | 346 |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 | 835 |
| 837 enhanced_bookmarks::EnhancedBookmarkModel* model = | 836 enhanced_bookmarks::EnhancedBookmarkModel* model = |
| 838 enhanced_bookmarks::EnhancedBookmarkModelFactory::GetForBrowserContext( | 837 enhanced_bookmarks::EnhancedBookmarkModelFactory::GetForBrowserContext( |
| 839 browser_context()); | 838 browser_context()); |
| 840 model->SetVersionSuffix(params->version); | 839 model->SetVersionSuffix(params->version); |
| 841 | 840 |
| 842 return true; | 841 return true; |
| 843 } | 842 } |
| 844 | 843 |
| 845 } // namespace extensions | 844 } // namespace extensions |
| OLD | NEW |