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

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

Issue 10546083: Convert ProtocolHandlerRegistry to be a ProfileKeyedService. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Reduce differences between orig and updated test. Trying to figure out why tests fail on try server… Created 8 years, 5 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/environment.h" 10 #include "base/environment.h"
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/string_tokenizer.h" 15 #include "base/string_tokenizer.h"
16 #include "base/string_util.h" 16 #include "base/string_util.h"
17 #include "base/stringprintf.h" 17 #include "base/stringprintf.h"
18 #include "base/utf_string_conversions.h" 18 #include "base/utf_string_conversions.h"
19 #include "base/version.h" 19 #include "base/version.h"
20 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 20 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
21 #include "chrome/browser/background/background_contents_service_factory.h" 21 #include "chrome/browser/background/background_contents_service_factory.h"
22 #include "chrome/browser/background/background_mode_manager.h" 22 #include "chrome/browser/background/background_mode_manager.h"
23 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 23 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
24 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/chrome_plugin_service_filter.h" 25 #include "chrome/browser/chrome_plugin_service_filter.h"
26 #include "chrome/browser/content_settings/cookie_settings.h" 26 #include "chrome/browser/content_settings/cookie_settings.h"
27 #include "chrome/browser/content_settings/host_content_settings_map.h" 27 #include "chrome/browser/content_settings/host_content_settings_map.h"
28 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 28 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
29 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
29 #include "chrome/browser/download/download_service.h" 30 #include "chrome/browser/download/download_service.h"
30 #include "chrome/browser/download/download_service_factory.h" 31 #include "chrome/browser/download/download_service_factory.h"
31 #include "chrome/browser/extensions/extension_event_router.h" 32 #include "chrome/browser/extensions/extension_event_router.h"
32 #include "chrome/browser/extensions/extension_pref_store.h" 33 #include "chrome/browser/extensions/extension_pref_store.h"
33 #include "chrome/browser/extensions/extension_pref_value_map.h" 34 #include "chrome/browser/extensions/extension_pref_value_map.h"
34 #include "chrome/browser/extensions/extension_pref_value_map_factory.h" 35 #include "chrome/browser/extensions/extension_pref_value_map_factory.h"
35 #include "chrome/browser/extensions/extension_process_manager.h" 36 #include "chrome/browser/extensions/extension_process_manager.h"
36 #include "chrome/browser/extensions/extension_service.h" 37 #include "chrome/browser/extensions/extension_service.h"
37 #include "chrome/browser/extensions/extension_special_storage_policy.h" 38 #include "chrome/browser/extensions/extension_special_storage_policy.h"
38 #include "chrome/browser/extensions/extension_system.h" 39 #include "chrome/browser/extensions/extension_system.h"
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 bool init_background_mode_manager = true; 345 bool init_background_mode_manager = true;
345 #if defined(OS_CHROMEOS) 346 #if defined(OS_CHROMEOS)
346 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kKeepAliveForTest)) 347 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kKeepAliveForTest))
347 init_background_mode_manager = false; 348 init_background_mode_manager = false;
348 #endif 349 #endif
349 if (init_background_mode_manager) { 350 if (init_background_mode_manager) {
350 if (g_browser_process->background_mode_manager()) 351 if (g_browser_process->background_mode_manager())
351 g_browser_process->background_mode_manager()->RegisterProfile(this); 352 g_browser_process->background_mode_manager()->RegisterProfile(this);
352 } 353 }
353 354
354 InitRegisteredProtocolHandlers();
355
356 InstantController::RecordMetrics(this); 355 InstantController::RecordMetrics(this);
357 356
358 FilePath cookie_path = GetPath(); 357 FilePath cookie_path = GetPath();
359 cookie_path = cookie_path.Append(chrome::kCookieFilename); 358 cookie_path = cookie_path.Append(chrome::kCookieFilename);
360 FilePath server_bound_cert_path = GetPath(); 359 FilePath server_bound_cert_path = GetPath();
361 server_bound_cert_path = 360 server_bound_cert_path =
362 server_bound_cert_path.Append(chrome::kOBCertFilename); 361 server_bound_cert_path.Append(chrome::kOBCertFilename);
363 FilePath cache_path = base_cache_path_; 362 FilePath cache_path = base_cache_path_;
364 int cache_max_size; 363 int cache_max_size;
365 GetCacheParameters(false, &cache_path, &cache_max_size); 364 GetCacheParameters(false, &cache_path, &cache_max_size);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 void ProfileImpl::InitPromoResources() { 449 void ProfileImpl::InitPromoResources() {
451 #if defined(ENABLE_PROMO_RESOURCE_SERVICE) 450 #if defined(ENABLE_PROMO_RESOURCE_SERVICE)
452 if (promo_resource_service_) 451 if (promo_resource_service_)
453 return; 452 return;
454 453
455 promo_resource_service_ = new PromoResourceService(this); 454 promo_resource_service_ = new PromoResourceService(this);
456 promo_resource_service_->StartAfterDelay(); 455 promo_resource_service_->StartAfterDelay();
457 #endif 456 #endif
458 } 457 }
459 458
460 void ProfileImpl::InitRegisteredProtocolHandlers() {
461 if (protocol_handler_registry_)
462 return;
463 protocol_handler_registry_ = new ProtocolHandlerRegistry(this,
464 new ProtocolHandlerRegistry::Delegate());
465
466 // Install predefined protocol handlers.
467 InstallDefaultProtocolHandlers();
468
469 protocol_handler_registry_->Load();
470 }
471
472 void ProfileImpl::InstallDefaultProtocolHandlers() {
473 #if defined(OS_CHROMEOS)
474 protocol_handler_registry_->AddPredefinedHandler(
475 ProtocolHandler::CreateProtocolHandler(
476 "mailto",
477 GURL(l10n_util::GetStringUTF8(IDS_GOOGLE_MAILTO_HANDLER_URL)),
478 l10n_util::GetStringUTF16(IDS_GOOGLE_MAILTO_HANDLER_NAME)));
479 protocol_handler_registry_->AddPredefinedHandler(
480 ProtocolHandler::CreateProtocolHandler(
481 "webcal",
482 GURL(l10n_util::GetStringUTF8(IDS_GOOGLE_WEBCAL_HANDLER_URL)),
483 l10n_util::GetStringUTF16(IDS_GOOGLE_WEBCAL_HANDLER_NAME)));
484 #endif
485 }
486
487 FilePath ProfileImpl::last_selected_directory() { 459 FilePath ProfileImpl::last_selected_directory() {
488 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); 460 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory);
489 } 461 }
490 462
491 void ProfileImpl::set_last_selected_directory(const FilePath& path) { 463 void ProfileImpl::set_last_selected_directory(const FilePath& path) {
492 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); 464 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path);
493 } 465 }
494 466
495 ProfileImpl::~ProfileImpl() { 467 ProfileImpl::~ProfileImpl() {
496 content::NotificationService::current()->Notify( 468 content::NotificationService::current()->Notify(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 if (top_sites_.get()) 508 if (top_sites_.get())
537 top_sites_->Shutdown(); 509 top_sites_->Shutdown();
538 510
539 // FaviconService depends on HistoryServce so make sure we delete 511 // FaviconService depends on HistoryServce so make sure we delete
540 // HistoryService first. 512 // HistoryService first.
541 favicon_service_.reset(); 513 favicon_service_.reset();
542 514
543 if (pref_proxy_config_tracker_.get()) 515 if (pref_proxy_config_tracker_.get())
544 pref_proxy_config_tracker_->DetachFromPrefService(); 516 pref_proxy_config_tracker_->DetachFromPrefService();
545 517
546 if (protocol_handler_registry_)
547 protocol_handler_registry_->Finalize();
548
549 if (host_content_settings_map_) 518 if (host_content_settings_map_)
550 host_content_settings_map_->ShutdownOnUIThread(); 519 host_content_settings_map_->ShutdownOnUIThread();
551 520
552 // This causes the Preferences file to be written to disk. 521 // This causes the Preferences file to be written to disk.
553 if (prefs_loaded) 522 if (prefs_loaded)
554 MarkAsCleanShutdown(); 523 MarkAsCleanShutdown();
555 } 524 }
556 525
557 std::string ProfileImpl::GetProfileName() { 526 std::string ProfileImpl::GetProfileName() {
558 return GetPrefs()->GetString(prefs::kGoogleServicesUsername); 527 return GetPrefs()->GetString(prefs::kGoogleServicesUsername);
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 788
820 quota::SpecialStoragePolicy* ProfileImpl::GetSpecialStoragePolicy() { 789 quota::SpecialStoragePolicy* ProfileImpl::GetSpecialStoragePolicy() {
821 return GetExtensionSpecialStoragePolicy(); 790 return GetExtensionSpecialStoragePolicy();
822 } 791 }
823 792
824 BookmarkModel* ProfileImpl::GetBookmarkModel() { 793 BookmarkModel* ProfileImpl::GetBookmarkModel() {
825 return BookmarkModelFactory::GetForProfile(this); 794 return BookmarkModelFactory::GetForProfile(this);
826 } 795 }
827 796
828 ProtocolHandlerRegistry* ProfileImpl::GetProtocolHandlerRegistry() { 797 ProtocolHandlerRegistry* ProfileImpl::GetProtocolHandlerRegistry() {
829 return protocol_handler_registry_.get(); 798 // TODO(smckay): Update all existing callers to use
799 // ProtocolHandlerRegistryFactory. Once that's done, this method
800 // can be nuked from Profile and ProfileImpl.
801 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
802 return ProtocolHandlerRegistryFactory::GetForProfile(this);
830 } 803 }
831 804
832 bool ProfileImpl::IsSameProfile(Profile* profile) { 805 bool ProfileImpl::IsSameProfile(Profile* profile) {
833 if (profile == static_cast<Profile*>(this)) 806 if (profile == static_cast<Profile*>(this))
834 return true; 807 return true;
835 Profile* otr_profile = off_the_record_profile_.get(); 808 Profile* otr_profile = off_the_record_profile_.get();
836 return otr_profile && profile == otr_profile; 809 return otr_profile && profile == otr_profile;
837 } 810 }
838 811
839 Time ProfileImpl::GetStartTime() const { 812 Time ProfileImpl::GetStartTime() const {
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 if (!path.empty()) 1088 if (!path.empty())
1116 *cache_path = path; 1089 *cache_path = path;
1117 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : 1090 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) :
1118 prefs_->GetInteger(prefs::kDiskCacheSize); 1091 prefs_->GetInteger(prefs::kDiskCacheSize);
1119 } 1092 }
1120 1093
1121 base::Callback<ChromeURLDataManagerBackend*(void)> 1094 base::Callback<ChromeURLDataManagerBackend*(void)>
1122 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { 1095 ProfileImpl::GetChromeURLDataManagerBackendGetter() const {
1123 return io_data_.GetChromeURLDataManagerBackendGetter(); 1096 return io_data_.GetChromeURLDataManagerBackendGetter();
1124 } 1097 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698