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

Side by Side Diff: chrome/browser/extensions/api/bookmarks/bookmark_api.cc

Issue 11820041: Remove profile-keyed factory boilerplates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 11 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/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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698