Chromium Code Reviews| 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/logins_table.h" | 14 #include "chrome/browser/webdata/logins_table.h" |
| 15 #include "chrome/browser/webdata/web_apps_table.h" | 15 #include "chrome/browser/webdata/web_apps_table.h" |
| 16 #include "chrome/browser/webdata/web_data_service.h" | |
| 17 #include "chrome/browser/webdata/web_intents_table.h" | 16 #include "chrome/browser/webdata/web_intents_table.h" |
| 18 #include "components/autofill/core/browser/autofill_country.h" | 17 #include "components/autofill/core/browser/autofill_country.h" |
| 19 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_ser vice.h" | 18 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_ser vice.h" |
| 20 #include "components/autofill/core/browser/webdata/autofill_table.h" | 19 #include "components/autofill/core/browser/webdata/autofill_table.h" |
| 21 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 20 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
| 22 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 21 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 23 #include "components/search_engines/keyword_table.h" | 22 #include "components/search_engines/keyword_table.h" |
| 24 #include "components/search_engines/keyword_web_data_service.h" | 23 #include "components/search_engines/keyword_web_data_service.h" |
| 25 #include "components/signin/core/browser/webdata/token_service_table.h" | 24 #include "components/signin/core/browser/webdata/token_service_table.h" |
| 26 #include "components/signin/core/browser/webdata/token_web_data.h" | 25 #include "components/signin/core/browser/webdata/token_web_data.h" |
| 27 #include "components/webdata/common/webdata_constants.h" | 26 #include "components/webdata/common/webdata_constants.h" |
| 28 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 29 #include "grit/chromium_strings.h" | 28 #include "grit/chromium_strings.h" |
| 30 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
| 31 | 30 |
| 31 #if defined(OS_WIN) | |
| 32 #include "chrome/browser/webdata/password_web_data_service_win.h" | |
| 33 #endif | |
| 34 | |
| 32 using autofill::AutofillWebDataService; | 35 using autofill::AutofillWebDataService; |
| 33 using autofill::AutofillProfileSyncableService; | 36 using autofill::AutofillProfileSyncableService; |
| 34 using content::BrowserThread; | 37 using content::BrowserThread; |
| 35 | 38 |
| 36 namespace { | 39 namespace { |
| 37 | 40 |
| 38 // Callback to show error dialog on profile load error. | 41 // Callback to show error dialog on profile load error. |
| 39 void ProfileErrorCallback(ProfileErrorType type, sql::InitStatus status) { | 42 void ProfileErrorCallback(ProfileErrorType type, sql::InitStatus status) { |
| 40 ShowProfileErrorDialog( | 43 ShowProfileErrorDialog(type, |
| 41 type, | 44 (status == sql::INIT_FAILURE) |
| 42 (status == sql::INIT_FAILURE) ? | 45 ? IDS_COULDNT_OPEN_PROFILE_ERROR |
| 43 IDS_COULDNT_OPEN_PROFILE_ERROR : IDS_PROFILE_TOO_NEW_ERROR); | 46 : IDS_PROFILE_TOO_NEW_ERROR); |
|
Peter Kasting
2014/07/07 23:20:03
Nit: The old wrapping is correct, the new wrapping
Cait (Slow)
2014/07/09 15:23:16
Done.
| |
| 44 } | 47 } |
| 45 | 48 |
| 46 void InitSyncableServicesOnDBThread( | 49 void InitSyncableServicesOnDBThread( |
| 47 scoped_refptr<AutofillWebDataService> autofill_web_data, | 50 scoped_refptr<AutofillWebDataService> autofill_web_data, |
| 48 const base::FilePath& profile_path, | 51 const base::FilePath& profile_path, |
| 49 const std::string& app_locale, | 52 const std::string& app_locale, |
| 50 autofill::AutofillWebDataBackend* autofill_backend) { | 53 autofill::AutofillWebDataBackend* autofill_backend) { |
| 51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 52 | 55 |
| 53 // Currently only Autocomplete and Autofill profiles use the new Sync API, but | 56 // Currently only Autocomplete and Autofill profiles use the new Sync API, but |
| 54 // all the database data should migrate to this API over time. | 57 // all the database data should migrate to this API over time. |
| 55 AutocompleteSyncableService::CreateForWebDataServiceAndBackend( | 58 AutocompleteSyncableService::CreateForWebDataServiceAndBackend( |
| 56 autofill_web_data.get(), autofill_backend); | 59 autofill_web_data.get(), autofill_backend); |
| 57 AutocompleteSyncableService::FromWebDataService(autofill_web_data.get()) | 60 AutocompleteSyncableService::FromWebDataService(autofill_web_data.get()) |
| 58 ->InjectStartSyncFlare( | 61 ->InjectStartSyncFlare( |
| 59 sync_start_util::GetFlareForSyncableService(profile_path)); | 62 sync_start_util::GetFlareForSyncableService(profile_path)); |
| 60 AutofillProfileSyncableService::CreateForWebDataServiceAndBackend( | 63 AutofillProfileSyncableService::CreateForWebDataServiceAndBackend( |
| 61 autofill_web_data.get(), autofill_backend, app_locale); | 64 autofill_web_data.get(), autofill_backend, app_locale); |
| 62 AutofillProfileSyncableService::FromWebDataService(autofill_web_data.get()) | 65 AutofillProfileSyncableService::FromWebDataService(autofill_web_data.get()) |
| 63 ->InjectStartSyncFlare( | 66 ->InjectStartSyncFlare( |
| 64 sync_start_util::GetFlareForSyncableService(profile_path)); | 67 sync_start_util::GetFlareForSyncableService(profile_path)); |
| 65 } | 68 } |
| 66 | 69 |
| 67 } // namespace | 70 } // namespace |
| 68 | 71 |
| 69 WebDataServiceWrapper::WebDataServiceWrapper() {} | 72 WebDataServiceWrapper::WebDataServiceWrapper() { |
| 73 } | |
| 70 | 74 |
| 71 WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile) { | 75 WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile) { |
| 72 base::FilePath profile_path = profile->GetPath(); | 76 base::FilePath profile_path = profile->GetPath(); |
| 73 base::FilePath path = profile_path.Append(kWebDataFilename); | 77 base::FilePath path = profile_path.Append(kWebDataFilename); |
| 74 | 78 |
| 75 scoped_refptr<base::MessageLoopProxy> ui_thread = | 79 scoped_refptr<base::MessageLoopProxy> ui_thread = |
| 76 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); | 80 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); |
| 77 scoped_refptr<base::MessageLoopProxy> db_thread = | 81 scoped_refptr<base::MessageLoopProxy> db_thread = |
| 78 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB); | 82 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB); |
| 79 web_database_ = new WebDatabaseService(path, ui_thread, db_thread); | 83 web_database_ = new WebDatabaseService(path, ui_thread, db_thread); |
| 80 | 84 |
| 81 // All tables objects that participate in managing the database must | 85 // All tables objects that participate in managing the database must |
| 82 // be added here. | 86 // be added here. |
| 83 web_database_->AddTable( | 87 web_database_->AddTable(scoped_ptr<WebDatabaseTable>( |
| 84 scoped_ptr<WebDatabaseTable>(new autofill::AutofillTable( | 88 new autofill::AutofillTable(g_browser_process->GetApplicationLocale()))); |
| 85 g_browser_process->GetApplicationLocale()))); | 89 web_database_->AddTable(scoped_ptr<WebDatabaseTable>(new KeywordTable())); |
| 86 web_database_->AddTable( | |
| 87 scoped_ptr<WebDatabaseTable>(new KeywordTable())); | |
| 88 // TODO(mdm): We only really need the LoginsTable on Windows for IE7 password | 90 // TODO(mdm): We only really need the LoginsTable on Windows for IE7 password |
| 89 // access, but for now, we still create it on all platforms since it deletes | 91 // access, but for now, we still create it on all platforms since it deletes |
| 90 // the old logins table. We can remove this after a while, e.g. in M22 or so. | 92 // the old logins table. We can remove this after a while, e.g. in M22 or so. |
| 91 web_database_->AddTable( | 93 web_database_->AddTable(scoped_ptr<WebDatabaseTable>(new LoginsTable())); |
| 92 scoped_ptr<WebDatabaseTable>(new LoginsTable())); | |
| 93 web_database_->AddTable( | 94 web_database_->AddTable( |
| 94 scoped_ptr<WebDatabaseTable>(new TokenServiceTable())); | 95 scoped_ptr<WebDatabaseTable>(new TokenServiceTable())); |
| 95 web_database_->AddTable( | 96 // TODO(caitkp): Add a migration to delete the SQL table used by |
| 96 scoped_ptr<WebDatabaseTable>(new WebAppsTable())); | 97 // WebIntentsTable, then remove this. |
| 98 web_database_->AddTable(scoped_ptr<WebDatabaseTable>(new WebAppsTable())); | |
| 97 // TODO(thakis): Add a migration to delete the SQL table used by | 99 // TODO(thakis): Add a migration to delete the SQL table used by |
| 98 // WebIntentsTable, then remove this. | 100 // WebIntentsTable, then remove this. |
| 99 web_database_->AddTable( | 101 web_database_->AddTable(scoped_ptr<WebDatabaseTable>(new WebIntentsTable())); |
| 100 scoped_ptr<WebDatabaseTable>(new WebIntentsTable())); | |
| 101 | 102 |
| 102 web_database_->LoadDatabase(); | 103 web_database_->LoadDatabase(); |
| 103 | 104 |
| 104 autofill_web_data_ = new AutofillWebDataService( | 105 autofill_web_data_ = new AutofillWebDataService( |
| 105 web_database_, ui_thread, db_thread, base::Bind( | 106 web_database_, |
| 106 &ProfileErrorCallback, PROFILE_ERROR_DB_AUTOFILL_WEB_DATA)); | 107 ui_thread, |
| 108 db_thread, | |
| 109 base::Bind(&ProfileErrorCallback, PROFILE_ERROR_DB_AUTOFILL_WEB_DATA)); | |
| 107 autofill_web_data_->Init(); | 110 autofill_web_data_->Init(); |
| 108 | 111 |
| 109 keyword_web_data_ = new KeywordWebDataService( | 112 keyword_web_data_ = new KeywordWebDataService( |
| 110 web_database_, ui_thread, base::Bind( | 113 web_database_, |
| 111 &ProfileErrorCallback, PROFILE_ERROR_DB_KEYWORD_WEB_DATA)); | 114 ui_thread, |
| 115 base::Bind(&ProfileErrorCallback, PROFILE_ERROR_DB_KEYWORD_WEB_DATA)); | |
| 112 keyword_web_data_->Init(); | 116 keyword_web_data_->Init(); |
| 113 | 117 |
| 114 token_web_data_ = new TokenWebData( | 118 token_web_data_ = new TokenWebData( |
| 115 web_database_, ui_thread, db_thread, base::Bind( | 119 web_database_, |
| 116 &ProfileErrorCallback, PROFILE_ERROR_DB_TOKEN_WEB_DATA)); | 120 ui_thread, |
| 121 db_thread, | |
| 122 base::Bind(&ProfileErrorCallback, PROFILE_ERROR_DB_TOKEN_WEB_DATA)); | |
| 117 token_web_data_->Init(); | 123 token_web_data_->Init(); |
| 118 | 124 |
| 119 web_data_ = new WebDataService( | 125 #if defined(OS_WIN) |
| 120 web_database_, base::Bind(&ProfileErrorCallback, | 126 password_web_data_ = new PasswordWebDataService( |
| 121 PROFILE_ERROR_DB_WEB_DATA)); | 127 web_database_, |
| 122 web_data_->Init(); | 128 base::Bind(&ProfileErrorCallback, PROFILE_ERROR_DB_WEB_DATA)); |
| 129 password_web_data_->Init(); | |
| 130 #endif | |
| 123 | 131 |
| 124 autofill_web_data_->GetAutofillBackend( | 132 autofill_web_data_->GetAutofillBackend( |
| 125 base::Bind(&InitSyncableServicesOnDBThread, | 133 base::Bind(&InitSyncableServicesOnDBThread, |
| 126 autofill_web_data_, | 134 autofill_web_data_, |
| 127 profile_path, | 135 profile_path, |
| 128 g_browser_process->GetApplicationLocale())); | 136 g_browser_process->GetApplicationLocale())); |
| 129 } | 137 } |
| 130 | 138 |
| 131 WebDataServiceWrapper::~WebDataServiceWrapper() { | 139 WebDataServiceWrapper::~WebDataServiceWrapper() { |
| 132 } | 140 } |
| 133 | 141 |
| 134 void WebDataServiceWrapper::Shutdown() { | 142 void WebDataServiceWrapper::Shutdown() { |
| 135 autofill_web_data_->ShutdownOnUIThread(); | 143 autofill_web_data_->ShutdownOnUIThread(); |
| 136 keyword_web_data_->ShutdownOnUIThread(); | 144 keyword_web_data_->ShutdownOnUIThread(); |
| 137 token_web_data_->ShutdownOnUIThread(); | 145 token_web_data_->ShutdownOnUIThread(); |
| 138 web_data_->ShutdownOnUIThread(); | 146 |
| 139 web_database_->ShutdownDatabase(); | 147 #if defined(OS_WIN) |
| 148 password_web_data_->ShutdownOnUIThread(); | |
| 149 #endif | |
| 150 web_database_->ShutdownDatabase(); | |
|
Peter Kasting
2014/07/07 23:20:03
Nit: Wrong indenting
Cait (Slow)
2014/07/09 15:23:16
Done.
| |
| 140 } | 151 } |
| 141 | 152 |
| 142 scoped_refptr<AutofillWebDataService> | 153 scoped_refptr<AutofillWebDataService> |
| 143 WebDataServiceWrapper::GetAutofillWebData() { | 154 WebDataServiceWrapper::GetAutofillWebData() { |
| 144 return autofill_web_data_.get(); | 155 return autofill_web_data_.get(); |
| 145 } | 156 } |
| 146 | 157 |
| 147 scoped_refptr<KeywordWebDataService> | 158 scoped_refptr<KeywordWebDataService> |
| 148 WebDataServiceWrapper::GetKeywordWebData() { | 159 WebDataServiceWrapper::GetKeywordWebData() { |
| 149 return keyword_web_data_.get(); | 160 return keyword_web_data_.get(); |
| 150 } | 161 } |
| 151 | 162 |
| 152 scoped_refptr<WebDataService> WebDataServiceWrapper::GetWebData() { | |
| 153 return web_data_.get(); | |
| 154 } | |
| 155 | |
| 156 scoped_refptr<TokenWebData> WebDataServiceWrapper::GetTokenWebData() { | 163 scoped_refptr<TokenWebData> WebDataServiceWrapper::GetTokenWebData() { |
| 157 return token_web_data_.get(); | 164 return token_web_data_.get(); |
| 158 } | 165 } |
| 159 | 166 |
| 160 // static | 167 #if defined(OS_WIN) |
| 161 scoped_refptr<WebDataService> WebDataService::FromBrowserContext( | 168 scoped_refptr<PasswordWebDataService> |
| 162 content::BrowserContext* context) { | 169 WebDataServiceWrapper::GetPasswordWebData() { |
| 163 // For this service, the implicit/explicit distinction doesn't | 170 return password_web_data_.get(); |
| 164 // really matter; it's just used for a DCHECK. So we currently | |
| 165 // cheat and always say EXPLICIT_ACCESS. | |
| 166 WebDataServiceWrapper* wrapper = | |
| 167 WebDataServiceFactory::GetForProfile( | |
| 168 static_cast<Profile*>(context), Profile::EXPLICIT_ACCESS); | |
| 169 if (wrapper) | |
| 170 return wrapper->GetWebData(); | |
| 171 // |wrapper| can be NULL in Incognito mode. | |
| 172 return scoped_refptr<WebDataService>(NULL); | |
| 173 } | 171 } |
| 172 #endif | |
| 174 | 173 |
| 175 WebDataServiceFactory::WebDataServiceFactory() | 174 WebDataServiceFactory::WebDataServiceFactory() |
| 176 : BrowserContextKeyedServiceFactory( | 175 : BrowserContextKeyedServiceFactory( |
| 177 "WebDataService", | 176 "WebDataService", |
| 178 BrowserContextDependencyManager::GetInstance()) { | 177 BrowserContextDependencyManager::GetInstance()) { |
| 179 // WebDataServiceFactory has no dependecies. | 178 // WebDataServiceFactory has no dependecies. |
| 180 } | 179 } |
| 181 | 180 |
| 182 WebDataServiceFactory::~WebDataServiceFactory() {} | 181 WebDataServiceFactory::~WebDataServiceFactory() { |
| 182 } | |
| 183 | 183 |
| 184 // static | 184 // static |
| 185 WebDataServiceWrapper* WebDataServiceFactory::GetForProfile( | 185 WebDataServiceWrapper* WebDataServiceFactory::GetForProfile( |
| 186 Profile* profile, | 186 Profile* profile, |
| 187 Profile::ServiceAccessType access_type) { | 187 Profile::ServiceAccessType access_type) { |
| 188 // If |access_type| starts being used for anything other than this | 188 // If |access_type| starts being used for anything other than this |
| 189 // DCHECK, we need to start taking it as a parameter to | 189 // DCHECK, we need to start taking it as a parameter to |
| 190 // the *WebDataService::FromBrowserContext() functions (see above). | 190 // the *WebDataService::FromBrowserContext() functions (see above). |
| 191 DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord()); | 191 DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord()); |
| 192 return static_cast<WebDataServiceWrapper*>( | 192 return static_cast<WebDataServiceWrapper*>( |
| 193 GetInstance()->GetServiceForBrowserContext(profile, true)); | 193 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 194 } | 194 } |
| 195 | 195 |
| 196 // static | 196 // static |
| 197 WebDataServiceWrapper* WebDataServiceFactory::GetForProfileIfExists( | 197 WebDataServiceWrapper* WebDataServiceFactory::GetForProfileIfExists( |
| 198 Profile* profile, | 198 Profile* profile, |
| 199 Profile::ServiceAccessType access_type) { | 199 Profile::ServiceAccessType access_type) { |
| 200 // If |access_type| starts being used for anything other than this | 200 // If |access_type| starts being used for anything other than this |
| 201 // DCHECK, we need to start taking it as a parameter to | 201 // DCHECK, we need to start taking it as a parameter to |
| 202 // the *WebDataService::FromBrowserContext() functions (see above). | 202 // the *WebDataService::FromBrowserContext() functions (see above). |
| 203 DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord()); | 203 DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord()); |
| 204 return static_cast<WebDataServiceWrapper*>( | 204 return static_cast<WebDataServiceWrapper*>( |
| 205 GetInstance()->GetServiceForBrowserContext(profile, false)); | 205 GetInstance()->GetServiceForBrowserContext(profile, false)); |
| 206 } | 206 } |
| 207 | 207 |
| 208 // static | 208 // static |
| 209 scoped_refptr<AutofillWebDataService> | 209 scoped_refptr<AutofillWebDataService> |
| 210 WebDataServiceFactory::GetAutofillWebDataForProfile( | 210 WebDataServiceFactory::GetAutofillWebDataForProfile( |
| 211 Profile* profile, | 211 Profile* profile, |
| 212 Profile::ServiceAccessType access_type) { | 212 Profile::ServiceAccessType access_type) { |
| 213 WebDataServiceWrapper* wrapper = | 213 WebDataServiceWrapper* wrapper = |
| 214 WebDataServiceFactory::GetForProfile(profile, access_type); | 214 WebDataServiceFactory::GetForProfile(profile, access_type); |
| 215 // |wrapper| can be NULL in Incognito mode. | 215 // |wrapper| can be NULL in Incognito mode. |
| 216 return wrapper ? | 216 return wrapper ? wrapper->GetAutofillWebData() |
| 217 wrapper->GetAutofillWebData() : | 217 : scoped_refptr<AutofillWebDataService>(NULL); |
| 218 scoped_refptr<AutofillWebDataService>(NULL); | |
| 219 } | 218 } |
| 220 | 219 |
| 221 // static | 220 // static |
| 222 scoped_refptr<KeywordWebDataService> | 221 scoped_refptr<KeywordWebDataService> |
| 223 WebDataServiceFactory::GetKeywordWebDataForProfile( | 222 WebDataServiceFactory::GetKeywordWebDataForProfile( |
| 224 Profile* profile, | 223 Profile* profile, |
| 225 Profile::ServiceAccessType access_type) { | 224 Profile::ServiceAccessType access_type) { |
| 226 WebDataServiceWrapper* wrapper = | 225 WebDataServiceWrapper* wrapper = |
| 227 WebDataServiceFactory::GetForProfile(profile, access_type); | 226 WebDataServiceFactory::GetForProfile(profile, access_type); |
| 228 // |wrapper| can be NULL in Incognito mode. | 227 // |wrapper| can be NULL in Incognito mode. |
| 229 return wrapper ? | 228 return wrapper ? wrapper->GetKeywordWebData() |
| 230 wrapper->GetKeywordWebData() : scoped_refptr<KeywordWebDataService>(NULL); | 229 : scoped_refptr<KeywordWebDataService>(NULL); |
| 231 } | 230 } |
| 232 | 231 |
| 233 // static | 232 // static |
| 234 scoped_refptr<TokenWebData> | 233 scoped_refptr<TokenWebData> WebDataServiceFactory::GetTokenWebDataForProfile( |
| 235 WebDataServiceFactory::GetTokenWebDataForProfile( | |
| 236 Profile* profile, | 234 Profile* profile, |
| 237 Profile::ServiceAccessType access_type) { | 235 Profile::ServiceAccessType access_type) { |
| 238 WebDataServiceWrapper* wrapper = | 236 WebDataServiceWrapper* wrapper = |
| 239 WebDataServiceFactory::GetForProfile(profile, access_type); | 237 WebDataServiceFactory::GetForProfile(profile, access_type); |
| 240 // |wrapper| can be NULL in Incognito mode. | 238 // |wrapper| can be NULL in Incognito mode. |
| 241 return wrapper ? wrapper->GetTokenWebData() | 239 return wrapper ? wrapper->GetTokenWebData() |
| 242 : scoped_refptr<TokenWebData>(NULL); | 240 : scoped_refptr<TokenWebData>(NULL); |
| 243 } | 241 } |
| 244 | 242 |
| 243 #if defined(OS_WIN) | |
| 244 // static | |
| 245 scoped_refptr<PasswordWebDataService> | |
| 246 WebDataServiceFactory::GetPasswordWebDataForProfile( | |
| 247 Profile* profile, | |
| 248 Profile::ServiceAccessType access_type) { | |
| 249 WebDataServiceWrapper* wrapper = | |
| 250 WebDataServiceFactory::GetForProfile(profile, access_type); | |
| 251 if (wrapper) | |
| 252 return wrapper->GetPasswordWebData(); | |
| 253 // |wrapper| can be NULL in Incognito mode. | |
|
Peter Kasting
2014/07/07 23:20:03
Nit: I'd move this comment either to the top of th
Cait (Slow)
2014/07/09 15:23:16
Done.
| |
| 254 return scoped_refptr<PasswordWebDataService>(NULL); | |
|
Peter Kasting
2014/07/07 23:20:03
Nit: Could also be this, though the two forms aren
Cait (Slow)
2014/07/09 15:23:16
Done.
| |
| 255 } | |
| 256 #endif | |
| 257 | |
| 245 // static | 258 // static |
| 246 WebDataServiceFactory* WebDataServiceFactory::GetInstance() { | 259 WebDataServiceFactory* WebDataServiceFactory::GetInstance() { |
| 247 return Singleton<WebDataServiceFactory>::get(); | 260 return Singleton<WebDataServiceFactory>::get(); |
| 248 } | 261 } |
| 249 | 262 |
| 250 content::BrowserContext* WebDataServiceFactory::GetBrowserContextToUse( | 263 content::BrowserContext* WebDataServiceFactory::GetBrowserContextToUse( |
| 251 content::BrowserContext* context) const { | 264 content::BrowserContext* context) const { |
| 252 return chrome::GetBrowserContextRedirectedInIncognito(context); | 265 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 253 } | 266 } |
| 254 | 267 |
| 255 KeyedService* WebDataServiceFactory::BuildServiceInstanceFor( | 268 KeyedService* WebDataServiceFactory::BuildServiceInstanceFor( |
| 256 content::BrowserContext* profile) const { | 269 content::BrowserContext* profile) const { |
| 257 return new WebDataServiceWrapper(static_cast<Profile*>(profile)); | 270 return new WebDataServiceWrapper(static_cast<Profile*>(profile)); |
| 258 } | 271 } |
| 259 | 272 |
| 260 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const { | 273 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const { |
| 261 return true; | 274 return true; |
| 262 } | 275 } |
| OLD | NEW |