| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/environment.h" | 9 #include "base/environment.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
| 15 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "chrome/browser/appcache/chrome_appcache_service.h" | 17 #include "chrome/browser/appcache/chrome_appcache_service.h" |
| 18 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 18 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
| 19 #include "chrome/browser/autofill/personal_data_manager.h" | 19 #include "chrome/browser/autofill/personal_data_manager.h" |
| 20 #include "chrome/browser/background_contents_service.h" | 20 #include "chrome/browser/background_contents_service.h" |
| 21 #include "chrome/browser/background_mode_manager.h" | 21 #include "chrome/browser/background_mode_manager.h" |
| 22 #include "chrome/browser/bookmarks/bookmark_model.h" | 22 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 23 #include "chrome/browser/browser_list.h" | 23 #include "chrome/browser/browser_list.h" |
| 24 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
| 25 #include "chrome/browser/browser_signin.h" | 25 #include "chrome/browser/browser_signin.h" |
| 26 #include "chrome/browser/browser_thread.h" | 26 #include "chrome/browser/browser_thread.h" |
| 27 #include "chrome/browser/chrome_blob_storage_context.h" | 27 #include "chrome/browser/chrome_blob_storage_context.h" |
| 28 #include "chrome/browser/content_settings/host_content_settings_map.h" | 28 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 29 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 29 #include "chrome/browser/defaults.h" | 30 #include "chrome/browser/defaults.h" |
| 30 #include "chrome/browser/dom_ui/ntp_resource_cache.h" | 31 #include "chrome/browser/dom_ui/ntp_resource_cache.h" |
| 31 #include "chrome/browser/download/download_manager.h" | 32 #include "chrome/browser/download/download_manager.h" |
| 32 #include "chrome/browser/extensions/default_apps.h" | 33 #include "chrome/browser/extensions/default_apps.h" |
| 33 #include "chrome/browser/extensions/extension_devtools_manager.h" | 34 #include "chrome/browser/extensions/extension_devtools_manager.h" |
| 34 #include "chrome/browser/extensions/extension_error_reporter.h" | 35 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 35 #include "chrome/browser/extensions/extension_event_router.h" | 36 #include "chrome/browser/extensions/extension_event_router.h" |
| 36 #include "chrome/browser/extensions/extension_info_map.h" | 37 #include "chrome/browser/extensions/extension_info_map.h" |
| 37 #include "chrome/browser/extensions/extension_io_event_router.h" | 38 #include "chrome/browser/extensions/extension_io_event_router.h" |
| 38 #include "chrome/browser/extensions/extension_message_service.h" | 39 #include "chrome/browser/extensions/extension_message_service.h" |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 background_mode_manager_.reset(new BackgroundModeManager(this, | 307 background_mode_manager_.reset(new BackgroundModeManager(this, |
| 307 CommandLine::ForCurrentProcess())); | 308 CommandLine::ForCurrentProcess())); |
| 308 #endif | 309 #endif |
| 309 | 310 |
| 310 background_contents_service_.reset( | 311 background_contents_service_.reset( |
| 311 new BackgroundContentsService(this, CommandLine::ForCurrentProcess())); | 312 new BackgroundContentsService(this, CommandLine::ForCurrentProcess())); |
| 312 | 313 |
| 313 extension_io_event_router_ = new ExtensionIOEventRouter(this); | 314 extension_io_event_router_ = new ExtensionIOEventRouter(this); |
| 314 extension_info_map_ = new ExtensionInfoMap(); | 315 extension_info_map_ = new ExtensionInfoMap(); |
| 315 | 316 |
| 317 InitRegisteredProtocolHandlers(); |
| 318 |
| 316 clear_local_state_on_exit_ = prefs->GetBoolean(prefs::kClearSiteDataOnExit); | 319 clear_local_state_on_exit_ = prefs->GetBoolean(prefs::kClearSiteDataOnExit); |
| 317 | 320 |
| 318 // Log the profile size after a reasonable startup delay. | 321 // Log the profile size after a reasonable startup delay. |
| 319 BrowserThread::PostDelayedTask(BrowserThread::FILE, FROM_HERE, | 322 BrowserThread::PostDelayedTask(BrowserThread::FILE, FROM_HERE, |
| 320 new ProfileSizeTask(path_), 112000); | 323 new ProfileSizeTask(path_), 112000); |
| 321 | 324 |
| 322 InstantController::RecordMetrics(this); | 325 InstantController::RecordMetrics(this); |
| 323 | 326 |
| 324 FilePath cookie_path = GetPath(); | 327 FilePath cookie_path = GetPath(); |
| 325 cookie_path = cookie_path.Append(chrome::kCookieFilename); | 328 cookie_path = cookie_path.Append(chrome::kCookieFilename); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 } | 485 } |
| 483 | 486 |
| 484 void ProfileImpl::InitPromoResources() { | 487 void ProfileImpl::InitPromoResources() { |
| 485 if (promo_resource_service_) | 488 if (promo_resource_service_) |
| 486 return; | 489 return; |
| 487 | 490 |
| 488 promo_resource_service_ = new PromoResourceService(this); | 491 promo_resource_service_ = new PromoResourceService(this); |
| 489 promo_resource_service_->StartAfterDelay(); | 492 promo_resource_service_->StartAfterDelay(); |
| 490 } | 493 } |
| 491 | 494 |
| 495 void ProfileImpl::InitRegisteredProtocolHandlers() { |
| 496 if (protocol_handler_registry_) |
| 497 return; |
| 498 protocol_handler_registry_ = new ProtocolHandlerRegistry(this); |
| 499 protocol_handler_registry_->Load(); |
| 500 } |
| 501 |
| 492 NTPResourceCache* ProfileImpl::GetNTPResourceCache() { | 502 NTPResourceCache* ProfileImpl::GetNTPResourceCache() { |
| 493 if (!ntp_resource_cache_.get()) | 503 if (!ntp_resource_cache_.get()) |
| 494 ntp_resource_cache_.reset(new NTPResourceCache(this)); | 504 ntp_resource_cache_.reset(new NTPResourceCache(this)); |
| 495 return ntp_resource_cache_.get(); | 505 return ntp_resource_cache_.get(); |
| 496 } | 506 } |
| 497 | 507 |
| 498 FilePath ProfileImpl::last_selected_directory() { | 508 FilePath ProfileImpl::last_selected_directory() { |
| 499 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); | 509 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); |
| 500 } | 510 } |
| 501 | 511 |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 } | 1148 } |
| 1139 | 1149 |
| 1140 BookmarkModel* ProfileImpl::GetBookmarkModel() { | 1150 BookmarkModel* ProfileImpl::GetBookmarkModel() { |
| 1141 if (!bookmark_bar_model_.get()) { | 1151 if (!bookmark_bar_model_.get()) { |
| 1142 bookmark_bar_model_.reset(new BookmarkModel(this)); | 1152 bookmark_bar_model_.reset(new BookmarkModel(this)); |
| 1143 bookmark_bar_model_->Load(); | 1153 bookmark_bar_model_->Load(); |
| 1144 } | 1154 } |
| 1145 return bookmark_bar_model_.get(); | 1155 return bookmark_bar_model_.get(); |
| 1146 } | 1156 } |
| 1147 | 1157 |
| 1158 ProtocolHandlerRegistry* ProfileImpl::GetProtocolHandlerRegistry() { |
| 1159 return protocol_handler_registry_.get(); |
| 1160 } |
| 1161 |
| 1148 bool ProfileImpl::IsSameProfile(Profile* profile) { | 1162 bool ProfileImpl::IsSameProfile(Profile* profile) { |
| 1149 if (profile == static_cast<Profile*>(this)) | 1163 if (profile == static_cast<Profile*>(this)) |
| 1150 return true; | 1164 return true; |
| 1151 Profile* otr_profile = off_the_record_profile_.get(); | 1165 Profile* otr_profile = off_the_record_profile_.get(); |
| 1152 return otr_profile && profile == otr_profile; | 1166 return otr_profile && profile == otr_profile; |
| 1153 } | 1167 } |
| 1154 | 1168 |
| 1155 Time ProfileImpl::GetStartTime() const { | 1169 Time ProfileImpl::GetStartTime() const { |
| 1156 return start_time_; | 1170 return start_time_; |
| 1157 } | 1171 } |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 return pref_proxy_config_tracker_; | 1518 return pref_proxy_config_tracker_; |
| 1505 } | 1519 } |
| 1506 | 1520 |
| 1507 prerender::PrerenderManager* ProfileImpl::GetPrerenderManager() { | 1521 prerender::PrerenderManager* ProfileImpl::GetPrerenderManager() { |
| 1508 if (!prerender::PrerenderManager::IsPrerenderingEnabled()) | 1522 if (!prerender::PrerenderManager::IsPrerenderingEnabled()) |
| 1509 return NULL; | 1523 return NULL; |
| 1510 if (!prerender_manager_) | 1524 if (!prerender_manager_) |
| 1511 prerender_manager_ = new prerender::PrerenderManager(this); | 1525 prerender_manager_ = new prerender::PrerenderManager(this); |
| 1512 return prerender_manager_; | 1526 return prerender_manager_; |
| 1513 } | 1527 } |
| OLD | NEW |