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/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" | 12 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" |
13 #include "chrome/browser/omnibox/omnibox_field_trial.h" | 13 #include "chrome/browser/omnibox/omnibox_field_trial.h" |
14 #include "chrome/browser/profiles/incognito_helpers.h" | 14 #include "chrome/browser/profiles/incognito_helpers.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/profiles/startup_task_runner_service.h" | 16 #include "chrome/browser/profiles/startup_task_runner_service.h" |
17 #include "chrome/browser/profiles/startup_task_runner_service_factory.h" | 17 #include "chrome/browser/profiles/startup_task_runner_service_factory.h" |
18 #include "chrome/browser/undo/bookmark_undo_service.h" | 18 #include "chrome/browser/undo/bookmark_undo_service.h" |
19 #include "chrome/browser/undo/bookmark_undo_service_factory.h" | 19 #include "chrome/browser/undo/bookmark_undo_service_factory.h" |
20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
21 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
22 #include "components/bookmarks/browser/bookmark_model.h" | 22 #include "components/bookmarks/browser/bookmark_model.h" |
23 #include "components/bookmarks/common/bookmark_pref_names.h" | 23 #include "components/bookmarks/common/bookmark_pref_names.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/pref_registry/pref_registry_syncable.h" | 25 #include "components/pref_registry/pref_registry_syncable.h" |
26 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
27 | 27 |
28 // static | 28 // static |
29 BookmarkModel* BookmarkModelFactory::GetForProfile(Profile* profile) { | 29 BookmarkModel* BookmarkModelFactory::GetForProfile(Profile* profile) { |
30 ChromeBookmarkClient* bookmark_client = static_cast<ChromeBookmarkClient*>( | 30 ChromeBookmarkClient* bookmark_client = |
31 GetInstance()->GetServiceForBrowserContext(profile, true)); | 31 GetChromeBookmarkClientForProfile(profile); |
32 return bookmark_client ? bookmark_client->model() : NULL; | 32 return bookmark_client ? bookmark_client->model() : NULL; |
33 } | 33 } |
34 | 34 |
| 35 // static |
35 BookmarkModel* BookmarkModelFactory::GetForProfileIfExists(Profile* profile) { | 36 BookmarkModel* BookmarkModelFactory::GetForProfileIfExists(Profile* profile) { |
36 ChromeBookmarkClient* bookmark_client = static_cast<ChromeBookmarkClient*>( | 37 ChromeBookmarkClient* bookmark_client = static_cast<ChromeBookmarkClient*>( |
37 GetInstance()->GetServiceForBrowserContext(profile, false)); | 38 GetInstance()->GetServiceForBrowserContext(profile, false)); |
38 return bookmark_client ? bookmark_client->model() : NULL; | 39 return bookmark_client ? bookmark_client->model() : NULL; |
39 } | 40 } |
40 | 41 |
41 // static | 42 // static |
| 43 ChromeBookmarkClient* BookmarkModelFactory::GetChromeBookmarkClientForProfile( |
| 44 Profile* profile) { |
| 45 return static_cast<ChromeBookmarkClient*>( |
| 46 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 47 } |
| 48 |
| 49 // static |
42 BookmarkModelFactory* BookmarkModelFactory::GetInstance() { | 50 BookmarkModelFactory* BookmarkModelFactory::GetInstance() { |
43 return Singleton<BookmarkModelFactory>::get(); | 51 return Singleton<BookmarkModelFactory>::get(); |
44 } | 52 } |
45 | 53 |
46 BookmarkModelFactory::BookmarkModelFactory() | 54 BookmarkModelFactory::BookmarkModelFactory() |
47 : BrowserContextKeyedServiceFactory( | 55 : BrowserContextKeyedServiceFactory( |
48 "BookmarkModel", | 56 "BookmarkModel", |
49 BrowserContextDependencyManager::GetInstance()) { | 57 BrowserContextDependencyManager::GetInstance()) { |
50 } | 58 } |
51 | 59 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } | 102 } |
95 | 103 |
96 content::BrowserContext* BookmarkModelFactory::GetBrowserContextToUse( | 104 content::BrowserContext* BookmarkModelFactory::GetBrowserContextToUse( |
97 content::BrowserContext* context) const { | 105 content::BrowserContext* context) const { |
98 return chrome::GetBrowserContextRedirectedInIncognito(context); | 106 return chrome::GetBrowserContextRedirectedInIncognito(context); |
99 } | 107 } |
100 | 108 |
101 bool BookmarkModelFactory::ServiceIsNULLWhileTesting() const { | 109 bool BookmarkModelFactory::ServiceIsNULLWhileTesting() const { |
102 return true; | 110 return true; |
103 } | 111 } |
OLD | NEW |