| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 scoped_refptr<ExtensionPrefStore> extension_pref_store( |
| 662 new ExtensionPrefStore); |
| 663 scoped_refptr<ExtensionPrefStore> incognito_extension_pref_store( |
| 664 new ExtensionPrefStore); |
| 662 prefs_.reset(PrefService::CreatePrefService(GetPrefFilePath(), | 665 prefs_.reset(PrefService::CreatePrefService(GetPrefFilePath(), |
| 663 extension_pref_store, | 666 extension_pref_store, |
| 664 GetOriginalProfile())); | 667 GetOriginalProfile())); |
| 668 incognito_prefs_.reset( |
| 669 prefs_->CreateIncognitoPrefService(incognito_extension_pref_store)); |
| 665 | 670 |
| 666 // The Profile class and ProfileManager class may read some prefs so | 671 // The Profile class and ProfileManager class may read some prefs so |
| 667 // register known prefs as soon as possible. | 672 // register known prefs as soon as possible. |
| 668 Profile::RegisterUserPrefs(prefs_.get()); | 673 Profile::RegisterUserPrefs(prefs_.get()); |
| 669 browser::RegisterUserPrefs(prefs_.get()); | 674 browser::RegisterUserPrefs(prefs_.get()); |
| 670 | 675 |
| 671 // The last session exited cleanly if there is no pref for | 676 // The last session exited cleanly if there is no pref for |
| 672 // kSessionExitedCleanly or the value for kSessionExitedCleanly is true. | 677 // kSessionExitedCleanly or the value for kSessionExitedCleanly is true. |
| 673 last_session_exited_cleanly_ = | 678 last_session_exited_cleanly_ = |
| 674 prefs_->GetBoolean(prefs::kSessionExitedCleanly); | 679 prefs_->GetBoolean(prefs::kSessionExitedCleanly); |
| 675 // Mark the session as open. | 680 // Mark the session as open. |
| 676 prefs_->SetBoolean(prefs::kSessionExitedCleanly, false); | 681 prefs_->SetBoolean(prefs::kSessionExitedCleanly, false); |
| 677 // Make sure we save to disk that the session has opened. | 682 // Make sure we save to disk that the session has opened. |
| 678 prefs_->ScheduleSavePersistentPrefs(); | 683 prefs_->ScheduleSavePersistentPrefs(); |
| 679 | 684 |
| 680 // Ensure that preferences set by extensions are restored in the profile | 685 // Ensure that preferences set by extensions are restored in the profile |
| 681 // as early as possible. The constructor takes care of that. | 686 // as early as possible. The constructor takes care of that. |
| 687 |
| 682 extension_prefs_.reset(new ExtensionPrefs( | 688 extension_prefs_.reset(new ExtensionPrefs( |
| 683 prefs_.get(), | 689 prefs_.get(), |
| 690 incognito_prefs_.get(), |
| 684 GetPath().AppendASCII(ExtensionService::kInstallDirectoryName), | 691 GetPath().AppendASCII(ExtensionService::kInstallDirectoryName), |
| 685 extension_pref_store)); | 692 extension_pref_store, |
| 693 incognito_extension_pref_store)); |
| 686 | 694 |
| 687 DCHECK(!net_pref_observer_.get()); | 695 DCHECK(!net_pref_observer_.get()); |
| 688 net_pref_observer_.reset(new NetPrefObserver(prefs_.get())); | 696 net_pref_observer_.reset(new NetPrefObserver(prefs_.get())); |
| 689 } | 697 } |
| 690 | 698 |
| 691 return prefs_.get(); | 699 return prefs_.get(); |
| 692 } | 700 } |
| 693 | 701 |
| 694 FilePath ProfileImpl::GetPrefFilePath() { | 702 FilePath ProfileImpl::GetPrefFilePath() { |
| 695 FilePath pref_file_path = path_; | 703 FilePath pref_file_path = path_; |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1351 } | 1359 } |
| 1352 | 1360 |
| 1353 PrerenderManager* ProfileImpl::GetPrerenderManager() { | 1361 PrerenderManager* ProfileImpl::GetPrerenderManager() { |
| 1354 CommandLine* cl = CommandLine::ForCurrentProcess(); | 1362 CommandLine* cl = CommandLine::ForCurrentProcess(); |
| 1355 if (!cl->HasSwitch(switches::kEnablePagePrerender)) | 1363 if (!cl->HasSwitch(switches::kEnablePagePrerender)) |
| 1356 return NULL; | 1364 return NULL; |
| 1357 if (!prerender_manager_.get()) | 1365 if (!prerender_manager_.get()) |
| 1358 prerender_manager_.reset(new PrerenderManager(this)); | 1366 prerender_manager_.reset(new PrerenderManager(this)); |
| 1359 return prerender_manager_.get(); | 1367 return prerender_manager_.get(); |
| 1360 } | 1368 } |
| OLD | NEW |