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 17 matching lines...) Expand all Loading... |
28 #include "chrome/browser/chrome_blob_storage_context.h" | 28 #include "chrome/browser/chrome_blob_storage_context.h" |
29 #include "chrome/browser/content_settings/host_content_settings_map.h" | 29 #include "chrome/browser/content_settings/host_content_settings_map.h" |
30 #include "chrome/browser/dom_ui/ntp_resource_cache.h" | 30 #include "chrome/browser/dom_ui/ntp_resource_cache.h" |
31 #include "chrome/browser/download/download_manager.h" | 31 #include "chrome/browser/download/download_manager.h" |
32 #include "chrome/browser/extensions/default_apps.h" | 32 #include "chrome/browser/extensions/default_apps.h" |
33 #include "chrome/browser/extensions/extension_devtools_manager.h" | 33 #include "chrome/browser/extensions/extension_devtools_manager.h" |
34 #include "chrome/browser/extensions/extension_error_reporter.h" | 34 #include "chrome/browser/extensions/extension_error_reporter.h" |
35 #include "chrome/browser/extensions/extension_info_map.h" | 35 #include "chrome/browser/extensions/extension_info_map.h" |
36 #include "chrome/browser/extensions/extension_event_router.h" | 36 #include "chrome/browser/extensions/extension_event_router.h" |
37 #include "chrome/browser/extensions/extension_message_service.h" | 37 #include "chrome/browser/extensions/extension_message_service.h" |
| 38 #include "chrome/browser/extensions/extension_pref_store.h" |
38 #include "chrome/browser/extensions/extension_process_manager.h" | 39 #include "chrome/browser/extensions/extension_process_manager.h" |
39 #include "chrome/browser/extensions/extensions_service.h" | 40 #include "chrome/browser/extensions/extensions_service.h" |
40 #include "chrome/browser/extensions/user_script_master.h" | 41 #include "chrome/browser/extensions/user_script_master.h" |
41 #include "chrome/browser/favicon_service.h" | 42 #include "chrome/browser/favicon_service.h" |
42 #include "chrome/browser/file_system/browser_file_system_context.h" | 43 #include "chrome/browser/file_system/browser_file_system_context.h" |
43 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" | 44 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" |
44 #include "chrome/browser/geolocation/geolocation_permission_context.h" | 45 #include "chrome/browser/geolocation/geolocation_permission_context.h" |
45 #include "chrome/browser/history/history.h" | 46 #include "chrome/browser/history/history.h" |
46 #include "chrome/browser/history/top_sites.h" | 47 #include "chrome/browser/history/top_sites.h" |
47 #include "chrome/browser/host_zoom_map.h" | 48 #include "chrome/browser/host_zoom_map.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, | 271 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, |
271 &ProfileImpl::EnsureSessionServiceCreated); | 272 &ProfileImpl::EnsureSessionServiceCreated); |
272 | 273 |
273 PrefService* prefs = GetPrefs(); | 274 PrefService* prefs = GetPrefs(); |
274 pref_change_registrar_.Init(prefs); | 275 pref_change_registrar_.Init(prefs); |
275 pref_change_registrar_.Add(prefs::kSpellCheckDictionary, this); | 276 pref_change_registrar_.Add(prefs::kSpellCheckDictionary, this); |
276 pref_change_registrar_.Add(prefs::kEnableSpellCheck, this); | 277 pref_change_registrar_.Add(prefs::kEnableSpellCheck, this); |
277 pref_change_registrar_.Add(prefs::kEnableAutoSpellCorrect, this); | 278 pref_change_registrar_.Add(prefs::kEnableAutoSpellCorrect, this); |
278 pref_change_registrar_.Add(prefs::kClearSiteDataOnExit, this); | 279 pref_change_registrar_.Add(prefs::kClearSiteDataOnExit, this); |
279 | 280 |
280 // Ensure that preferences set by extensions are restored in the profile | |
281 // as early as possible. The constructor takes care of that. | |
282 extension_prefs_.reset(new ExtensionPrefs( | |
283 GetPrefs(), | |
284 GetPath().AppendASCII(ExtensionsService::kInstallDirectoryName))); | |
285 | |
286 // Convert active labs into switches. Modifies the current command line. | 281 // Convert active labs into switches. Modifies the current command line. |
287 about_flags::ConvertFlagsToSwitches(prefs, CommandLine::ForCurrentProcess()); | 282 about_flags::ConvertFlagsToSwitches(prefs, CommandLine::ForCurrentProcess()); |
288 | 283 |
289 // It would be nice to use PathService for fetching this directory, but | 284 // It would be nice to use PathService for fetching this directory, but |
290 // the cache directory depends on the profile directory, which isn't available | 285 // the cache directory depends on the profile directory, which isn't available |
291 // to PathService. | 286 // to PathService. |
292 chrome::GetUserCacheDirectory(path_, &base_cache_path_); | 287 chrome::GetUserCacheDirectory(path_, &base_cache_path_); |
293 file_util::CreateDirectory(base_cache_path_); | 288 file_util::CreateDirectory(base_cache_path_); |
294 | 289 |
295 // Listen for theme installations from our original profile. | 290 // Listen for theme installations from our original profile. |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 new TransportSecurityPersister(); | 659 new TransportSecurityPersister(); |
665 transport_security_persister_->Initialize( | 660 transport_security_persister_->Initialize( |
666 transport_security_state_.get(), path_); | 661 transport_security_state_.get(), path_); |
667 } | 662 } |
668 | 663 |
669 return transport_security_state_.get(); | 664 return transport_security_state_.get(); |
670 } | 665 } |
671 | 666 |
672 PrefService* ProfileImpl::GetPrefs() { | 667 PrefService* ProfileImpl::GetPrefs() { |
673 if (!prefs_.get()) { | 668 if (!prefs_.get()) { |
| 669 ExtensionPrefStore* extension_pref_store = new ExtensionPrefStore; |
674 prefs_.reset(PrefService::CreatePrefService(GetPrefFilePath(), | 670 prefs_.reset(PrefService::CreatePrefService(GetPrefFilePath(), |
| 671 extension_pref_store, |
675 GetOriginalProfile())); | 672 GetOriginalProfile())); |
676 | 673 |
677 // The Profile class and ProfileManager class may read some prefs so | 674 // The Profile class and ProfileManager class may read some prefs so |
678 // register known prefs as soon as possible. | 675 // register known prefs as soon as possible. |
679 Profile::RegisterUserPrefs(prefs_.get()); | 676 Profile::RegisterUserPrefs(prefs_.get()); |
680 browser::RegisterUserPrefs(prefs_.get()); | 677 browser::RegisterUserPrefs(prefs_.get()); |
681 | 678 |
682 // The last session exited cleanly if there is no pref for | 679 // The last session exited cleanly if there is no pref for |
683 // kSessionExitedCleanly or the value for kSessionExitedCleanly is true. | 680 // kSessionExitedCleanly or the value for kSessionExitedCleanly is true. |
684 last_session_exited_cleanly_ = | 681 last_session_exited_cleanly_ = |
685 prefs_->GetBoolean(prefs::kSessionExitedCleanly); | 682 prefs_->GetBoolean(prefs::kSessionExitedCleanly); |
686 // Mark the session as open. | 683 // Mark the session as open. |
687 prefs_->SetBoolean(prefs::kSessionExitedCleanly, false); | 684 prefs_->SetBoolean(prefs::kSessionExitedCleanly, false); |
688 // Make sure we save to disk that the session has opened. | 685 // Make sure we save to disk that the session has opened. |
689 prefs_->ScheduleSavePersistentPrefs(); | 686 prefs_->ScheduleSavePersistentPrefs(); |
690 | 687 |
| 688 // Ensure that preferences set by extensions are restored in the profile |
| 689 // as early as possible. The constructor takes care of that. |
| 690 extension_prefs_.reset(new ExtensionPrefs( |
| 691 prefs_.get(), |
| 692 GetPath().AppendASCII(ExtensionsService::kInstallDirectoryName), |
| 693 extension_pref_store)); |
| 694 |
691 DCHECK(!net_pref_observer_.get()); | 695 DCHECK(!net_pref_observer_.get()); |
692 net_pref_observer_.reset(new NetPrefObserver(prefs_.get())); | 696 net_pref_observer_.reset(new NetPrefObserver(prefs_.get())); |
693 } | 697 } |
694 | 698 |
695 return prefs_.get(); | 699 return prefs_.get(); |
696 } | 700 } |
697 | 701 |
698 FilePath ProfileImpl::GetPrefFilePath() { | 702 FilePath ProfileImpl::GetPrefFilePath() { |
699 FilePath pref_file_path = path_; | 703 FilePath pref_file_path = path_; |
700 pref_file_path = pref_file_path.Append(chrome::kPreferencesFilename); | 704 pref_file_path = pref_file_path.Append(chrome::kPreferencesFilename); |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1355 } | 1359 } |
1356 | 1360 |
1357 PrerenderManager* ProfileImpl::GetPrerenderManager() { | 1361 PrerenderManager* ProfileImpl::GetPrerenderManager() { |
1358 CommandLine* cl = CommandLine::ForCurrentProcess(); | 1362 CommandLine* cl = CommandLine::ForCurrentProcess(); |
1359 if (!cl->HasSwitch(switches::kEnablePagePrerender)) | 1363 if (!cl->HasSwitch(switches::kEnablePagePrerender)) |
1360 return NULL; | 1364 return NULL; |
1361 if (!prerender_manager_.get()) | 1365 if (!prerender_manager_.get()) |
1362 prerender_manager_.reset(new PrerenderManager(this)); | 1366 prerender_manager_.reset(new PrerenderManager(this)); |
1363 return prerender_manager_.get(); | 1367 return prerender_manager_.get(); |
1364 } | 1368 } |
OLD | NEW |