| 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/profiles/profile_impl.h" | 5 #include "chrome/browser/profiles/profile_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/environment.h" | 10 #include "base/environment.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 #include "chrome/browser/profiles/profile_info_cache.h" | 68 #include "chrome/browser/profiles/profile_info_cache.h" |
| 69 #include "chrome/browser/profiles/profile_manager.h" | 69 #include "chrome/browser/profiles/profile_manager.h" |
| 70 #include "chrome/browser/search_engines/template_url_fetcher.h" | 70 #include "chrome/browser/search_engines/template_url_fetcher.h" |
| 71 #include "chrome/browser/search_engines/template_url_service.h" | 71 #include "chrome/browser/search_engines/template_url_service.h" |
| 72 #include "chrome/browser/sessions/session_service_factory.h" | 72 #include "chrome/browser/sessions/session_service_factory.h" |
| 73 #include "chrome/browser/signin/signin_manager.h" | 73 #include "chrome/browser/signin/signin_manager.h" |
| 74 #include "chrome/browser/signin/token_service.h" | 74 #include "chrome/browser/signin/token_service.h" |
| 75 #include "chrome/browser/speech/chrome_speech_input_manager.h" | 75 #include "chrome/browser/speech/chrome_speech_input_manager.h" |
| 76 #include "chrome/browser/speech/chrome_speech_input_preferences.h" | 76 #include "chrome/browser/speech/chrome_speech_input_preferences.h" |
| 77 #include "chrome/browser/spellchecker/spellcheck_profile.h" | 77 #include "chrome/browser/spellchecker/spellcheck_profile.h" |
| 78 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" | 78 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 79 #include "chrome/browser/sync/profile_sync_service.h" | |
| 80 #include "chrome/browser/tabs/pinned_tab_service_factory.h" | 79 #include "chrome/browser/tabs/pinned_tab_service_factory.h" |
| 81 #include "chrome/browser/transport_security_persister.h" | 80 #include "chrome/browser/transport_security_persister.h" |
| 82 #include "chrome/browser/ui/browser_init.h" | 81 #include "chrome/browser/ui/browser_init.h" |
| 83 #include "chrome/browser/ui/browser_list.h" | 82 #include "chrome/browser/ui/browser_list.h" |
| 84 #include "chrome/browser/ui/find_bar/find_bar_state.h" | 83 #include "chrome/browser/ui/find_bar/find_bar_state.h" |
| 85 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 84 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 86 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 85 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| 87 #include "chrome/browser/user_style_sheet_watcher.h" | 86 #include "chrome/browser/user_style_sheet_watcher.h" |
| 88 #include "chrome/browser/visitedlink/visitedlink_event_listener.h" | 87 #include "chrome/browser/visitedlink/visitedlink_event_listener.h" |
| 89 #include "chrome/browser/visitedlink/visitedlink_master.h" | 88 #include "chrome/browser/visitedlink/visitedlink_master.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 | 245 |
| 247 ProfileImpl::ProfileImpl(const FilePath& path, | 246 ProfileImpl::ProfileImpl(const FilePath& path, |
| 248 Profile::Delegate* delegate) | 247 Profile::Delegate* delegate) |
| 249 : path_(path), | 248 : path_(path), |
| 250 ALLOW_THIS_IN_INITIALIZER_LIST(visited_link_event_listener_( | 249 ALLOW_THIS_IN_INITIALIZER_LIST(visited_link_event_listener_( |
| 251 new VisitedLinkEventListener(this))), | 250 new VisitedLinkEventListener(this))), |
| 252 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), | 251 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), |
| 253 extension_devtools_manager_(NULL), | 252 extension_devtools_manager_(NULL), |
| 254 host_content_settings_map_(NULL), | 253 host_content_settings_map_(NULL), |
| 255 host_zoom_map_(NULL), | 254 host_zoom_map_(NULL), |
| 256 profile_sync_service_created_(false), | |
| 257 history_service_created_(false), | 255 history_service_created_(false), |
| 258 favicon_service_created_(false), | 256 favicon_service_created_(false), |
| 259 created_web_data_service_(false), | 257 created_web_data_service_(false), |
| 260 created_password_store_(false), | 258 created_password_store_(false), |
| 261 start_time_(Time::Now()), | 259 start_time_(Time::Now()), |
| 262 #if defined(OS_WIN) | 260 #if defined(OS_WIN) |
| 263 checked_instant_promo_(false), | 261 checked_instant_promo_(false), |
| 264 #endif | 262 #endif |
| 265 delegate_(delegate), | 263 delegate_(delegate), |
| 266 predictor_(NULL), | 264 predictor_(NULL), |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 BrowserThread::IO, FROM_HERE, | 563 BrowserThread::IO, FROM_HERE, |
| 566 base::Bind(&appcache::AppCacheService::set_clear_local_state_on_exit, | 564 base::Bind(&appcache::AppCacheService::set_clear_local_state_on_exit, |
| 567 appcache_service_.get(), true)); | 565 appcache_service_.get(), true)); |
| 568 } | 566 } |
| 569 | 567 |
| 570 StopCreateSessionServiceTimer(); | 568 StopCreateSessionServiceTimer(); |
| 571 | 569 |
| 572 // Remove pref observers | 570 // Remove pref observers |
| 573 pref_change_registrar_.RemoveAll(); | 571 pref_change_registrar_.RemoveAll(); |
| 574 | 572 |
| 575 // The sync service needs to be deleted before the services it calls. | |
| 576 // TODO(stevet): Make ProfileSyncService into a PKS and let the PDM take care | |
| 577 // of the cleanup below. | |
| 578 sync_service_.reset(); | |
| 579 | |
| 580 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( | 573 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( |
| 581 &io_data_.GetResourceContextNoInit()); | 574 &io_data_.GetResourceContextNoInit()); |
| 582 | 575 |
| 583 if (io_data_.HasMainRequestContext() && | 576 if (io_data_.HasMainRequestContext() && |
| 584 default_request_context_ == GetRequestContext()) { | 577 default_request_context_ == GetRequestContext()) { |
| 585 default_request_context_ = NULL; | 578 default_request_context_ = NULL; |
| 586 } | 579 } |
| 587 | 580 |
| 588 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); | 581 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); |
| 589 | 582 |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1164 fileapi::FileSystemContext* ProfileImpl::GetFileSystemContext() { | 1157 fileapi::FileSystemContext* ProfileImpl::GetFileSystemContext() { |
| 1165 CreateQuotaManagerAndClients(); | 1158 CreateQuotaManagerAndClients(); |
| 1166 return file_system_context_.get(); | 1159 return file_system_context_.get(); |
| 1167 } | 1160 } |
| 1168 | 1161 |
| 1169 quota::QuotaManager* ProfileImpl::GetQuotaManager() { | 1162 quota::QuotaManager* ProfileImpl::GetQuotaManager() { |
| 1170 CreateQuotaManagerAndClients(); | 1163 CreateQuotaManagerAndClients(); |
| 1171 return quota_manager_.get(); | 1164 return quota_manager_.get(); |
| 1172 } | 1165 } |
| 1173 | 1166 |
| 1174 bool ProfileImpl::HasProfileSyncService() const { | 1167 bool ProfileImpl::HasProfileSyncService() { |
| 1175 return (sync_service_.get() != NULL); | 1168 return ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService(this); |
| 1176 } | 1169 } |
| 1177 | 1170 |
| 1178 bool ProfileImpl::DidLastSessionExitCleanly() { | 1171 bool ProfileImpl::DidLastSessionExitCleanly() { |
| 1179 // last_session_exited_cleanly_ is set when the preferences are loaded. Force | 1172 // last_session_exited_cleanly_ is set when the preferences are loaded. Force |
| 1180 // it to be set by asking for the prefs. | 1173 // it to be set by asking for the prefs. |
| 1181 GetPrefs(); | 1174 GetPrefs(); |
| 1182 return last_session_exited_cleanly_; | 1175 return last_session_exited_cleanly_; |
| 1183 } | 1176 } |
| 1184 | 1177 |
| 1185 BookmarkModel* ProfileImpl::GetBookmarkModel() { | 1178 BookmarkModel* ProfileImpl::GetBookmarkModel() { |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1410 } | 1403 } |
| 1411 | 1404 |
| 1412 TokenService* ProfileImpl::GetTokenService() { | 1405 TokenService* ProfileImpl::GetTokenService() { |
| 1413 if (!token_service_.get()) { | 1406 if (!token_service_.get()) { |
| 1414 token_service_.reset(new TokenService()); | 1407 token_service_.reset(new TokenService()); |
| 1415 } | 1408 } |
| 1416 return token_service_.get(); | 1409 return token_service_.get(); |
| 1417 } | 1410 } |
| 1418 | 1411 |
| 1419 ProfileSyncService* ProfileImpl::GetProfileSyncService() { | 1412 ProfileSyncService* ProfileImpl::GetProfileSyncService() { |
| 1420 if (!ProfileSyncService::IsSyncEnabled()) | 1413 return ProfileSyncServiceFactory::GetInstance()->GetForProfile(this); |
| 1421 return NULL; | |
| 1422 if (!profile_sync_service_created_) { | |
| 1423 profile_sync_service_created_ = true; | |
| 1424 InitSyncService(); | |
| 1425 } | |
| 1426 return sync_service_.get(); | |
| 1427 } | |
| 1428 | |
| 1429 void ProfileImpl::InitSyncService() { | |
| 1430 profile_sync_factory_.reset( | |
| 1431 new ProfileSyncComponentsFactoryImpl(this, | |
| 1432 CommandLine::ForCurrentProcess())); | |
| 1433 sync_service_.reset(profile_sync_factory_->CreateProfileSyncService()); | |
| 1434 profile_sync_factory_->RegisterDataTypes(sync_service_.get()); | |
| 1435 sync_service_->Initialize(); | |
| 1436 } | 1414 } |
| 1437 | 1415 |
| 1438 ChromeBlobStorageContext* ProfileImpl::GetBlobStorageContext() { | 1416 ChromeBlobStorageContext* ProfileImpl::GetBlobStorageContext() { |
| 1439 if (!blob_storage_context_) { | 1417 if (!blob_storage_context_) { |
| 1440 blob_storage_context_ = new ChromeBlobStorageContext(); | 1418 blob_storage_context_ = new ChromeBlobStorageContext(); |
| 1441 BrowserThread::PostTask( | 1419 BrowserThread::PostTask( |
| 1442 BrowserThread::IO, FROM_HERE, | 1420 BrowserThread::IO, FROM_HERE, |
| 1443 base::Bind(&ChromeBlobStorageContext::InitializeOnIOThread, | 1421 base::Bind(&ChromeBlobStorageContext::InitializeOnIOThread, |
| 1444 blob_storage_context_.get())); | 1422 blob_storage_context_.get())); |
| 1445 } | 1423 } |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1679 FilePath* cache_path, | 1657 FilePath* cache_path, |
| 1680 int* max_size) { | 1658 int* max_size) { |
| 1681 DCHECK(cache_path); | 1659 DCHECK(cache_path); |
| 1682 DCHECK(max_size); | 1660 DCHECK(max_size); |
| 1683 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); | 1661 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); |
| 1684 if (!path.empty()) | 1662 if (!path.empty()) |
| 1685 *cache_path = path; | 1663 *cache_path = path; |
| 1686 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : | 1664 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : |
| 1687 prefs_->GetInteger(prefs::kDiskCacheSize); | 1665 prefs_->GetInteger(prefs::kDiskCacheSize); |
| 1688 } | 1666 } |
| OLD | NEW |