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/bookmarks_api.h" | 5 #include "chrome/browser/extensions/api/bookmarks/bookmarks_api.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/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/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
15 #include "base/profiler/scoped_profile.h" | |
16 #include "base/sha1.h" | 15 #include "base/sha1.h" |
17 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
18 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
19 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
20 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
21 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
22 #include "base/time/time.h" | 21 #include "base/time/time.h" |
23 #include "chrome/browser/bookmarks/bookmark_html_writer.h" | 22 #include "chrome/browser/bookmarks/bookmark_html_writer.h" |
24 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 23 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
25 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" | 24 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 static base::LazyInstance<BrowserContextKeyedAPIFactory<BookmarksAPI> > | 389 static base::LazyInstance<BrowserContextKeyedAPIFactory<BookmarksAPI> > |
391 g_factory = LAZY_INSTANCE_INITIALIZER; | 390 g_factory = LAZY_INSTANCE_INITIALIZER; |
392 | 391 |
393 // static | 392 // static |
394 BrowserContextKeyedAPIFactory<BookmarksAPI>* | 393 BrowserContextKeyedAPIFactory<BookmarksAPI>* |
395 BookmarksAPI::GetFactoryInstance() { | 394 BookmarksAPI::GetFactoryInstance() { |
396 return g_factory.Pointer(); | 395 return g_factory.Pointer(); |
397 } | 396 } |
398 | 397 |
399 void BookmarksAPI::OnListenerAdded(const EventListenerInfo& details) { | 398 void BookmarksAPI::OnListenerAdded(const EventListenerInfo& details) { |
400 // TODO(vadimt): Remove ScopedProfile below once crbug.com/417106 is fixed. | |
401 tracked_objects::ScopedProfile tracking_profile( | |
402 FROM_HERE_WITH_EXPLICIT_FUNCTION("BookmarksAPI::OnListenerAdded")); | |
403 | |
404 bookmark_event_router_.reset( | 399 bookmark_event_router_.reset( |
405 new BookmarkEventRouter(Profile::FromBrowserContext(browser_context_))); | 400 new BookmarkEventRouter(Profile::FromBrowserContext(browser_context_))); |
406 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 401 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
407 } | 402 } |
408 | 403 |
409 bool BookmarksGetFunction::RunOnReady() { | 404 bool BookmarksGetFunction::RunOnReady() { |
410 scoped_ptr<bookmarks::Get::Params> params( | 405 scoped_ptr<bookmarks::Get::Params> params( |
411 bookmarks::Get::Params::Create(*args_)); | 406 bookmarks::Get::Params::Create(*args_)); |
412 EXTENSION_FUNCTION_VALIDATE(params.get()); | 407 EXTENSION_FUNCTION_VALIDATE(params.get()); |
413 | 408 |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 } | 837 } |
843 | 838 |
844 void BookmarksExportFunction::FileSelected(const base::FilePath& path, | 839 void BookmarksExportFunction::FileSelected(const base::FilePath& path, |
845 int index, | 840 int index, |
846 void* params) { | 841 void* params) { |
847 bookmark_html_writer::WriteBookmarks(GetProfile(), path, NULL); | 842 bookmark_html_writer::WriteBookmarks(GetProfile(), path, NULL); |
848 Release(); // Balanced in BookmarksIOFunction::SelectFile() | 843 Release(); // Balanced in BookmarksIOFunction::SelectFile() |
849 } | 844 } |
850 | 845 |
851 } // namespace extensions | 846 } // namespace extensions |
OLD | NEW |