Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1099)

Side by Side Diff: chrome/browser/profiles/profile_impl.cc

Issue 5646003: Sanitize PrefStore interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, fix up unit tests. Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, 270 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this,
270 &ProfileImpl::EnsureSessionServiceCreated); 271 &ProfileImpl::EnsureSessionServiceCreated);
271 272
272 PrefService* prefs = GetPrefs(); 273 PrefService* prefs = GetPrefs();
273 pref_change_registrar_.Init(prefs); 274 pref_change_registrar_.Init(prefs);
274 pref_change_registrar_.Add(prefs::kSpellCheckDictionary, this); 275 pref_change_registrar_.Add(prefs::kSpellCheckDictionary, this);
275 pref_change_registrar_.Add(prefs::kEnableSpellCheck, this); 276 pref_change_registrar_.Add(prefs::kEnableSpellCheck, this);
276 pref_change_registrar_.Add(prefs::kEnableAutoSpellCorrect, this); 277 pref_change_registrar_.Add(prefs::kEnableAutoSpellCorrect, this);
277 pref_change_registrar_.Add(prefs::kClearSiteDataOnExit, this); 278 pref_change_registrar_.Add(prefs::kClearSiteDataOnExit, this);
278 279
279 // Ensure that preferences set by extensions are restored in the profile
280 // as early as possible. The constructor takes care of that.
281 extension_prefs_.reset(new ExtensionPrefs(
282 GetPrefs(),
283 GetPath().AppendASCII(ExtensionsService::kInstallDirectoryName)));
284
285 // Convert active labs into switches. Modifies the current command line. 280 // Convert active labs into switches. Modifies the current command line.
286 about_flags::ConvertFlagsToSwitches(prefs, CommandLine::ForCurrentProcess()); 281 about_flags::ConvertFlagsToSwitches(prefs, CommandLine::ForCurrentProcess());
287 282
288 // It would be nice to use PathService for fetching this directory, but 283 // It would be nice to use PathService for fetching this directory, but
289 // the cache directory depends on the profile directory, which isn't available 284 // the cache directory depends on the profile directory, which isn't available
290 // to PathService. 285 // to PathService.
291 chrome::GetUserCacheDirectory(path_, &base_cache_path_); 286 chrome::GetUserCacheDirectory(path_, &base_cache_path_);
292 file_util::CreateDirectory(base_cache_path_); 287 file_util::CreateDirectory(base_cache_path_);
293 288
294 // Listen for theme installations from our original profile. 289 // Listen for theme installations from our original profile.
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 new TransportSecurityPersister(); 658 new TransportSecurityPersister();
664 transport_security_persister_->Initialize( 659 transport_security_persister_->Initialize(
665 transport_security_state_.get(), path_); 660 transport_security_state_.get(), path_);
666 } 661 }
667 662
668 return transport_security_state_.get(); 663 return transport_security_state_.get();
669 } 664 }
670 665
671 PrefService* ProfileImpl::GetPrefs() { 666 PrefService* ProfileImpl::GetPrefs() {
672 if (!prefs_.get()) { 667 if (!prefs_.get()) {
668 ExtensionPrefStore* extension_pref_store = new ExtensionPrefStore;
673 prefs_.reset(PrefService::CreatePrefService(GetPrefFilePath(), 669 prefs_.reset(PrefService::CreatePrefService(GetPrefFilePath(),
670 extension_pref_store,
674 GetOriginalProfile())); 671 GetOriginalProfile()));
675 672
676 // The Profile class and ProfileManager class may read some prefs so 673 // The Profile class and ProfileManager class may read some prefs so
677 // register known prefs as soon as possible. 674 // register known prefs as soon as possible.
678 Profile::RegisterUserPrefs(prefs_.get()); 675 Profile::RegisterUserPrefs(prefs_.get());
679 browser::RegisterUserPrefs(prefs_.get()); 676 browser::RegisterUserPrefs(prefs_.get());
680 677
681 // The last session exited cleanly if there is no pref for 678 // The last session exited cleanly if there is no pref for
682 // kSessionExitedCleanly or the value for kSessionExitedCleanly is true. 679 // kSessionExitedCleanly or the value for kSessionExitedCleanly is true.
683 last_session_exited_cleanly_ = 680 last_session_exited_cleanly_ =
684 prefs_->GetBoolean(prefs::kSessionExitedCleanly); 681 prefs_->GetBoolean(prefs::kSessionExitedCleanly);
685 // Mark the session as open. 682 // Mark the session as open.
686 prefs_->SetBoolean(prefs::kSessionExitedCleanly, false); 683 prefs_->SetBoolean(prefs::kSessionExitedCleanly, false);
687 // Make sure we save to disk that the session has opened. 684 // Make sure we save to disk that the session has opened.
688 prefs_->ScheduleSavePersistentPrefs(); 685 prefs_->ScheduleSavePersistentPrefs();
689 686
687 // Ensure that preferences set by extensions are restored in the profile
688 // as early as possible. The constructor takes care of that.
689 extension_prefs_.reset(new ExtensionPrefs(
690 prefs_.get(),
691 GetPath().AppendASCII(ExtensionsService::kInstallDirectoryName),
692 extension_pref_store));
693
690 DCHECK(!net_pref_observer_.get()); 694 DCHECK(!net_pref_observer_.get());
691 net_pref_observer_.reset(new NetPrefObserver(prefs_.get())); 695 net_pref_observer_.reset(new NetPrefObserver(prefs_.get()));
692 } 696 }
693 697
694 return prefs_.get(); 698 return prefs_.get();
695 } 699 }
696 700
697 FilePath ProfileImpl::GetPrefFilePath() { 701 FilePath ProfileImpl::GetPrefFilePath() {
698 FilePath pref_file_path = path_; 702 FilePath pref_file_path = path_;
699 pref_file_path = pref_file_path.Append(chrome::kPreferencesFilename); 703 pref_file_path = pref_file_path.Append(chrome::kPreferencesFilename);
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 new chromeos::EnterpriseExtensionObserver(this)); 1349 new chromeos::EnterpriseExtensionObserver(this));
1346 } 1350 }
1347 #endif // defined(OS_CHROMEOS) 1351 #endif // defined(OS_CHROMEOS)
1348 1352
1349 PrefProxyConfigTracker* ProfileImpl::GetProxyConfigTracker() { 1353 PrefProxyConfigTracker* ProfileImpl::GetProxyConfigTracker() {
1350 if (!pref_proxy_config_tracker_) 1354 if (!pref_proxy_config_tracker_)
1351 pref_proxy_config_tracker_ = new PrefProxyConfigTracker(GetPrefs()); 1355 pref_proxy_config_tracker_ = new PrefProxyConfigTracker(GetPrefs());
1352 1356
1353 return pref_proxy_config_tracker_; 1357 return pref_proxy_config_tracker_;
1354 } 1358 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698