| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/profile.h" | 5 #include "chrome/browser/profile.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 SSLHostState* ProfileImpl::GetSSLHostState() { | 566 SSLHostState* ProfileImpl::GetSSLHostState() { |
| 567 if (!ssl_host_state_.get()) | 567 if (!ssl_host_state_.get()) |
| 568 ssl_host_state_.reset(new SSLHostState()); | 568 ssl_host_state_.reset(new SSLHostState()); |
| 569 | 569 |
| 570 DCHECK(ssl_host_state_->CalledOnValidThread()); | 570 DCHECK(ssl_host_state_->CalledOnValidThread()); |
| 571 return ssl_host_state_.get(); | 571 return ssl_host_state_.get(); |
| 572 } | 572 } |
| 573 | 573 |
| 574 PrefService* ProfileImpl::GetPrefs() { | 574 PrefService* ProfileImpl::GetPrefs() { |
| 575 if (!prefs_.get()) { | 575 if (!prefs_.get()) { |
| 576 prefs_.reset(new PrefService(GetPrefFilePath())); | 576 prefs_.reset(new PrefService(GetPrefFilePath(), |
| 577 g_browser_process->file_thread())); |
| 577 | 578 |
| 578 // The Profile class and ProfileManager class may read some prefs so | 579 // The Profile class and ProfileManager class may read some prefs so |
| 579 // register known prefs as soon as possible. | 580 // register known prefs as soon as possible. |
| 580 Profile::RegisterUserPrefs(prefs_.get()); | 581 Profile::RegisterUserPrefs(prefs_.get()); |
| 581 ProfileManager::RegisterUserPrefs(prefs_.get()); | 582 ProfileManager::RegisterUserPrefs(prefs_.get()); |
| 582 | 583 |
| 583 // The last session exited cleanly if there is no pref for | 584 // The last session exited cleanly if there is no pref for |
| 584 // kSessionExitedCleanly or the value for kSessionExitedCleanly is true. | 585 // kSessionExitedCleanly or the value for kSessionExitedCleanly is true. |
| 585 last_session_exited_cleanly_ = | 586 last_session_exited_cleanly_ = |
| 586 prefs_->GetBoolean(prefs::kSessionExitedCleanly); | 587 prefs_->GetBoolean(prefs::kSessionExitedCleanly); |
| 587 // Mark the session as open. | 588 // Mark the session as open. |
| 588 prefs_->SetBoolean(prefs::kSessionExitedCleanly, false); | 589 prefs_->SetBoolean(prefs::kSessionExitedCleanly, false); |
| 589 // Make sure we save to disk that the session has opened. | 590 // Make sure we save to disk that the session has opened. |
| 590 prefs_->ScheduleSavePersistentPrefs(g_browser_process->file_thread()); | 591 prefs_->ScheduleSavePersistentPrefs(); |
| 591 } | 592 } |
| 592 | 593 |
| 593 return prefs_.get(); | 594 return prefs_.get(); |
| 594 } | 595 } |
| 595 | 596 |
| 596 FilePath ProfileImpl::GetPrefFilePath() { | 597 FilePath ProfileImpl::GetPrefFilePath() { |
| 597 FilePath pref_file_path = path_; | 598 FilePath pref_file_path = path_; |
| 598 pref_file_path = pref_file_path.Append(chrome::kPreferencesFilename); | 599 pref_file_path = pref_file_path.Append(chrome::kPreferencesFilename); |
| 599 return pref_file_path; | 600 return pref_file_path; |
| 600 } | 601 } |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 return spellchecker_; | 873 return spellchecker_; |
| 873 } | 874 } |
| 874 | 875 |
| 875 void ProfileImpl::MarkAsCleanShutdown() { | 876 void ProfileImpl::MarkAsCleanShutdown() { |
| 876 if (prefs_.get()) { | 877 if (prefs_.get()) { |
| 877 // The session cleanly exited, set kSessionExitedCleanly appropriately. | 878 // The session cleanly exited, set kSessionExitedCleanly appropriately. |
| 878 prefs_->SetBoolean(prefs::kSessionExitedCleanly, true); | 879 prefs_->SetBoolean(prefs::kSessionExitedCleanly, true); |
| 879 | 880 |
| 880 // NOTE: If you change what thread this writes on, be sure and update | 881 // NOTE: If you change what thread this writes on, be sure and update |
| 881 // ChromeFrame::EndSession(). | 882 // ChromeFrame::EndSession(). |
| 882 prefs_->SavePersistentPrefs(g_browser_process->file_thread()); | 883 prefs_->SavePersistentPrefs(); |
| 883 } | 884 } |
| 884 } | 885 } |
| 885 | 886 |
| 886 void ProfileImpl::Observe(NotificationType type, | 887 void ProfileImpl::Observe(NotificationType type, |
| 887 const NotificationSource& source, | 888 const NotificationSource& source, |
| 888 const NotificationDetails& details) { | 889 const NotificationDetails& details) { |
| 889 if (NotificationType::PREF_CHANGED == type) { | 890 if (NotificationType::PREF_CHANGED == type) { |
| 890 std::wstring* pref_name_in = Details<std::wstring>(details).ptr(); | 891 std::wstring* pref_name_in = Details<std::wstring>(details).ptr(); |
| 891 PrefService* prefs = Source<PrefService>(source).ptr(); | 892 PrefService* prefs = Source<PrefService>(source).ptr(); |
| 892 DCHECK(pref_name_in && prefs); | 893 DCHECK(pref_name_in && prefs); |
| 893 if (*pref_name_in == prefs::kSpellCheckDictionary || | 894 if (*pref_name_in == prefs::kSpellCheckDictionary || |
| 894 *pref_name_in == prefs::kEnableSpellCheck) { | 895 *pref_name_in == prefs::kEnableSpellCheck) { |
| 895 InitializeSpellChecker(true); | 896 InitializeSpellChecker(true); |
| 896 } | 897 } |
| 897 } | 898 } |
| 898 } | 899 } |
| 899 | 900 |
| 900 void ProfileImpl::StopCreateSessionServiceTimer() { | 901 void ProfileImpl::StopCreateSessionServiceTimer() { |
| 901 create_session_service_timer_.Stop(); | 902 create_session_service_timer_.Stop(); |
| 902 } | 903 } |
| 903 | 904 |
| 904 #ifdef CHROME_PERSONALIZATION | 905 #ifdef CHROME_PERSONALIZATION |
| 905 ProfilePersonalization* ProfileImpl::GetProfilePersonalization() { | 906 ProfilePersonalization* ProfileImpl::GetProfilePersonalization() { |
| 906 return personalization_.get(); | 907 return personalization_.get(); |
| 907 } | 908 } |
| 908 #endif | 909 #endif |
| OLD | NEW |