| 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/profile_impl.h" | 5 #include "chrome/browser/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/find_bar_state.h" | 44 #include "chrome/browser/find_bar_state.h" |
| 44 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" | 45 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" |
| 45 #include "chrome/browser/geolocation/geolocation_permission_context.h" | 46 #include "chrome/browser/geolocation/geolocation_permission_context.h" |
| 46 #include "chrome/browser/history/history.h" | 47 #include "chrome/browser/history/history.h" |
| 47 #include "chrome/browser/history/top_sites.h" | 48 #include "chrome/browser/history/top_sites.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 created_web_data_service_(false), | 255 created_web_data_service_(false), |
| 255 created_password_store_(false), | 256 created_password_store_(false), |
| 256 created_download_manager_(false), | 257 created_download_manager_(false), |
| 257 created_theme_provider_(false), | 258 created_theme_provider_(false), |
| 258 start_time_(Time::Now()), | 259 start_time_(Time::Now()), |
| 259 spellcheck_host_(NULL), | 260 spellcheck_host_(NULL), |
| 260 spellcheck_host_ready_(false), | 261 spellcheck_host_ready_(false), |
| 261 #if defined(OS_WIN) | 262 #if defined(OS_WIN) |
| 262 checked_instant_promo_(false), | 263 checked_instant_promo_(false), |
| 263 #endif | 264 #endif |
| 264 shutdown_session_service_(false) { | 265 shutdown_session_service_(false), |
| 266 extension_prefs_(NULL) { |
| 265 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << | 267 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << |
| 266 "profile files to the root directory!"; | 268 "profile files to the root directory!"; |
| 267 create_session_service_timer_.Start( | 269 create_session_service_timer_.Start( |
| 268 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, | 270 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, |
| 269 &ProfileImpl::EnsureSessionServiceCreated); | 271 &ProfileImpl::EnsureSessionServiceCreated); |
| 270 | 272 |
| 271 PrefService* prefs = GetPrefs(); | 273 PrefService* prefs = GetPrefs(); |
| 272 pref_change_registrar_.Init(prefs); | 274 pref_change_registrar_.Init(prefs); |
| 273 pref_change_registrar_.Add(prefs::kSpellCheckDictionary, this); | 275 pref_change_registrar_.Add(prefs::kSpellCheckDictionary, this); |
| 274 pref_change_registrar_.Add(prefs::kEnableSpellCheck, this); | 276 pref_change_registrar_.Add(prefs::kEnableSpellCheck, this); |
| 275 pref_change_registrar_.Add(prefs::kEnableAutoSpellCorrect, this); | 277 pref_change_registrar_.Add(prefs::kEnableAutoSpellCorrect, this); |
| 276 pref_change_registrar_.Add(prefs::kClearSiteDataOnExit, this); | 278 pref_change_registrar_.Add(prefs::kClearSiteDataOnExit, this); |
| 277 | 279 |
| 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 this, |
| 284 GetPrefs(), |
| 285 GetPath().AppendASCII(ExtensionsService::kInstallDirectoryName))); |
| 286 |
| 278 // Convert active labs into switches. Modifies the current command line. | 287 // Convert active labs into switches. Modifies the current command line. |
| 279 about_flags::ConvertFlagsToSwitches(prefs, CommandLine::ForCurrentProcess()); | 288 about_flags::ConvertFlagsToSwitches(prefs, CommandLine::ForCurrentProcess()); |
| 280 | 289 |
| 281 // It would be nice to use PathService for fetching this directory, but | 290 // It would be nice to use PathService for fetching this directory, but |
| 282 // the cache directory depends on the profile directory, which isn't available | 291 // the cache directory depends on the profile directory, which isn't available |
| 283 // to PathService. | 292 // to PathService. |
| 284 chrome::GetUserCacheDirectory(path_, &base_cache_path_); | 293 chrome::GetUserCacheDirectory(path_, &base_cache_path_); |
| 285 file_util::CreateDirectory(base_cache_path_); | 294 file_util::CreateDirectory(base_cache_path_); |
| 286 | 295 |
| 287 // Listen for theme installations from our original profile. | 296 // Listen for theme installations from our original profile. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 | 355 |
| 347 FilePath script_dir; // Don't look for user scripts in any directory. | 356 FilePath script_dir; // Don't look for user scripts in any directory. |
| 348 // TODO(aa): We should just remove this functionality, | 357 // TODO(aa): We should just remove this functionality, |
| 349 // since it isn't used anymore. | 358 // since it isn't used anymore. |
| 350 user_script_master_ = new UserScriptMaster(script_dir, this); | 359 user_script_master_ = new UserScriptMaster(script_dir, this); |
| 351 | 360 |
| 352 extensions_service_ = new ExtensionsService( | 361 extensions_service_ = new ExtensionsService( |
| 353 this, | 362 this, |
| 354 CommandLine::ForCurrentProcess(), | 363 CommandLine::ForCurrentProcess(), |
| 355 GetPath().AppendASCII(ExtensionsService::kInstallDirectoryName), | 364 GetPath().AppendASCII(ExtensionsService::kInstallDirectoryName), |
| 365 extension_prefs_.get(), |
| 356 true); | 366 true); |
| 357 | 367 |
| 358 RegisterComponentExtensions(); | 368 RegisterComponentExtensions(); |
| 359 extensions_service_->Init(); | 369 extensions_service_->Init(); |
| 360 InstallDefaultApps(); | 370 InstallDefaultApps(); |
| 361 | 371 |
| 362 // Load any extensions specified with --load-extension. | 372 // Load any extensions specified with --load-extension. |
| 363 if (command_line->HasSwitch(switches::kLoadExtension)) { | 373 if (command_line->HasSwitch(switches::kLoadExtension)) { |
| 364 FilePath path = command_line->GetSwitchValuePath(switches::kLoadExtension); | 374 FilePath path = command_line->GetSwitchValuePath(switches::kLoadExtension); |
| 365 extensions_service_->LoadExtension(path); | 375 extensions_service_->LoadExtension(path); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 // Make sure we save to disk that the session has opened. | 689 // Make sure we save to disk that the session has opened. |
| 680 prefs_->ScheduleSavePersistentPrefs(); | 690 prefs_->ScheduleSavePersistentPrefs(); |
| 681 | 691 |
| 682 DCHECK(!net_pref_observer_.get()); | 692 DCHECK(!net_pref_observer_.get()); |
| 683 net_pref_observer_.reset(new NetPrefObserver(prefs_.get())); | 693 net_pref_observer_.reset(new NetPrefObserver(prefs_.get())); |
| 684 } | 694 } |
| 685 | 695 |
| 686 return prefs_.get(); | 696 return prefs_.get(); |
| 687 } | 697 } |
| 688 | 698 |
| 699 PrefStore* ProfileImpl::GetExtensionPrefStore() { |
| 700 return ext_pref_store_; |
| 701 } |
| 702 |
| 703 void ProfileImpl::SetExtensionPrefStore(PrefStore* ext_pref_store) { |
| 704 ext_pref_store_ = ext_pref_store; |
| 705 } |
| 706 |
| 689 FilePath ProfileImpl::GetPrefFilePath() { | 707 FilePath ProfileImpl::GetPrefFilePath() { |
| 690 FilePath pref_file_path = path_; | 708 FilePath pref_file_path = path_; |
| 691 pref_file_path = pref_file_path.Append(chrome::kPreferencesFilename); | 709 pref_file_path = pref_file_path.Append(chrome::kPreferencesFilename); |
| 692 return pref_file_path; | 710 return pref_file_path; |
| 693 } | 711 } |
| 694 | 712 |
| 695 URLRequestContextGetter* ProfileImpl::GetRequestContext() { | 713 URLRequestContextGetter* ProfileImpl::GetRequestContext() { |
| 696 if (!request_context_) { | 714 if (!request_context_) { |
| 697 FilePath cookie_path = GetPath(); | 715 FilePath cookie_path = GetPath(); |
| 698 cookie_path = cookie_path.Append(chrome::kCookieFilename); | 716 cookie_path = cookie_path.Append(chrome::kCookieFilename); |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 return chromeos_proxy_config_service_impl_; | 1349 return chromeos_proxy_config_service_impl_; |
| 1332 } | 1350 } |
| 1333 #endif // defined(OS_CHROMEOS) | 1351 #endif // defined(OS_CHROMEOS) |
| 1334 | 1352 |
| 1335 PrefProxyConfigTracker* ProfileImpl::GetProxyConfigTracker() { | 1353 PrefProxyConfigTracker* ProfileImpl::GetProxyConfigTracker() { |
| 1336 if (!pref_proxy_config_tracker_) | 1354 if (!pref_proxy_config_tracker_) |
| 1337 pref_proxy_config_tracker_ = new PrefProxyConfigTracker(GetPrefs()); | 1355 pref_proxy_config_tracker_ = new PrefProxyConfigTracker(GetPrefs()); |
| 1338 | 1356 |
| 1339 return pref_proxy_config_tracker_; | 1357 return pref_proxy_config_tracker_; |
| 1340 } | 1358 } |
| OLD | NEW |