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/webdata/web_data_service_factory.h" | 5 #include "chrome/browser/webdata/web_data_service_factory.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/profiles/incognito_helpers.h" | 11 #include "chrome/browser/profiles/incognito_helpers.h" |
| 12 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/sync/glue/sync_start_util.h" | 13 #include "chrome/browser/sync/glue/sync_start_util.h" |
13 #include "chrome/browser/ui/profile_error_dialog.h" | 14 #include "chrome/browser/ui/profile_error_dialog.h" |
14 #include "chrome/grit/chromium_strings.h" | 15 #include "chrome/grit/chromium_strings.h" |
15 #include "chrome/grit/generated_resources.h" | 16 #include "chrome/grit/generated_resources.h" |
16 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 17 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
17 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 18 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
18 #include "components/search_engines/keyword_web_data_service.h" | 19 #include "components/search_engines/keyword_web_data_service.h" |
19 #include "components/signin/core/browser/webdata/token_web_data.h" | 20 #include "components/signin/core/browser/webdata/token_web_data.h" |
20 #include "components/webdata_services/web_data_service_wrapper.h" | 21 #include "components/webdata_services/web_data_service_wrapper.h" |
21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 BrowserContextDependencyManager::GetInstance()) { | 69 BrowserContextDependencyManager::GetInstance()) { |
69 // WebDataServiceFactory has no dependecies. | 70 // WebDataServiceFactory has no dependecies. |
70 } | 71 } |
71 | 72 |
72 WebDataServiceFactory::~WebDataServiceFactory() { | 73 WebDataServiceFactory::~WebDataServiceFactory() { |
73 } | 74 } |
74 | 75 |
75 // static | 76 // static |
76 WebDataServiceWrapper* WebDataServiceFactory::GetForProfile( | 77 WebDataServiceWrapper* WebDataServiceFactory::GetForProfile( |
77 Profile* profile, | 78 Profile* profile, |
78 Profile::ServiceAccessType access_type) { | 79 ServiceAccessType access_type) { |
79 // If |access_type| starts being used for anything other than this | 80 // If |access_type| starts being used for anything other than this |
80 // DCHECK, we need to start taking it as a parameter to | 81 // DCHECK, we need to start taking it as a parameter to |
81 // the *WebDataService::FromBrowserContext() functions (see above). | 82 // the *WebDataService::FromBrowserContext() functions (see above). |
82 DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord()); | 83 DCHECK(access_type != ServiceAccessType::IMPLICIT_ACCESS || |
| 84 !profile->IsOffTheRecord()); |
83 return static_cast<WebDataServiceWrapper*>( | 85 return static_cast<WebDataServiceWrapper*>( |
84 GetInstance()->GetServiceForBrowserContext(profile, true)); | 86 GetInstance()->GetServiceForBrowserContext(profile, true)); |
85 } | 87 } |
86 | 88 |
87 // static | 89 // static |
88 WebDataServiceWrapper* WebDataServiceFactory::GetForProfileIfExists( | 90 WebDataServiceWrapper* WebDataServiceFactory::GetForProfileIfExists( |
89 Profile* profile, | 91 Profile* profile, |
90 Profile::ServiceAccessType access_type) { | 92 ServiceAccessType access_type) { |
91 // If |access_type| starts being used for anything other than this | 93 // If |access_type| starts being used for anything other than this |
92 // DCHECK, we need to start taking it as a parameter to | 94 // DCHECK, we need to start taking it as a parameter to |
93 // the *WebDataService::FromBrowserContext() functions (see above). | 95 // the *WebDataService::FromBrowserContext() functions (see above). |
94 DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord()); | 96 DCHECK(access_type != ServiceAccessType::IMPLICIT_ACCESS || |
| 97 !profile->IsOffTheRecord()); |
95 return static_cast<WebDataServiceWrapper*>( | 98 return static_cast<WebDataServiceWrapper*>( |
96 GetInstance()->GetServiceForBrowserContext(profile, false)); | 99 GetInstance()->GetServiceForBrowserContext(profile, false)); |
97 } | 100 } |
98 | 101 |
99 // static | 102 // static |
100 scoped_refptr<autofill::AutofillWebDataService> | 103 scoped_refptr<autofill::AutofillWebDataService> |
101 WebDataServiceFactory::GetAutofillWebDataForProfile( | 104 WebDataServiceFactory::GetAutofillWebDataForProfile( |
102 Profile* profile, | 105 Profile* profile, |
103 Profile::ServiceAccessType access_type) { | 106 ServiceAccessType access_type) { |
104 WebDataServiceWrapper* wrapper = | 107 WebDataServiceWrapper* wrapper = |
105 WebDataServiceFactory::GetForProfile(profile, access_type); | 108 WebDataServiceFactory::GetForProfile(profile, access_type); |
106 // |wrapper| can be null in Incognito mode. | 109 // |wrapper| can be null in Incognito mode. |
107 return wrapper ? | 110 return wrapper ? |
108 wrapper->GetAutofillWebData() : | 111 wrapper->GetAutofillWebData() : |
109 scoped_refptr<autofill::AutofillWebDataService>(nullptr); | 112 scoped_refptr<autofill::AutofillWebDataService>(nullptr); |
110 } | 113 } |
111 | 114 |
112 // static | 115 // static |
113 scoped_refptr<KeywordWebDataService> | 116 scoped_refptr<KeywordWebDataService> |
114 WebDataServiceFactory::GetKeywordWebDataForProfile( | 117 WebDataServiceFactory::GetKeywordWebDataForProfile( |
115 Profile* profile, | 118 Profile* profile, |
116 Profile::ServiceAccessType access_type) { | 119 ServiceAccessType access_type) { |
117 WebDataServiceWrapper* wrapper = | 120 WebDataServiceWrapper* wrapper = |
118 WebDataServiceFactory::GetForProfile(profile, access_type); | 121 WebDataServiceFactory::GetForProfile(profile, access_type); |
119 // |wrapper| can be null in Incognito mode. | 122 // |wrapper| can be null in Incognito mode. |
120 return wrapper ? | 123 return wrapper ? |
121 wrapper->GetKeywordWebData() : | 124 wrapper->GetKeywordWebData() : |
122 scoped_refptr<KeywordWebDataService>(nullptr); | 125 scoped_refptr<KeywordWebDataService>(nullptr); |
123 } | 126 } |
124 | 127 |
125 // static | 128 // static |
126 scoped_refptr<TokenWebData> WebDataServiceFactory::GetTokenWebDataForProfile( | 129 scoped_refptr<TokenWebData> WebDataServiceFactory::GetTokenWebDataForProfile( |
127 Profile* profile, | 130 Profile* profile, |
128 Profile::ServiceAccessType access_type) { | 131 ServiceAccessType access_type) { |
129 WebDataServiceWrapper* wrapper = | 132 WebDataServiceWrapper* wrapper = |
130 WebDataServiceFactory::GetForProfile(profile, access_type); | 133 WebDataServiceFactory::GetForProfile(profile, access_type); |
131 // |wrapper| can be null in Incognito mode. | 134 // |wrapper| can be null in Incognito mode. |
132 return wrapper ? | 135 return wrapper ? |
133 wrapper->GetTokenWebData() : scoped_refptr<TokenWebData>(nullptr); | 136 wrapper->GetTokenWebData() : scoped_refptr<TokenWebData>(nullptr); |
134 } | 137 } |
135 | 138 |
136 #if defined(OS_WIN) | 139 #if defined(OS_WIN) |
137 // static | 140 // static |
138 scoped_refptr<PasswordWebDataService> | 141 scoped_refptr<PasswordWebDataService> |
139 WebDataServiceFactory::GetPasswordWebDataForProfile( | 142 WebDataServiceFactory::GetPasswordWebDataForProfile( |
140 Profile* profile, | 143 Profile* profile, |
141 Profile::ServiceAccessType access_type) { | 144 ServiceAccessType access_type) { |
142 WebDataServiceWrapper* wrapper = | 145 WebDataServiceWrapper* wrapper = |
143 WebDataServiceFactory::GetForProfile(profile, access_type); | 146 WebDataServiceFactory::GetForProfile(profile, access_type); |
144 // |wrapper| can be null in Incognito mode. | 147 // |wrapper| can be null in Incognito mode. |
145 return wrapper ? | 148 return wrapper ? |
146 wrapper->GetPasswordWebData() : | 149 wrapper->GetPasswordWebData() : |
147 scoped_refptr<PasswordWebDataService>(nullptr); | 150 scoped_refptr<PasswordWebDataService>(nullptr); |
148 } | 151 } |
149 #endif | 152 #endif |
150 | 153 |
151 // static | 154 // static |
(...skipping 13 matching lines...) Expand all Loading... |
165 profile_path, g_browser_process->GetApplicationLocale(), | 168 profile_path, g_browser_process->GetApplicationLocale(), |
166 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 169 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
167 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), | 170 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), |
168 sync_start_util::GetFlareForSyncableService(profile_path), | 171 sync_start_util::GetFlareForSyncableService(profile_path), |
169 &ProfileErrorCallback); | 172 &ProfileErrorCallback); |
170 } | 173 } |
171 | 174 |
172 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const { | 175 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const { |
173 return true; | 176 return true; |
174 } | 177 } |
OLD | NEW |