OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/undo/bookmark_undo_service_factory.h" | 5 #include "chrome/browser/undo/bookmark_undo_service_factory.h" |
6 | 6 |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/undo/bookmark_undo_service.h" | 8 #include "chrome/browser/undo/bookmark_undo_service.h" |
9 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 9 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
10 | 10 |
11 // static | 11 // static |
12 BookmarkUndoService* BookmarkUndoServiceFactory::GetForProfile( | 12 BookmarkUndoService* BookmarkUndoServiceFactory::GetForProfile( |
13 Profile* profile) { | 13 Profile* profile) { |
14 return static_cast<BookmarkUndoService*>( | 14 return static_cast<BookmarkUndoService*>( |
15 GetInstance()->GetServiceForBrowserContext(profile, true)); | 15 GetInstance()->GetServiceForBrowserContext(profile, true)); |
16 } | 16 } |
17 | 17 |
18 // static | 18 // static |
| 19 BookmarkUndoService* BookmarkUndoServiceFactory::GetForProfileIfExists( |
| 20 Profile* profile) { |
| 21 return static_cast<BookmarkUndoService*>( |
| 22 GetInstance()->GetServiceForBrowserContext(profile, false)); |
| 23 } |
| 24 |
| 25 // static |
19 BookmarkUndoServiceFactory* BookmarkUndoServiceFactory::GetInstance() { | 26 BookmarkUndoServiceFactory* BookmarkUndoServiceFactory::GetInstance() { |
20 return Singleton<BookmarkUndoServiceFactory>::get(); | 27 return Singleton<BookmarkUndoServiceFactory>::get(); |
21 } | 28 } |
22 | 29 |
23 BookmarkUndoServiceFactory::BookmarkUndoServiceFactory() | 30 BookmarkUndoServiceFactory::BookmarkUndoServiceFactory() |
24 : BrowserContextKeyedServiceFactory( | 31 : BrowserContextKeyedServiceFactory( |
25 "BookmarkUndoService", | 32 "BookmarkUndoService", |
26 BrowserContextDependencyManager::GetInstance()) { | 33 BrowserContextDependencyManager::GetInstance()) { |
27 } | 34 } |
28 | 35 |
29 BookmarkUndoServiceFactory::~BookmarkUndoServiceFactory() { | 36 BookmarkUndoServiceFactory::~BookmarkUndoServiceFactory() { |
30 } | 37 } |
31 | 38 |
32 KeyedService* BookmarkUndoServiceFactory::BuildServiceInstanceFor( | 39 KeyedService* BookmarkUndoServiceFactory::BuildServiceInstanceFor( |
33 content::BrowserContext* context) const { | 40 content::BrowserContext* context) const { |
34 return new BookmarkUndoService; | 41 return new BookmarkUndoService; |
35 } | 42 } |
OLD | NEW |