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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
14 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
19 #include "chrome/browser/bookmarks/bookmark_stats.h" | 19 #include "chrome/browser/bookmarks/bookmark_stats.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 BookmarkModelFactory::GetForProfile(profile), profile_path); | 162 BookmarkModelFactory::GetForProfile(profile), profile_path); |
163 for (size_t i = 0; i < nodes.size(); ++i) { | 163 for (size_t i = 0; i < nodes.size(); ++i) { |
164 node_data->elements.push_back( | 164 node_data->elements.push_back( |
165 CreateNodeDataElementFromBookmarkNode(*nodes[i])); | 165 CreateNodeDataElementFromBookmarkNode(*nodes[i])); |
166 } | 166 } |
167 } else { | 167 } else { |
168 // We do not have a node IDs when the data comes from a different profile. | 168 // We do not have a node IDs when the data comes from a different profile. |
169 for (size_t i = 0; i < data.size(); ++i) | 169 for (size_t i = 0; i < data.size(); ++i) |
170 node_data->elements.push_back(CreateApiNodeDataElement(data.elements[i])); | 170 node_data->elements.push_back(CreateApiNodeDataElement(data.elements[i])); |
171 } | 171 } |
172 return node_data.Pass(); | 172 return node_data; |
173 } | 173 } |
174 | 174 |
175 } // namespace | 175 } // namespace |
176 | 176 |
177 BookmarkManagerPrivateEventRouter::BookmarkManagerPrivateEventRouter( | 177 BookmarkManagerPrivateEventRouter::BookmarkManagerPrivateEventRouter( |
178 content::BrowserContext* browser_context, | 178 content::BrowserContext* browser_context, |
179 BookmarkModel* bookmark_model) | 179 BookmarkModel* bookmark_model) |
180 : browser_context_(browser_context), bookmark_model_(bookmark_model) { | 180 : browser_context_(browser_context), bookmark_model_(bookmark_model) { |
181 bookmark_model_->AddObserver(this); | 181 bookmark_model_->AddObserver(this); |
182 } | 182 } |
183 | 183 |
184 BookmarkManagerPrivateEventRouter::~BookmarkManagerPrivateEventRouter() { | 184 BookmarkManagerPrivateEventRouter::~BookmarkManagerPrivateEventRouter() { |
185 if (bookmark_model_) | 185 if (bookmark_model_) |
186 bookmark_model_->RemoveObserver(this); | 186 bookmark_model_->RemoveObserver(this); |
187 } | 187 } |
188 | 188 |
189 void BookmarkManagerPrivateEventRouter::DispatchEvent( | 189 void BookmarkManagerPrivateEventRouter::DispatchEvent( |
190 events::HistogramValue histogram_value, | 190 events::HistogramValue histogram_value, |
191 const std::string& event_name, | 191 const std::string& event_name, |
192 scoped_ptr<base::ListValue> event_args) { | 192 scoped_ptr<base::ListValue> event_args) { |
193 EventRouter::Get(browser_context_) | 193 EventRouter::Get(browser_context_) |
194 ->BroadcastEvent(make_scoped_ptr( | 194 ->BroadcastEvent(make_scoped_ptr( |
195 new Event(histogram_value, event_name, event_args.Pass()))); | 195 new Event(histogram_value, event_name, std::move(event_args)))); |
196 } | 196 } |
197 | 197 |
198 void BookmarkManagerPrivateEventRouter::BookmarkModelChanged() {} | 198 void BookmarkManagerPrivateEventRouter::BookmarkModelChanged() {} |
199 | 199 |
200 void BookmarkManagerPrivateEventRouter::BookmarkModelBeingDeleted( | 200 void BookmarkManagerPrivateEventRouter::BookmarkModelBeingDeleted( |
201 BookmarkModel* model) { | 201 BookmarkModel* model) { |
202 bookmark_model_ = NULL; | 202 bookmark_model_ = NULL; |
203 } | 203 } |
204 | 204 |
205 void BookmarkManagerPrivateEventRouter::OnWillChangeBookmarkMetaInfo( | 205 void BookmarkManagerPrivateEventRouter::OnWillChangeBookmarkMetaInfo( |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 } | 303 } |
304 | 304 |
305 void BookmarkManagerPrivateDragEventRouter::DispatchEvent( | 305 void BookmarkManagerPrivateDragEventRouter::DispatchEvent( |
306 events::HistogramValue histogram_value, | 306 events::HistogramValue histogram_value, |
307 const std::string& event_name, | 307 const std::string& event_name, |
308 scoped_ptr<base::ListValue> args) { | 308 scoped_ptr<base::ListValue> args) { |
309 EventRouter* event_router = EventRouter::Get(profile_); | 309 EventRouter* event_router = EventRouter::Get(profile_); |
310 if (!event_router) | 310 if (!event_router) |
311 return; | 311 return; |
312 | 312 |
313 scoped_ptr<Event> event(new Event(histogram_value, event_name, args.Pass())); | 313 scoped_ptr<Event> event( |
314 event_router->BroadcastEvent(event.Pass()); | 314 new Event(histogram_value, event_name, std::move(args))); |
| 315 event_router->BroadcastEvent(std::move(event)); |
315 } | 316 } |
316 | 317 |
317 void BookmarkManagerPrivateDragEventRouter::OnDragEnter( | 318 void BookmarkManagerPrivateDragEventRouter::OnDragEnter( |
318 const BookmarkNodeData& data) { | 319 const BookmarkNodeData& data) { |
319 if (!data.is_valid()) | 320 if (!data.is_valid()) |
320 return; | 321 return; |
321 DispatchEvent(events::BOOKMARK_MANAGER_PRIVATE_ON_DRAG_ENTER, | 322 DispatchEvent(events::BOOKMARK_MANAGER_PRIVATE_ON_DRAG_ENTER, |
322 bookmark_manager_private::OnDragEnter::kEventName, | 323 bookmark_manager_private::OnDragEnter::kEventName, |
323 bookmark_manager_private::OnDragEnter::Create( | 324 bookmark_manager_private::OnDragEnter::Create( |
324 *CreateApiBookmarkNodeData(profile_, data))); | 325 *CreateApiBookmarkNodeData(profile_, data))); |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 | 861 |
861 enhanced_bookmarks::EnhancedBookmarkModel* model = | 862 enhanced_bookmarks::EnhancedBookmarkModel* model = |
862 enhanced_bookmarks::EnhancedBookmarkModelFactory::GetForBrowserContext( | 863 enhanced_bookmarks::EnhancedBookmarkModelFactory::GetForBrowserContext( |
863 browser_context()); | 864 browser_context()); |
864 model->SetVersionSuffix(params->version); | 865 model->SetVersionSuffix(params->version); |
865 | 866 |
866 return true; | 867 return true; |
867 } | 868 } |
868 | 869 |
869 } // namespace extensions | 870 } // namespace extensions |
OLD | NEW |