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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 spellcheck_host_(NULL), | 285 spellcheck_host_(NULL), |
286 spellcheck_host_ready_(false), | 286 spellcheck_host_ready_(false), |
287 shutdown_session_service_(false) { | 287 shutdown_session_service_(false) { |
288 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << | 288 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << |
289 "profile files to the root directory!"; | 289 "profile files to the root directory!"; |
290 create_session_service_timer_.Start( | 290 create_session_service_timer_.Start( |
291 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, | 291 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, |
292 &ProfileImpl::EnsureSessionServiceCreated); | 292 &ProfileImpl::EnsureSessionServiceCreated); |
293 | 293 |
294 PrefService* prefs = GetPrefs(); | 294 PrefService* prefs = GetPrefs(); |
295 prefs->AddPrefObserver(prefs::kSpellCheckDictionary, this); | 295 pref_change_registrar_.Init(prefs); |
296 prefs->AddPrefObserver(prefs::kEnableSpellCheck, this); | 296 pref_change_registrar_.Add(prefs::kSpellCheckDictionary, this); |
297 prefs->AddPrefObserver(prefs::kEnableAutoSpellCorrect, this); | 297 pref_change_registrar_.Add(prefs::kEnableSpellCheck, this); |
| 298 pref_change_registrar_.Add(prefs::kEnableAutoSpellCorrect, this); |
298 | 299 |
299 #if defined(OS_MACOSX) | 300 #if defined(OS_MACOSX) |
300 // If the profile directory doesn't already have a cache directory and it | 301 // If the profile directory doesn't already have a cache directory and it |
301 // is under ~/Library/Application Support, use a suitable cache directory | 302 // is under ~/Library/Application Support, use a suitable cache directory |
302 // under ~/Library/Caches. For example, a profile directory of | 303 // under ~/Library/Caches. For example, a profile directory of |
303 // ~/Library/Application Support/Google/Chrome/MyProfileName that doesn't | 304 // ~/Library/Application Support/Google/Chrome/MyProfileName that doesn't |
304 // have a "Cache" or "MediaCache" subdirectory would use the cache directory | 305 // have a "Cache" or "MediaCache" subdirectory would use the cache directory |
305 // ~/Library/Caches/Google/Chrome/MyProfileName. | 306 // ~/Library/Caches/Google/Chrome/MyProfileName. |
306 // | 307 // |
307 // TODO(akalin): Come up with unit tests for this. | 308 // TODO(akalin): Come up with unit tests for this. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 ExtensionErrorReporter::Init(true); // allow noisy errors. | 384 ExtensionErrorReporter::Init(true); // allow noisy errors. |
384 | 385 |
385 FilePath script_dir; // Don't look for user scripts in any directory. | 386 FilePath script_dir; // Don't look for user scripts in any directory. |
386 // TODO(aa): We should just remove this functionality, | 387 // TODO(aa): We should just remove this functionality, |
387 // since it isn't used anymore. | 388 // since it isn't used anymore. |
388 user_script_master_ = new UserScriptMaster(script_dir, this); | 389 user_script_master_ = new UserScriptMaster(script_dir, this); |
389 | 390 |
390 extensions_service_ = new ExtensionsService( | 391 extensions_service_ = new ExtensionsService( |
391 this, | 392 this, |
392 CommandLine::ForCurrentProcess(), | 393 CommandLine::ForCurrentProcess(), |
393 GetPrefs(), | |
394 GetPath().AppendASCII(ExtensionsService::kInstallDirectoryName), | 394 GetPath().AppendASCII(ExtensionsService::kInstallDirectoryName), |
395 true); | 395 true); |
396 | 396 |
397 // Register the component extensions. | 397 // Register the component extensions. |
398 typedef std::list<std::pair<std::string, int> > ComponentExtensionList; | 398 typedef std::list<std::pair<std::string, int> > ComponentExtensionList; |
399 ComponentExtensionList component_extensions; | 399 ComponentExtensionList component_extensions; |
400 | 400 |
401 // Bookmark manager. | 401 // Bookmark manager. |
402 component_extensions.push_back( | 402 component_extensions.push_back( |
403 std::make_pair("bookmark_manager", IDR_BOOKMARKS_MANIFEST)); | 403 std::make_pair("bookmark_manager", IDR_BOOKMARKS_MANIFEST)); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 if (download_manager_.get()) { | 494 if (download_manager_.get()) { |
495 // The download manager queries the history system and should be shutdown | 495 // The download manager queries the history system and should be shutdown |
496 // before the history is shutdown so it can properly cancel all requests. | 496 // before the history is shutdown so it can properly cancel all requests. |
497 download_manager_->Shutdown(); | 497 download_manager_->Shutdown(); |
498 download_manager_ = NULL; | 498 download_manager_ = NULL; |
499 } | 499 } |
500 | 500 |
501 // The theme provider provides bitmaps to whoever wants them. | 501 // The theme provider provides bitmaps to whoever wants them. |
502 theme_provider_.reset(); | 502 theme_provider_.reset(); |
503 | 503 |
504 // Remove pref observers. | 504 // Remove pref observers |
505 PrefService* prefs = GetPrefs(); | 505 pref_change_registrar_.RemoveAll(); |
506 prefs->RemovePrefObserver(prefs::kSpellCheckDictionary, this); | |
507 prefs->RemovePrefObserver(prefs::kEnableSpellCheck, this); | |
508 prefs->RemovePrefObserver(prefs::kEnableAutoSpellCorrect, this); | |
509 | 506 |
510 // Delete the NTP resource cache so we can unregister pref observers. | 507 // Delete the NTP resource cache so we can unregister pref observers. |
511 ntp_resource_cache_.reset(); | 508 ntp_resource_cache_.reset(); |
512 | 509 |
513 // The sync service needs to be deleted before the services it calls. | 510 // The sync service needs to be deleted before the services it calls. |
514 sync_service_.reset(); | 511 sync_service_.reset(); |
515 | 512 |
516 // Both HistoryService and WebDataService maintain threads for background | 513 // Both HistoryService and WebDataService maintain threads for background |
517 // processing. Its possible each thread still has tasks on it that have | 514 // processing. Its possible each thread still has tasks on it that have |
518 // increased the ref count of the service. In such a situation, when we | 515 // increased the ref count of the service. In such a situation, when we |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 #if defined(OS_CHROMEOS) | 1313 #if defined(OS_CHROMEOS) |
1317 chromeos::ProxyConfigServiceImpl* | 1314 chromeos::ProxyConfigServiceImpl* |
1318 ProfileImpl::GetChromeOSProxyConfigServiceImpl() { | 1315 ProfileImpl::GetChromeOSProxyConfigServiceImpl() { |
1319 if (!chromeos_proxy_config_service_impl_) { | 1316 if (!chromeos_proxy_config_service_impl_) { |
1320 chromeos_proxy_config_service_impl_ = | 1317 chromeos_proxy_config_service_impl_ = |
1321 new chromeos::ProxyConfigServiceImpl(); | 1318 new chromeos::ProxyConfigServiceImpl(); |
1322 } | 1319 } |
1323 return chromeos_proxy_config_service_impl_; | 1320 return chromeos_proxy_config_service_impl_; |
1324 } | 1321 } |
1325 #endif // defined(OS_CHROMEOS) | 1322 #endif // defined(OS_CHROMEOS) |
OLD | NEW |