| 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 "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/environment.h" | 9 #include "base/environment.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 new TransportSecurityPersister(); | 651 new TransportSecurityPersister(); |
| 652 transport_security_persister_->Initialize( | 652 transport_security_persister_->Initialize( |
| 653 transport_security_state_.get(), path_); | 653 transport_security_state_.get(), path_); |
| 654 } | 654 } |
| 655 | 655 |
| 656 return transport_security_state_.get(); | 656 return transport_security_state_.get(); |
| 657 } | 657 } |
| 658 | 658 |
| 659 PrefService* ProfileImpl::GetPrefs() { | 659 PrefService* ProfileImpl::GetPrefs() { |
| 660 if (!prefs_.get()) { | 660 if (!prefs_.get()) { |
| 661 ExtensionPrefStore* extension_pref_store = new ExtensionPrefStore; | 661 extension_pref_value_map_.reset(new ExtensionPrefValueMap); |
| 662 prefs_.reset(PrefService::CreatePrefService(GetPrefFilePath(), | 662 prefs_.reset(PrefService::CreatePrefService( |
| 663 extension_pref_store, | 663 GetPrefFilePath(), |
| 664 GetOriginalProfile())); | 664 new ExtensionPrefStore(extension_pref_value_map_.get(), false), |
| 665 GetOriginalProfile())); |
| 665 | 666 |
| 666 // The Profile class and ProfileManager class may read some prefs so | 667 // The Profile class and ProfileManager class may read some prefs so |
| 667 // register known prefs as soon as possible. | 668 // register known prefs as soon as possible. |
| 668 Profile::RegisterUserPrefs(prefs_.get()); | 669 Profile::RegisterUserPrefs(prefs_.get()); |
| 669 browser::RegisterUserPrefs(prefs_.get()); | 670 browser::RegisterUserPrefs(prefs_.get()); |
| 670 | 671 |
| 671 // The last session exited cleanly if there is no pref for | 672 // The last session exited cleanly if there is no pref for |
| 672 // kSessionExitedCleanly or the value for kSessionExitedCleanly is true. | 673 // kSessionExitedCleanly or the value for kSessionExitedCleanly is true. |
| 673 last_session_exited_cleanly_ = | 674 last_session_exited_cleanly_ = |
| 674 prefs_->GetBoolean(prefs::kSessionExitedCleanly); | 675 prefs_->GetBoolean(prefs::kSessionExitedCleanly); |
| 675 // Mark the session as open. | 676 // Mark the session as open. |
| 676 prefs_->SetBoolean(prefs::kSessionExitedCleanly, false); | 677 prefs_->SetBoolean(prefs::kSessionExitedCleanly, false); |
| 677 // Make sure we save to disk that the session has opened. | 678 // Make sure we save to disk that the session has opened. |
| 678 prefs_->ScheduleSavePersistentPrefs(); | 679 prefs_->ScheduleSavePersistentPrefs(); |
| 679 | 680 |
| 680 // Ensure that preferences set by extensions are restored in the profile | 681 // Ensure that preferences set by extensions are restored in the profile |
| 681 // as early as possible. The constructor takes care of that. | 682 // as early as possible. The constructor takes care of that. |
| 682 extension_prefs_.reset(new ExtensionPrefs( | 683 extension_prefs_.reset(new ExtensionPrefs( |
| 683 prefs_.get(), | 684 prefs_.get(), |
| 684 GetPath().AppendASCII(ExtensionService::kInstallDirectoryName), | 685 GetPath().AppendASCII(ExtensionService::kInstallDirectoryName), |
| 685 extension_pref_store)); | 686 extension_pref_value_map_.get())); |
| 686 | 687 |
| 687 DCHECK(!net_pref_observer_.get()); | 688 DCHECK(!net_pref_observer_.get()); |
| 688 net_pref_observer_.reset(new NetPrefObserver(prefs_.get())); | 689 net_pref_observer_.reset(new NetPrefObserver(prefs_.get())); |
| 689 } | 690 } |
| 690 | 691 |
| 691 return prefs_.get(); | 692 return prefs_.get(); |
| 692 } | 693 } |
| 693 | 694 |
| 694 FilePath ProfileImpl::GetPrefFilePath() { | 695 FilePath ProfileImpl::GetPrefFilePath() { |
| 695 FilePath pref_file_path = path_; | 696 FilePath pref_file_path = path_; |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1164 | 1165 |
| 1165 void ProfileImpl::SpellCheckHostInitialized() { | 1166 void ProfileImpl::SpellCheckHostInitialized() { |
| 1166 spellcheck_host_ready_ = spellcheck_host_ && | 1167 spellcheck_host_ready_ = spellcheck_host_ && |
| 1167 (spellcheck_host_->bdict_file() != base::kInvalidPlatformFileValue || | 1168 (spellcheck_host_->bdict_file() != base::kInvalidPlatformFileValue || |
| 1168 spellcheck_host_->use_platform_spellchecker()); | 1169 spellcheck_host_->use_platform_spellchecker()); |
| 1169 NotificationService::current()->Notify( | 1170 NotificationService::current()->Notify( |
| 1170 NotificationType::SPELLCHECK_HOST_REINITIALIZED, | 1171 NotificationType::SPELLCHECK_HOST_REINITIALIZED, |
| 1171 Source<Profile>(this), NotificationService::NoDetails()); | 1172 Source<Profile>(this), NotificationService::NoDetails()); |
| 1172 } | 1173 } |
| 1173 | 1174 |
| 1175 ExtensionPrefValueMap* ProfileImpl::GetExtensionPrefValueMap() { |
| 1176 return extension_pref_value_map_.get(); |
| 1177 } |
| 1178 |
| 1174 WebKitContext* ProfileImpl::GetWebKitContext() { | 1179 WebKitContext* ProfileImpl::GetWebKitContext() { |
| 1175 if (!webkit_context_.get()) | 1180 if (!webkit_context_.get()) |
| 1176 webkit_context_ = new WebKitContext(this, clear_local_state_on_exit_); | 1181 webkit_context_ = new WebKitContext(this, clear_local_state_on_exit_); |
| 1177 DCHECK(webkit_context_.get()); | 1182 DCHECK(webkit_context_.get()); |
| 1178 return webkit_context_.get(); | 1183 return webkit_context_.get(); |
| 1179 } | 1184 } |
| 1180 | 1185 |
| 1181 DesktopNotificationService* ProfileImpl::GetDesktopNotificationService() { | 1186 DesktopNotificationService* ProfileImpl::GetDesktopNotificationService() { |
| 1182 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1187 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1183 if (!desktop_notification_service_.get()) { | 1188 if (!desktop_notification_service_.get()) { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1364 } | 1369 } |
| 1365 | 1370 |
| 1366 PrerenderManager* ProfileImpl::GetPrerenderManager() { | 1371 PrerenderManager* ProfileImpl::GetPrerenderManager() { |
| 1367 CommandLine* cl = CommandLine::ForCurrentProcess(); | 1372 CommandLine* cl = CommandLine::ForCurrentProcess(); |
| 1368 if (!cl->HasSwitch(switches::kEnablePagePrerender)) | 1373 if (!cl->HasSwitch(switches::kEnablePagePrerender)) |
| 1369 return NULL; | 1374 return NULL; |
| 1370 if (!prerender_manager_.get()) | 1375 if (!prerender_manager_.get()) |
| 1371 prerender_manager_.reset(new PrerenderManager(this)); | 1376 prerender_manager_.reset(new PrerenderManager(this)); |
| 1372 return prerender_manager_.get(); | 1377 return prerender_manager_.get(); |
| 1373 } | 1378 } |
| OLD | NEW |