| 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/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 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 browser::MigrateBrowserPrefs(prefs_.get(), | 751 browser::MigrateBrowserPrefs(prefs_.get(), |
| 752 g_browser_process->local_state()); | 752 g_browser_process->local_state()); |
| 753 } | 753 } |
| 754 | 754 |
| 755 // The last session exited cleanly if there is no pref for | 755 // The last session exited cleanly if there is no pref for |
| 756 // kSessionExitedCleanly or the value for kSessionExitedCleanly is true. | 756 // kSessionExitedCleanly or the value for kSessionExitedCleanly is true. |
| 757 last_session_exited_cleanly_ = | 757 last_session_exited_cleanly_ = |
| 758 prefs_->GetBoolean(prefs::kSessionExitedCleanly); | 758 prefs_->GetBoolean(prefs::kSessionExitedCleanly); |
| 759 // Mark the session as open. | 759 // Mark the session as open. |
| 760 prefs_->SetBoolean(prefs::kSessionExitedCleanly, false); | 760 prefs_->SetBoolean(prefs::kSessionExitedCleanly, false); |
| 761 // Make sure we save to disk that the session has opened. | |
| 762 prefs_->ScheduleSavePersistentPrefs(); | |
| 763 | 761 |
| 764 bool extensions_disabled = | 762 bool extensions_disabled = |
| 765 prefs_->GetBoolean(prefs::kDisableExtensions) || | 763 prefs_->GetBoolean(prefs::kDisableExtensions) || |
| 766 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableExtensions); | 764 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableExtensions); |
| 767 | 765 |
| 768 // Ensure that preferences set by extensions are restored in the profile | 766 // Ensure that preferences set by extensions are restored in the profile |
| 769 // as early as possible. The constructor takes care of that. | 767 // as early as possible. The constructor takes care of that. |
| 770 extension_prefs_.reset(new ExtensionPrefs( | 768 extension_prefs_.reset(new ExtensionPrefs( |
| 771 prefs_.get(), | 769 prefs_.get(), |
| 772 GetPath().AppendASCII(ExtensionService::kInstallDirectoryName), | 770 GetPath().AppendASCII(ExtensionService::kInstallDirectoryName), |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1284 return webkit_context_.get(); | 1282 return webkit_context_.get(); |
| 1285 } | 1283 } |
| 1286 | 1284 |
| 1287 void ProfileImpl::MarkAsCleanShutdown() { | 1285 void ProfileImpl::MarkAsCleanShutdown() { |
| 1288 if (prefs_.get()) { | 1286 if (prefs_.get()) { |
| 1289 // The session cleanly exited, set kSessionExitedCleanly appropriately. | 1287 // The session cleanly exited, set kSessionExitedCleanly appropriately. |
| 1290 prefs_->SetBoolean(prefs::kSessionExitedCleanly, true); | 1288 prefs_->SetBoolean(prefs::kSessionExitedCleanly, true); |
| 1291 | 1289 |
| 1292 // NOTE: If you change what thread this writes on, be sure and update | 1290 // NOTE: If you change what thread this writes on, be sure and update |
| 1293 // ChromeFrame::EndSession(). | 1291 // ChromeFrame::EndSession(). |
| 1294 prefs_->SavePersistentPrefs(); | 1292 prefs_->CommitPendingWrite(); |
| 1295 } | 1293 } |
| 1296 } | 1294 } |
| 1297 | 1295 |
| 1298 void ProfileImpl::Observe(int type, | 1296 void ProfileImpl::Observe(int type, |
| 1299 const content::NotificationSource& source, | 1297 const content::NotificationSource& source, |
| 1300 const content::NotificationDetails& details) { | 1298 const content::NotificationDetails& details) { |
| 1301 switch (type) { | 1299 switch (type) { |
| 1302 case chrome::NOTIFICATION_PREF_INITIALIZATION_COMPLETED: { | 1300 case chrome::NOTIFICATION_PREF_INITIALIZATION_COMPLETED: { |
| 1303 bool* succeeded = content::Details<bool>(details).ptr(); | 1301 bool* succeeded = content::Details<bool>(details).ptr(); |
| 1304 PrefService *prefs = content::Source<PrefService>(source).ptr(); | 1302 PrefService *prefs = content::Source<PrefService>(source).ptr(); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1526 NOTREACHED(); | 1524 NOTREACHED(); |
| 1527 break; | 1525 break; |
| 1528 } | 1526 } |
| 1529 } | 1527 } |
| 1530 if (do_update_pref) | 1528 if (do_update_pref) |
| 1531 GetPrefs()->SetString(prefs::kApplicationLocale, new_locale); | 1529 GetPrefs()->SetString(prefs::kApplicationLocale, new_locale); |
| 1532 local_state->SetString(prefs::kApplicationLocale, new_locale); | 1530 local_state->SetString(prefs::kApplicationLocale, new_locale); |
| 1533 | 1531 |
| 1534 if (chromeos::UserManager::Get()->current_user_is_owner()) | 1532 if (chromeos::UserManager::Get()->current_user_is_owner()) |
| 1535 local_state->SetString(prefs::kOwnerLocale, new_locale); | 1533 local_state->SetString(prefs::kOwnerLocale, new_locale); |
| 1536 | |
| 1537 GetPrefs()->ScheduleSavePersistentPrefs(); | |
| 1538 local_state->ScheduleSavePersistentPrefs(); | |
| 1539 } | 1534 } |
| 1540 | 1535 |
| 1541 void ProfileImpl::OnLogin() { | 1536 void ProfileImpl::OnLogin() { |
| 1542 if (locale_change_guard_ == NULL) | 1537 if (locale_change_guard_ == NULL) |
| 1543 locale_change_guard_.reset(new chromeos::LocaleChangeGuard(this)); | 1538 locale_change_guard_.reset(new chromeos::LocaleChangeGuard(this)); |
| 1544 locale_change_guard_->OnLogin(); | 1539 locale_change_guard_->OnLogin(); |
| 1545 } | 1540 } |
| 1546 | 1541 |
| 1547 void ProfileImpl::SetupChromeOSEnterpriseExtensionObserver() { | 1542 void ProfileImpl::SetupChromeOSEnterpriseExtensionObserver() { |
| 1548 DCHECK(!chromeos_enterprise_extension_observer_.get()); | 1543 DCHECK(!chromeos_enterprise_extension_observer_.get()); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1662 FilePath* cache_path, | 1657 FilePath* cache_path, |
| 1663 int* max_size) { | 1658 int* max_size) { |
| 1664 DCHECK(cache_path); | 1659 DCHECK(cache_path); |
| 1665 DCHECK(max_size); | 1660 DCHECK(max_size); |
| 1666 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); | 1661 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); |
| 1667 if (!path.empty()) | 1662 if (!path.empty()) |
| 1668 *cache_path = path; | 1663 *cache_path = path; |
| 1669 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : | 1664 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : |
| 1670 prefs_->GetInteger(prefs::kDiskCacheSize); | 1665 prefs_->GetInteger(prefs::kDiskCacheSize); |
| 1671 } | 1666 } |
| OLD | NEW |