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/bookmarks/bookmark_api.h" | 5 #include "chrome/browser/extensions/api/bookmarks/bookmark_api.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/i18n/file_util_icu.h" | 9 #include "base/i18n/file_util_icu.h" |
10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 12 #include "base/lazy_instance.h" |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
13 #include "base/path_service.h" | 14 #include "base/path_service.h" |
14 #include "base/prefs/public/pref_service_base.h" | 15 #include "base/prefs/public/pref_service_base.h" |
15 #include "base/sha1.h" | 16 #include "base/sha1.h" |
16 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
17 #include "base/string16.h" | 18 #include "base/string16.h" |
18 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
19 #include "base/string_util.h" | 20 #include "base/string_util.h" |
20 #include "base/time.h" | 21 #include "base/time.h" |
21 #include "base/utf_string_conversions.h" | 22 #include "base/utf_string_conversions.h" |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 this, keys::kOnBookmarkImportEnded); | 291 this, keys::kOnBookmarkImportEnded); |
291 } | 292 } |
292 | 293 |
293 BookmarkAPI::~BookmarkAPI() { | 294 BookmarkAPI::~BookmarkAPI() { |
294 } | 295 } |
295 | 296 |
296 void BookmarkAPI::Shutdown() { | 297 void BookmarkAPI::Shutdown() { |
297 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); | 298 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); |
298 } | 299 } |
299 | 300 |
| 301 static base::LazyInstance<ProfileKeyedAPIFactory<BookmarkAPI> > |
| 302 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 303 |
| 304 // static |
| 305 ProfileKeyedAPIFactory<BookmarkAPI>* BookmarkAPI::GetFactoryInstance() { |
| 306 return &g_factory.Get(); |
| 307 } |
| 308 |
300 void BookmarkAPI::OnListenerAdded(const EventListenerInfo& details) { | 309 void BookmarkAPI::OnListenerAdded(const EventListenerInfo& details) { |
301 bookmark_event_router_.reset(new BookmarkEventRouter( | 310 bookmark_event_router_.reset(new BookmarkEventRouter( |
302 BookmarkModelFactory::GetForProfile(profile_))); | 311 BookmarkModelFactory::GetForProfile(profile_))); |
303 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); | 312 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); |
304 } | 313 } |
305 | 314 |
306 bool GetBookmarksFunction::RunImpl() { | 315 bool GetBookmarksFunction::RunImpl() { |
307 scoped_ptr<bookmarks::Get::Params> params( | 316 scoped_ptr<bookmarks::Get::Params> params( |
308 bookmarks::Get::Params::Create(*args_)); | 317 bookmarks::Get::Params::Create(*args_)); |
309 EXTENSION_FUNCTION_VALIDATE(params.get()); | 318 EXTENSION_FUNCTION_VALIDATE(params.get()); |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
987 #if !defined(OS_ANDROID) | 996 #if !defined(OS_ANDROID) |
988 // Android does not have support for the standard exporter. | 997 // Android does not have support for the standard exporter. |
989 // TODO(jgreenwald): remove ifdef once extensions are no longer built on | 998 // TODO(jgreenwald): remove ifdef once extensions are no longer built on |
990 // Android. | 999 // Android. |
991 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); | 1000 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); |
992 #endif | 1001 #endif |
993 Release(); // Balanced in BookmarksIOFunction::SelectFile() | 1002 Release(); // Balanced in BookmarksIOFunction::SelectFile() |
994 } | 1003 } |
995 | 1004 |
996 } // namespace extensions | 1005 } // namespace extensions |
OLD | NEW |