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

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: Minor docu-changes. 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
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/profiles/profile_io_data.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_number_conversions.h" 15 #include "base/string_number_conversions.h"
16 #include "base/string_tokenizer.h" 16 #include "base/string_tokenizer.h"
17 #include "base/string_util.h" 17 #include "base/string_util.h"
18 #include "base/stringprintf.h" 18 #include "base/stringprintf.h"
19 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
20 #include "base/version.h" 20 #include "base/version.h"
21 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 21 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
22 #include "chrome/browser/background/background_contents_service_factory.h" 22 #include "chrome/browser/background/background_contents_service_factory.h"
23 #include "chrome/browser/background/background_mode_manager.h" 23 #include "chrome/browser/background/background_mode_manager.h"
24 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 24 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
25 #include "chrome/browser/browser_process.h" 25 #include "chrome/browser/browser_process.h"
26 #include "chrome/browser/chrome_plugin_service_filter.h" 26 #include "chrome/browser/chrome_plugin_service_filter.h"
27 #include "chrome/browser/content_settings/cookie_settings.h" 27 #include "chrome/browser/content_settings/cookie_settings.h"
28 #include "chrome/browser/content_settings/host_content_settings_map.h" 28 #include "chrome/browser/content_settings/host_content_settings_map.h"
29 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 29 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
30 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
30 #include "chrome/browser/download/download_service.h" 31 #include "chrome/browser/download/download_service.h"
31 #include "chrome/browser/download/download_service_factory.h" 32 #include "chrome/browser/download/download_service_factory.h"
32 #include "chrome/browser/extensions/extension_event_router.h" 33 #include "chrome/browser/extensions/extension_event_router.h"
33 #include "chrome/browser/extensions/extension_pref_store.h" 34 #include "chrome/browser/extensions/extension_pref_store.h"
34 #include "chrome/browser/extensions/extension_pref_value_map.h" 35 #include "chrome/browser/extensions/extension_pref_value_map.h"
35 #include "chrome/browser/extensions/extension_pref_value_map_factory.h" 36 #include "chrome/browser/extensions/extension_pref_value_map_factory.h"
36 #include "chrome/browser/extensions/extension_process_manager.h" 37 #include "chrome/browser/extensions/extension_process_manager.h"
37 #include "chrome/browser/extensions/extension_service.h" 38 #include "chrome/browser/extensions/extension_service.h"
38 #include "chrome/browser/extensions/extension_special_storage_policy.h" 39 #include "chrome/browser/extensions/extension_special_storage_policy.h"
39 #include "chrome/browser/extensions/extension_system.h" 40 #include "chrome/browser/extensions/extension_system.h"
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 bool init_background_mode_manager = true; 344 bool init_background_mode_manager = true;
344 #if defined(OS_CHROMEOS) 345 #if defined(OS_CHROMEOS)
345 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kKeepAliveForTest)) 346 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kKeepAliveForTest))
346 init_background_mode_manager = false; 347 init_background_mode_manager = false;
347 #endif 348 #endif
348 if (init_background_mode_manager) { 349 if (init_background_mode_manager) {
349 if (g_browser_process->background_mode_manager()) 350 if (g_browser_process->background_mode_manager())
350 g_browser_process->background_mode_manager()->RegisterProfile(this); 351 g_browser_process->background_mode_manager()->RegisterProfile(this);
351 } 352 }
352 353
353 InitRegisteredProtocolHandlers();
354
355 InstantController::RecordMetrics(this); 354 InstantController::RecordMetrics(this);
356 355
357 FilePath cookie_path = GetPath(); 356 FilePath cookie_path = GetPath();
358 cookie_path = cookie_path.Append(chrome::kCookieFilename); 357 cookie_path = cookie_path.Append(chrome::kCookieFilename);
359 FilePath server_bound_cert_path = GetPath(); 358 FilePath server_bound_cert_path = GetPath();
360 server_bound_cert_path = 359 server_bound_cert_path =
361 server_bound_cert_path.Append(chrome::kOBCertFilename); 360 server_bound_cert_path.Append(chrome::kOBCertFilename);
362 FilePath cache_path = base_cache_path_; 361 FilePath cache_path = base_cache_path_;
363 int cache_max_size; 362 int cache_max_size;
364 GetCacheParameters(false, &cache_path, &cache_max_size); 363 GetCacheParameters(false, &cache_path, &cache_max_size);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 content::Source<HostZoomMap>(host_zoom_map)); 445 content::Source<HostZoomMap>(host_zoom_map));
447 } 446 }
448 447
449 void ProfileImpl::InitPromoResources() { 448 void ProfileImpl::InitPromoResources() {
450 if (promo_resource_service_) 449 if (promo_resource_service_)
451 return; 450 return;
452 promo_resource_service_ = new PromoResourceService(this); 451 promo_resource_service_ = new PromoResourceService(this);
453 promo_resource_service_->StartAfterDelay(); 452 promo_resource_service_->StartAfterDelay();
454 } 453 }
455 454
456 void ProfileImpl::InitRegisteredProtocolHandlers() {
457 if (protocol_handler_registry_)
458 return;
459 protocol_handler_registry_ = new ProtocolHandlerRegistry(this,
460 new ProtocolHandlerRegistry::Delegate());
461
462 // Install predefined protocol handlers.
463 InstallDefaultProtocolHandlers();
464
465 protocol_handler_registry_->Load();
466 }
467
468 void ProfileImpl::InstallDefaultProtocolHandlers() {
469 #if defined(OS_CHROMEOS)
470 protocol_handler_registry_->AddPredefinedHandler(
471 ProtocolHandler::CreateProtocolHandler(
472 "mailto",
473 GURL(l10n_util::GetStringUTF8(IDS_GOOGLE_MAILTO_HANDLER_URL)),
474 l10n_util::GetStringUTF16(IDS_GOOGLE_MAILTO_HANDLER_NAME)));
475 protocol_handler_registry_->AddPredefinedHandler(
476 ProtocolHandler::CreateProtocolHandler(
477 "webcal",
478 GURL(l10n_util::GetStringUTF8(IDS_GOOGLE_WEBCAL_HANDLER_URL)),
479 l10n_util::GetStringUTF16(IDS_GOOGLE_WEBCAL_HANDLER_NAME)));
480 #endif
481 }
482
483 FilePath ProfileImpl::last_selected_directory() { 455 FilePath ProfileImpl::last_selected_directory() {
484 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); 456 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory);
485 } 457 }
486 458
487 void ProfileImpl::set_last_selected_directory(const FilePath& path) { 459 void ProfileImpl::set_last_selected_directory(const FilePath& path) {
488 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); 460 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path);
489 } 461 }
490 462
491 ProfileImpl::~ProfileImpl() { 463 ProfileImpl::~ProfileImpl() {
492 content::NotificationService::current()->Notify( 464 content::NotificationService::current()->Notify(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 if (top_sites_.get()) 499 if (top_sites_.get())
528 top_sites_->Shutdown(); 500 top_sites_->Shutdown();
529 501
530 // FaviconService depends on HistoryServce so make sure we delete 502 // FaviconService depends on HistoryServce so make sure we delete
531 // HistoryService first. 503 // HistoryService first.
532 favicon_service_.reset(); 504 favicon_service_.reset();
533 505
534 if (pref_proxy_config_tracker_.get()) 506 if (pref_proxy_config_tracker_.get())
535 pref_proxy_config_tracker_->DetachFromPrefService(); 507 pref_proxy_config_tracker_->DetachFromPrefService();
536 508
537 if (protocol_handler_registry_)
538 protocol_handler_registry_->Finalize();
539
540 if (host_content_settings_map_) 509 if (host_content_settings_map_)
541 host_content_settings_map_->ShutdownOnUIThread(); 510 host_content_settings_map_->ShutdownOnUIThread();
542 511
543 // This causes the Preferences file to be written to disk. 512 // This causes the Preferences file to be written to disk.
544 if (prefs_loaded) 513 if (prefs_loaded)
545 MarkAsCleanShutdown(); 514 MarkAsCleanShutdown();
546 } 515 }
547 516
548 std::string ProfileImpl::GetProfileName() { 517 std::string ProfileImpl::GetProfileName() {
549 return GetPrefs()->GetString(prefs::kGoogleServicesUsername); 518 return GetPrefs()->GetString(prefs::kGoogleServicesUsername);
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 774
806 quota::SpecialStoragePolicy* ProfileImpl::GetSpecialStoragePolicy() { 775 quota::SpecialStoragePolicy* ProfileImpl::GetSpecialStoragePolicy() {
807 return GetExtensionSpecialStoragePolicy(); 776 return GetExtensionSpecialStoragePolicy();
808 } 777 }
809 778
810 BookmarkModel* ProfileImpl::GetBookmarkModel() { 779 BookmarkModel* ProfileImpl::GetBookmarkModel() {
811 return BookmarkModelFactory::GetForProfile(this); 780 return BookmarkModelFactory::GetForProfile(this);
812 } 781 }
813 782
814 ProtocolHandlerRegistry* ProfileImpl::GetProtocolHandlerRegistry() { 783 ProtocolHandlerRegistry* ProfileImpl::GetProtocolHandlerRegistry() {
815 return protocol_handler_registry_.get(); 784 // TODO(smckay): Update all existing callers to use
785 // ProtocolHandlerRegistryFactory. Once that's done, this method
786 // can be nuked from Profile and ProfileImpl.
787 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
788 return ProtocolHandlerRegistryFactory::GetForProfile(this);
816 } 789 }
817 790
818 bool ProfileImpl::IsSameProfile(Profile* profile) { 791 bool ProfileImpl::IsSameProfile(Profile* profile) {
819 if (profile == static_cast<Profile*>(this)) 792 if (profile == static_cast<Profile*>(this))
820 return true; 793 return true;
821 Profile* otr_profile = off_the_record_profile_.get(); 794 Profile* otr_profile = off_the_record_profile_.get();
822 return otr_profile && profile == otr_profile; 795 return otr_profile && profile == otr_profile;
823 } 796 }
824 797
825 Time ProfileImpl::GetStartTime() const { 798 Time ProfileImpl::GetStartTime() const {
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 if (!path.empty()) 1074 if (!path.empty())
1102 *cache_path = path; 1075 *cache_path = path;
1103 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : 1076 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) :
1104 prefs_->GetInteger(prefs::kDiskCacheSize); 1077 prefs_->GetInteger(prefs::kDiskCacheSize);
1105 } 1078 }
1106 1079
1107 base::Callback<ChromeURLDataManagerBackend*(void)> 1080 base::Callback<ChromeURLDataManagerBackend*(void)>
1108 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { 1081 ProfileImpl::GetChromeURLDataManagerBackendGetter() const {
1109 return io_data_.GetChromeURLDataManagerBackendGetter(); 1082 return io_data_.GetChromeURLDataManagerBackendGetter();
1110 } 1083 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/profiles/profile_io_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698