| 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/bookmarks/bookmark_model_factory.h" | 5 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/deferred_sequenced_task_runner.h" | 8 #include "base/deferred_sequenced_task_runner.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "components/bookmarks/browser/startup_task_runner_service.h" | 23 #include "components/bookmarks/browser/startup_task_runner_service.h" |
| 24 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 24 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 25 #include "components/prefs/pref_service.h" | 25 #include "components/prefs/pref_service.h" |
| 26 #include "components/undo/bookmark_undo_service.h" | 26 #include "components/undo/bookmark_undo_service.h" |
| 27 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 28 | 28 |
| 29 using bookmarks::BookmarkModel; | 29 using bookmarks::BookmarkModel; |
| 30 | 30 |
| 31 // static | 31 // static |
| 32 BookmarkModel* BookmarkModelFactory::GetForBrowserContext( | 32 BookmarkModel* BookmarkModelFactory::GetForBrowserContext( |
| 33 content::BrowserContext* browser_context) { | 33 content::BrowserContext* context) { |
| 34 return static_cast<BookmarkModel*>( | 34 return static_cast<BookmarkModel*>( |
| 35 GetInstance()->GetServiceForBrowserContext(browser_context, true)); | 35 GetInstance()->GetServiceForBrowserContext(context, true)); |
| 36 } | 36 } |
| 37 | 37 |
| 38 // static | 38 // static |
| 39 BookmarkModel* BookmarkModelFactory::GetForBrowserContextIfExists( | 39 BookmarkModel* BookmarkModelFactory::GetForBrowserContextIfExists( |
| 40 content::BrowserContext* browser_context) { | 40 content::BrowserContext* context) { |
| 41 return static_cast<BookmarkModel*>( | 41 return static_cast<BookmarkModel*>( |
| 42 GetInstance()->GetServiceForBrowserContext(browser_context, false)); | 42 GetInstance()->GetServiceForBrowserContext(context, false)); |
| 43 } | 43 } |
| 44 | 44 |
| 45 // static | 45 // static |
| 46 BookmarkModel* BookmarkModelFactory::GetForProfile(Profile* profile) { | |
| 47 return static_cast<BookmarkModel*>( | |
| 48 GetInstance()->GetServiceForBrowserContext(profile, true)); | |
| 49 } | |
| 50 | |
| 51 // static | |
| 52 BookmarkModel* BookmarkModelFactory::GetForProfileIfExists(Profile* profile) { | |
| 53 return static_cast<BookmarkModel*>( | |
| 54 GetInstance()->GetServiceForBrowserContext(profile, false)); | |
| 55 } | |
| 56 | |
| 57 // static | |
| 58 BookmarkModelFactory* BookmarkModelFactory::GetInstance() { | 46 BookmarkModelFactory* BookmarkModelFactory::GetInstance() { |
| 59 return base::Singleton<BookmarkModelFactory>::get(); | 47 return base::Singleton<BookmarkModelFactory>::get(); |
| 60 } | 48 } |
| 61 | 49 |
| 62 BookmarkModelFactory::BookmarkModelFactory() | 50 BookmarkModelFactory::BookmarkModelFactory() |
| 63 : BrowserContextKeyedServiceFactory( | 51 : BrowserContextKeyedServiceFactory( |
| 64 "BookmarkModel", | 52 "BookmarkModel", |
| 65 BrowserContextDependencyManager::GetInstance()) { | 53 BrowserContextDependencyManager::GetInstance()) { |
| 66 DependsOn(BookmarkUndoServiceFactory::GetInstance()); | 54 DependsOn(BookmarkUndoServiceFactory::GetInstance()); |
| 67 DependsOn(ManagedBookmarkServiceFactory::GetInstance()); | 55 DependsOn(ManagedBookmarkServiceFactory::GetInstance()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } | 88 } |
| 101 | 89 |
| 102 content::BrowserContext* BookmarkModelFactory::GetBrowserContextToUse( | 90 content::BrowserContext* BookmarkModelFactory::GetBrowserContextToUse( |
| 103 content::BrowserContext* context) const { | 91 content::BrowserContext* context) const { |
| 104 return chrome::GetBrowserContextRedirectedInIncognito(context); | 92 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 105 } | 93 } |
| 106 | 94 |
| 107 bool BookmarkModelFactory::ServiceIsNULLWhileTesting() const { | 95 bool BookmarkModelFactory::ServiceIsNULLWhileTesting() const { |
| 108 return true; | 96 return true; |
| 109 } | 97 } |
| OLD | NEW |