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/history/history_service_factory.h" | 5 #include "chrome/browser/history/history_service_factory.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
9 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" | 9 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" |
10 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h" | 10 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h" |
11 #include "chrome/browser/history/chrome_history_client.h" | 11 #include "chrome/browser/history/chrome_history_client.h" |
12 #include "chrome/browser/history/chrome_history_client_factory.h" | 12 #include "chrome/browser/history/chrome_history_client_factory.h" |
13 #include "chrome/browser/history/history_service.h" | 13 #include "chrome/browser/history/history_service.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/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
16 #include "components/bookmarks/browser/bookmark_model.h" | 17 #include "components/bookmarks/browser/bookmark_model.h" |
17 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 18 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 19 #include "components/keyed_service/core/service_access_type.h" |
18 | 20 |
19 // static | 21 // static |
20 HistoryService* HistoryServiceFactory::GetForProfile( | 22 HistoryService* HistoryServiceFactory::GetForProfile(Profile* profile, |
21 Profile* profile, Profile::ServiceAccessType sat) { | 23 ServiceAccessType sat) { |
22 // If saving history is disabled, only allow explicit access. | 24 // If saving history is disabled, only allow explicit access. |
23 if (profile->GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled) && | 25 if (profile->GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled) && |
24 sat != Profile::EXPLICIT_ACCESS) | 26 sat != ServiceAccessType::EXPLICIT_ACCESS) |
25 return NULL; | 27 return NULL; |
26 | 28 |
27 return static_cast<HistoryService*>( | 29 return static_cast<HistoryService*>( |
28 GetInstance()->GetServiceForBrowserContext(profile, true)); | 30 GetInstance()->GetServiceForBrowserContext(profile, true)); |
29 } | 31 } |
30 | 32 |
31 // static | 33 // static |
32 HistoryService* | 34 HistoryService* HistoryServiceFactory::GetForProfileIfExists( |
33 HistoryServiceFactory::GetForProfileIfExists( | 35 Profile* profile, |
34 Profile* profile, Profile::ServiceAccessType sat) { | 36 ServiceAccessType sat) { |
35 // If saving history is disabled, only allow explicit access. | 37 // If saving history is disabled, only allow explicit access. |
36 if (profile->GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled) && | 38 if (profile->GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled) && |
37 sat != Profile::EXPLICIT_ACCESS) | 39 sat != ServiceAccessType::EXPLICIT_ACCESS) |
38 return NULL; | 40 return NULL; |
39 | 41 |
40 return static_cast<HistoryService*>( | 42 return static_cast<HistoryService*>( |
41 GetInstance()->GetServiceForBrowserContext(profile, false)); | 43 GetInstance()->GetServiceForBrowserContext(profile, false)); |
42 } | 44 } |
43 | 45 |
44 // static | 46 // static |
45 HistoryService* | 47 HistoryService* |
46 HistoryServiceFactory::GetForProfileWithoutCreating(Profile* profile) { | 48 HistoryServiceFactory::GetForProfileWithoutCreating(Profile* profile) { |
47 return static_cast<HistoryService*>( | 49 return static_cast<HistoryService*>( |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 } | 84 } |
83 | 85 |
84 content::BrowserContext* HistoryServiceFactory::GetBrowserContextToUse( | 86 content::BrowserContext* HistoryServiceFactory::GetBrowserContextToUse( |
85 content::BrowserContext* context) const { | 87 content::BrowserContext* context) const { |
86 return chrome::GetBrowserContextRedirectedInIncognito(context); | 88 return chrome::GetBrowserContextRedirectedInIncognito(context); |
87 } | 89 } |
88 | 90 |
89 bool HistoryServiceFactory::ServiceIsNULLWhileTesting() const { | 91 bool HistoryServiceFactory::ServiceIsNULLWhileTesting() const { |
90 return true; | 92 return true; |
91 } | 93 } |
OLD | NEW |