| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 #include "chrome/browser/profiles/gaia_info_update_service.h" | 58 #include "chrome/browser/profiles/gaia_info_update_service.h" |
| 59 #include "chrome/browser/profiles/profile_dependency_manager.h" | 59 #include "chrome/browser/profiles/profile_dependency_manager.h" |
| 60 #include "chrome/browser/profiles/profile_info_cache.h" | 60 #include "chrome/browser/profiles/profile_info_cache.h" |
| 61 #include "chrome/browser/profiles/profile_manager.h" | 61 #include "chrome/browser/profiles/profile_manager.h" |
| 62 #include "chrome/browser/search_engines/template_url_fetcher.h" | 62 #include "chrome/browser/search_engines/template_url_fetcher.h" |
| 63 #include "chrome/browser/sessions/session_service_factory.h" | 63 #include "chrome/browser/sessions/session_service_factory.h" |
| 64 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h" | 64 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h" |
| 65 #include "chrome/browser/sync/profile_sync_service_factory.h" | 65 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 66 #include "chrome/browser/ui/browser_init.h" | 66 #include "chrome/browser/ui/browser_init.h" |
| 67 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 67 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| 68 #include "chrome/browser/usb/usb_service.h" |
| 68 #include "chrome/browser/user_style_sheet_watcher.h" | 69 #include "chrome/browser/user_style_sheet_watcher.h" |
| 69 #include "chrome/browser/visitedlink/visitedlink_event_listener.h" | 70 #include "chrome/browser/visitedlink/visitedlink_event_listener.h" |
| 70 #include "chrome/browser/visitedlink/visitedlink_master.h" | 71 #include "chrome/browser/visitedlink/visitedlink_master.h" |
| 71 #include "chrome/browser/web_resource/promo_resource_service.h" | 72 #include "chrome/browser/web_resource/promo_resource_service.h" |
| 72 #include "chrome/browser/webdata/web_data_service.h" | 73 #include "chrome/browser/webdata/web_data_service.h" |
| 73 #include "chrome/common/chrome_constants.h" | 74 #include "chrome/common/chrome_constants.h" |
| 74 #include "chrome/common/chrome_notification_types.h" | 75 #include "chrome/common/chrome_notification_types.h" |
| 75 #include "chrome/common/chrome_paths_internal.h" | 76 #include "chrome/common/chrome_paths_internal.h" |
| 76 #include "chrome/common/chrome_switches.h" | 77 #include "chrome/common/chrome_switches.h" |
| 77 #include "chrome/common/chrome_version_info.h" | 78 #include "chrome/common/chrome_version_info.h" |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 // HistoryService will join with HistoryService's backend thread so that | 523 // HistoryService will join with HistoryService's backend thread so that |
| 523 // by the time the destructor has finished we're sure it will no longer call | 524 // by the time the destructor has finished we're sure it will no longer call |
| 524 // into the BookmarkModel. | 525 // into the BookmarkModel. |
| 525 history_service_ = NULL; | 526 history_service_ = NULL; |
| 526 bookmark_bar_model_.reset(); | 527 bookmark_bar_model_.reset(); |
| 527 | 528 |
| 528 // FaviconService depends on HistoryServce so make sure we delete | 529 // FaviconService depends on HistoryServce so make sure we delete |
| 529 // HistoryService first. | 530 // HistoryService first. |
| 530 favicon_service_.reset(); | 531 favicon_service_.reset(); |
| 531 | 532 |
| 533 if (usb_service_.get()) |
| 534 usb_service_->Cleanup(); |
| 535 usb_service_.reset(NULL); |
| 536 |
| 532 if (pref_proxy_config_tracker_.get()) | 537 if (pref_proxy_config_tracker_.get()) |
| 533 pref_proxy_config_tracker_->DetachFromPrefService(); | 538 pref_proxy_config_tracker_->DetachFromPrefService(); |
| 534 | 539 |
| 535 if (protocol_handler_registry_) | 540 if (protocol_handler_registry_) |
| 536 protocol_handler_registry_->Finalize(); | 541 protocol_handler_registry_->Finalize(); |
| 537 | 542 |
| 538 if (host_content_settings_map_) | 543 if (host_content_settings_map_) |
| 539 host_content_settings_map_->ShutdownOnUIThread(); | 544 host_content_settings_map_->ShutdownOnUIThread(); |
| 540 | 545 |
| 541 // This causes the Preferences file to be written to disk. | 546 // This causes the Preferences file to be written to disk. |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 ChromeVersionService::OnProfileLoaded(prefs_.get(), is_new_profile); | 661 ChromeVersionService::OnProfileLoaded(prefs_.get(), is_new_profile); |
| 657 DoFinalInit(is_new_profile); | 662 DoFinalInit(is_new_profile); |
| 658 } | 663 } |
| 659 | 664 |
| 660 bool ProfileImpl::WasCreatedByVersionOrLater(const std::string& version) { | 665 bool ProfileImpl::WasCreatedByVersionOrLater(const std::string& version) { |
| 661 Version profile_version(ChromeVersionService::GetVersion(prefs_.get())); | 666 Version profile_version(ChromeVersionService::GetVersion(prefs_.get())); |
| 662 Version arg_version(version); | 667 Version arg_version(version); |
| 663 return (profile_version.CompareTo(arg_version) >= 0); | 668 return (profile_version.CompareTo(arg_version) >= 0); |
| 664 } | 669 } |
| 665 | 670 |
| 671 UsbService* ProfileImpl::GetUsbService() { |
| 672 if (!usb_service_.get()) { |
| 673 usb_service_.reset(new UsbService()); |
| 674 } |
| 675 return usb_service_.get(); |
| 676 } |
| 677 |
| 666 PrefService* ProfileImpl::GetPrefs() { | 678 PrefService* ProfileImpl::GetPrefs() { |
| 667 DCHECK(prefs_.get()); // Should explicitly be initialized. | 679 DCHECK(prefs_.get()); // Should explicitly be initialized. |
| 668 return prefs_.get(); | 680 return prefs_.get(); |
| 669 } | 681 } |
| 670 | 682 |
| 671 PrefService* ProfileImpl::GetOffTheRecordPrefs() { | 683 PrefService* ProfileImpl::GetOffTheRecordPrefs() { |
| 672 if (!otr_prefs_.get()) { | 684 if (!otr_prefs_.get()) { |
| 673 // The new ExtensionPrefStore is ref_counted and the new PrefService | 685 // The new ExtensionPrefStore is ref_counted and the new PrefService |
| 674 // stores a reference so that we do not leak memory here. | 686 // stores a reference so that we do not leak memory here. |
| 675 otr_prefs_.reset(GetPrefs()->CreateIncognitoPrefService( | 687 otr_prefs_.reset(GetPrefs()->CreateIncognitoPrefService( |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 if (!path.empty()) | 1170 if (!path.empty()) |
| 1159 *cache_path = path; | 1171 *cache_path = path; |
| 1160 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : | 1172 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : |
| 1161 prefs_->GetInteger(prefs::kDiskCacheSize); | 1173 prefs_->GetInteger(prefs::kDiskCacheSize); |
| 1162 } | 1174 } |
| 1163 | 1175 |
| 1164 base::Callback<ChromeURLDataManagerBackend*(void)> | 1176 base::Callback<ChromeURLDataManagerBackend*(void)> |
| 1165 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { | 1177 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { |
| 1166 return io_data_.GetChromeURLDataManagerBackendGetter(); | 1178 return io_data_.GetChromeURLDataManagerBackendGetter(); |
| 1167 } | 1179 } |
| OLD | NEW |