| 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 "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profiles/incognito_helpers.h" | 10 #include "chrome/browser/profiles/incognito_helpers.h" |
| 11 #include "chrome/browser/sync/glue/sync_start_util.h" | 11 #include "chrome/browser/sync/glue/sync_start_util.h" |
| 12 #include "chrome/browser/ui/profile_error_dialog.h" | 12 #include "chrome/browser/ui/profile_error_dialog.h" |
| 13 #include "chrome/browser/webdata/autocomplete_syncable_service.h" | 13 #include "chrome/browser/webdata/autocomplete_syncable_service.h" |
| 14 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" | 14 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" |
| 15 #include "chrome/browser/webdata/keyword_table.h" | 15 #include "chrome/browser/webdata/keyword_table.h" |
| 16 #include "chrome/browser/webdata/logins_table.h" | 16 #include "chrome/browser/webdata/logins_table.h" |
| 17 #include "chrome/browser/webdata/token_service_table.h" | 17 #include "chrome/browser/webdata/token_service_table.h" |
| 18 #include "chrome/browser/webdata/token_web_data.h" |
| 18 #include "chrome/browser/webdata/web_apps_table.h" | 19 #include "chrome/browser/webdata/web_apps_table.h" |
| 19 #include "chrome/browser/webdata/web_data_service.h" | 20 #include "chrome/browser/webdata/web_data_service.h" |
| 20 #include "chrome/browser/webdata/web_intents_table.h" | 21 #include "chrome/browser/webdata/web_intents_table.h" |
| 21 #include "components/autofill/browser/autofill_country.h" | 22 #include "components/autofill/browser/autofill_country.h" |
| 22 #include "components/autofill/browser/webdata/autofill_table.h" | 23 #include "components/autofill/browser/webdata/autofill_table.h" |
| 23 #include "components/autofill/browser/webdata/autofill_webdata_service.h" | 24 #include "components/autofill/browser/webdata/autofill_webdata_service.h" |
| 24 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | 25 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
| 25 #include "components/webdata/common/webdata_constants.h" | 26 #include "components/webdata/common/webdata_constants.h" |
| 26 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 27 #include "grit/chromium_strings.h" | 28 #include "grit/chromium_strings.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 // WebIntentsTable, then remove this. | 91 // WebIntentsTable, then remove this. |
| 91 web_database_->AddTable( | 92 web_database_->AddTable( |
| 92 scoped_ptr<WebDatabaseTable>(new WebIntentsTable())); | 93 scoped_ptr<WebDatabaseTable>(new WebIntentsTable())); |
| 93 | 94 |
| 94 web_database_->LoadDatabase(); | 95 web_database_->LoadDatabase(); |
| 95 | 96 |
| 96 autofill_web_data_ = new AutofillWebDataService( | 97 autofill_web_data_ = new AutofillWebDataService( |
| 97 web_database_, base::Bind(&ProfileErrorCallback)); | 98 web_database_, base::Bind(&ProfileErrorCallback)); |
| 98 autofill_web_data_->Init(); | 99 autofill_web_data_->Init(); |
| 99 | 100 |
| 101 token_web_data_ = new TokenWebData( |
| 102 web_database_, base::Bind(&ProfileErrorCallback)); |
| 103 token_web_data_->Init(); |
| 104 |
| 100 web_data_ = new WebDataService( | 105 web_data_ = new WebDataService( |
| 101 web_database_, base::Bind(&ProfileErrorCallback)); | 106 web_database_, base::Bind(&ProfileErrorCallback)); |
| 102 web_data_->Init(); | 107 web_data_->Init(); |
| 103 | 108 |
| 104 autofill_web_data_->GetAutofillBackend( | 109 autofill_web_data_->GetAutofillBackend( |
| 105 base::Bind(&InitSyncableServicesOnDBThread, | 110 base::Bind(&InitSyncableServicesOnDBThread, |
| 106 autofill_web_data_, | 111 autofill_web_data_, |
| 107 profile_path, | 112 profile_path, |
| 108 g_browser_process->GetApplicationLocale())); | 113 g_browser_process->GetApplicationLocale())); |
| 109 } | 114 } |
| 110 | 115 |
| 111 WebDataServiceWrapper::~WebDataServiceWrapper() { | 116 WebDataServiceWrapper::~WebDataServiceWrapper() { |
| 112 } | 117 } |
| 113 | 118 |
| 114 void WebDataServiceWrapper::Shutdown() { | 119 void WebDataServiceWrapper::Shutdown() { |
| 115 autofill_web_data_->ShutdownOnUIThread(); | 120 autofill_web_data_->ShutdownOnUIThread(); |
| 121 token_web_data_->ShutdownOnUIThread(); |
| 116 web_data_->ShutdownOnUIThread(); | 122 web_data_->ShutdownOnUIThread(); |
| 117 web_database_->ShutdownDatabase(); | 123 web_database_->ShutdownDatabase(); |
| 118 } | 124 } |
| 119 | 125 |
| 120 scoped_refptr<AutofillWebDataService> | 126 scoped_refptr<AutofillWebDataService> |
| 121 WebDataServiceWrapper::GetAutofillWebData() { | 127 WebDataServiceWrapper::GetAutofillWebData() { |
| 122 return autofill_web_data_.get(); | 128 return autofill_web_data_.get(); |
| 123 } | 129 } |
| 124 | 130 |
| 125 scoped_refptr<WebDataService> WebDataServiceWrapper::GetWebData() { | 131 scoped_refptr<WebDataService> WebDataServiceWrapper::GetWebData() { |
| 126 return web_data_.get(); | 132 return web_data_.get(); |
| 127 } | 133 } |
| 128 | 134 |
| 135 scoped_refptr<TokenWebData> WebDataServiceWrapper::GetTokenWebData() { |
| 136 return token_web_data_.get(); |
| 137 } |
| 138 |
| 129 // static | 139 // static |
| 130 scoped_refptr<AutofillWebDataService> | 140 scoped_refptr<AutofillWebDataService> |
| 131 AutofillWebDataService::FromBrowserContext(content::BrowserContext* context) { | 141 AutofillWebDataService::FromBrowserContext(content::BrowserContext* context) { |
| 132 // For this service, the implicit/explicit distinction doesn't | 142 // For this service, the implicit/explicit distinction doesn't |
| 133 // really matter; it's just used for a DCHECK. So we currently | 143 // really matter; it's just used for a DCHECK. So we currently |
| 134 // cheat and always say EXPLICIT_ACCESS. | 144 // cheat and always say EXPLICIT_ACCESS. |
| 135 WebDataServiceWrapper* wrapper = | 145 WebDataServiceWrapper* wrapper = |
| 136 WebDataServiceFactory::GetForProfile( | 146 WebDataServiceFactory::GetForProfile( |
| 137 static_cast<Profile*>(context), Profile::EXPLICIT_ACCESS); | 147 static_cast<Profile*>(context), Profile::EXPLICIT_ACCESS); |
| 138 if (wrapper) | 148 if (wrapper) |
| 139 return wrapper->GetAutofillWebData(); | 149 return wrapper->GetAutofillWebData(); |
| 140 // |wrapper| can be NULL in Incognito mode. | 150 // |wrapper| can be NULL in Incognito mode. |
| 141 return scoped_refptr<AutofillWebDataService>(NULL); | 151 return scoped_refptr<AutofillWebDataService>(NULL); |
| 142 } | 152 } |
| 143 | 153 |
| 144 // static | 154 // static |
| 155 scoped_refptr<TokenWebData> TokenWebData::FromBrowserContext( |
| 156 content::BrowserContext* context) { |
| 157 // For this service, the implicit/explicit distinction doesn't |
| 158 // really matter; it's just used for a DCHECK. So we currently |
| 159 // cheat and always say EXPLICIT_ACCESS. |
| 160 WebDataServiceWrapper* wrapper = |
| 161 WebDataServiceFactory::GetForProfile( |
| 162 static_cast<Profile*>(context), Profile::EXPLICIT_ACCESS); |
| 163 if (wrapper) |
| 164 return wrapper->GetTokenWebData(); |
| 165 // |wrapper| can be NULL in Incognito mode. |
| 166 return scoped_refptr<TokenWebData>(NULL); |
| 167 } |
| 168 |
| 169 // static |
| 145 scoped_refptr<WebDataService> WebDataService::FromBrowserContext( | 170 scoped_refptr<WebDataService> WebDataService::FromBrowserContext( |
| 146 content::BrowserContext* context) { | 171 content::BrowserContext* context) { |
| 147 // For this service, the implicit/explicit distinction doesn't | 172 // For this service, the implicit/explicit distinction doesn't |
| 148 // really matter; it's just used for a DCHECK. So we currently | 173 // really matter; it's just used for a DCHECK. So we currently |
| 149 // cheat and always say EXPLICIT_ACCESS. | 174 // cheat and always say EXPLICIT_ACCESS. |
| 150 WebDataServiceWrapper* wrapper = | 175 WebDataServiceWrapper* wrapper = |
| 151 WebDataServiceFactory::GetForProfile( | 176 WebDataServiceFactory::GetForProfile( |
| 152 static_cast<Profile*>(context), Profile::EXPLICIT_ACCESS); | 177 static_cast<Profile*>(context), Profile::EXPLICIT_ACCESS); |
| 153 if (wrapper) | 178 if (wrapper) |
| 154 return wrapper->GetWebData(); | 179 return wrapper->GetWebData(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 } | 223 } |
| 199 | 224 |
| 200 BrowserContextKeyedService* WebDataServiceFactory::BuildServiceInstanceFor( | 225 BrowserContextKeyedService* WebDataServiceFactory::BuildServiceInstanceFor( |
| 201 content::BrowserContext* profile) const { | 226 content::BrowserContext* profile) const { |
| 202 return new WebDataServiceWrapper(static_cast<Profile*>(profile)); | 227 return new WebDataServiceWrapper(static_cast<Profile*>(profile)); |
| 203 } | 228 } |
| 204 | 229 |
| 205 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const { | 230 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const { |
| 206 return true; | 231 return true; |
| 207 } | 232 } |
| OLD | NEW |