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

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: Update ProtocolHandlerRegistry to be a ProfileKeyedService in lieu of a refcounted pointer. Created 8 years, 6 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.h" 23 #include "chrome/browser/bookmarks/bookmark_model.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"
39 #include "chrome/browser/extensions/user_script_master.h" 40 #include "chrome/browser/extensions/user_script_master.h"
40 #include "chrome/browser/favicon/favicon_service.h" 41 #include "chrome/browser/favicon/favicon_service.h"
41 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" 42 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h"
42 #include "chrome/browser/history/history.h" 43 #include "chrome/browser/history/history.h"
43 #include "chrome/browser/history/shortcuts_backend.h" 44 #include "chrome/browser/history/shortcuts_backend.h"
44 #include "chrome/browser/history/top_sites.h" 45 #include "chrome/browser/history/top_sites.h"
45 #include "chrome/browser/instant/instant_controller.h" 46 #include "chrome/browser/instant/instant_controller.h"
47 #include "chrome/browser/intents/web_intents_registry.h"
48 #include "chrome/browser/intents/web_intents_registry_factory.h"
46 #include "chrome/browser/metrics/metrics_service.h" 49 #include "chrome/browser/metrics/metrics_service.h"
47 #include "chrome/browser/net/chrome_url_request_context.h" 50 #include "chrome/browser/net/chrome_url_request_context.h"
48 #include "chrome/browser/net/net_pref_observer.h" 51 #include "chrome/browser/net/net_pref_observer.h"
49 #include "chrome/browser/net/predictor.h" 52 #include "chrome/browser/net/predictor.h"
50 #include "chrome/browser/net/proxy_service_factory.h" 53 #include "chrome/browser/net/proxy_service_factory.h"
51 #include "chrome/browser/net/ssl_config_service_manager.h" 54 #include "chrome/browser/net/ssl_config_service_manager.h"
52 #include "chrome/browser/net/url_fixer_upper.h" 55 #include "chrome/browser/net/url_fixer_upper.h"
53 #include "chrome/browser/plugin_prefs.h" 56 #include "chrome/browser/plugin_prefs.h"
54 #include "chrome/browser/policy/policy_service.h" 57 #include "chrome/browser/policy/policy_service.h"
55 #include "chrome/browser/prefs/browser_prefs.h" 58 #include "chrome/browser/prefs/browser_prefs.h"
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 void ProfileImpl::InitPromoResources() { 438 void ProfileImpl::InitPromoResources() {
436 #if defined(ENABLE_PROMO_RESOURCE_SERVICE) 439 #if defined(ENABLE_PROMO_RESOURCE_SERVICE)
437 if (promo_resource_service_) 440 if (promo_resource_service_)
438 return; 441 return;
439 442
440 promo_resource_service_ = new PromoResourceService(this); 443 promo_resource_service_ = new PromoResourceService(this);
441 promo_resource_service_->StartAfterDelay(); 444 promo_resource_service_->StartAfterDelay();
442 #endif 445 #endif
443 } 446 }
444 447
448 // TODO(smckay): Handle in profile_dependency_manager,
449 // then replace calls to GetProtocolHandlerRegistry
450 // with factory.
445 void ProfileImpl::InitRegisteredProtocolHandlers() { 451 void ProfileImpl::InitRegisteredProtocolHandlers() {
446 if (protocol_handler_registry_) 452 // TODO(smckay): delete me
447 return;
448 protocol_handler_registry_ = new ProtocolHandlerRegistry(this,
449 new ProtocolHandlerRegistry::Delegate());
450
451 // Install predefined protocol handlers.
452 InstallDefaultProtocolHandlers();
453
454 protocol_handler_registry_->Load();
455 }
456
457 void ProfileImpl::InstallDefaultProtocolHandlers() {
458 #if defined(OS_CHROMEOS)
459 protocol_handler_registry_->AddPredefinedHandler(
460 ProtocolHandler::CreateProtocolHandler(
461 "mailto",
462 GURL(l10n_util::GetStringUTF8(IDS_GOOGLE_MAILTO_HANDLER_URL)),
463 l10n_util::GetStringUTF16(IDS_GOOGLE_MAILTO_HANDLER_NAME)));
464 protocol_handler_registry_->AddPredefinedHandler(
465 ProtocolHandler::CreateProtocolHandler(
466 "webcal",
467 GURL(l10n_util::GetStringUTF8(IDS_GOOGLE_WEBCAL_HANDLER_URL)),
468 l10n_util::GetStringUTF16(IDS_GOOGLE_WEBCAL_HANDLER_NAME)));
469 #endif
470 } 453 }
471 454
472 FilePath ProfileImpl::last_selected_directory() { 455 FilePath ProfileImpl::last_selected_directory() {
473 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); 456 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory);
474 } 457 }
475 458
476 void ProfileImpl::set_last_selected_directory(const FilePath& path) { 459 void ProfileImpl::set_last_selected_directory(const FilePath& path) {
477 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); 460 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path);
478 } 461 }
479 462
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 history_service_ = NULL; 521 history_service_ = NULL;
539 bookmark_bar_model_.reset(); 522 bookmark_bar_model_.reset();
540 523
541 // FaviconService depends on HistoryServce so make sure we delete 524 // FaviconService depends on HistoryServce so make sure we delete
542 // HistoryService first. 525 // HistoryService first.
543 favicon_service_.reset(); 526 favicon_service_.reset();
544 527
545 if (pref_proxy_config_tracker_.get()) 528 if (pref_proxy_config_tracker_.get())
546 pref_proxy_config_tracker_->DetachFromPrefService(); 529 pref_proxy_config_tracker_->DetachFromPrefService();
547 530
548 if (protocol_handler_registry_)
549 protocol_handler_registry_->Finalize();
550
551 if (host_content_settings_map_) 531 if (host_content_settings_map_)
552 host_content_settings_map_->ShutdownOnUIThread(); 532 host_content_settings_map_->ShutdownOnUIThread();
553 533
554 // This causes the Preferences file to be written to disk. 534 // This causes the Preferences file to be written to disk.
555 if (prefs_loaded) 535 if (prefs_loaded)
556 MarkAsCleanShutdown(); 536 MarkAsCleanShutdown();
557 } 537 }
558 538
559 std::string ProfileImpl::GetProfileName() { 539 std::string ProfileImpl::GetProfileName() {
560 return GetPrefs()->GetString(prefs::kGoogleServicesUsername); 540 return GetPrefs()->GetString(prefs::kGoogleServicesUsername);
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 824
845 BookmarkModel* ProfileImpl::GetBookmarkModel() { 825 BookmarkModel* ProfileImpl::GetBookmarkModel() {
846 if (!bookmark_bar_model_.get()) { 826 if (!bookmark_bar_model_.get()) {
847 bookmark_bar_model_.reset(new BookmarkModel(this)); 827 bookmark_bar_model_.reset(new BookmarkModel(this));
848 bookmark_bar_model_->Load(); 828 bookmark_bar_model_->Load();
849 } 829 }
850 return bookmark_bar_model_.get(); 830 return bookmark_bar_model_.get();
851 } 831 }
852 832
853 ProtocolHandlerRegistry* ProfileImpl::GetProtocolHandlerRegistry() { 833 ProtocolHandlerRegistry* ProfileImpl::GetProtocolHandlerRegistry() {
854 return protocol_handler_registry_.get(); 834 // TODO(smckay): delete me
835 return ProtocolHandlerRegistryFactory::GetForProfile(this);
855 } 836 }
856 837
857 bool ProfileImpl::IsSameProfile(Profile* profile) { 838 bool ProfileImpl::IsSameProfile(Profile* profile) {
858 if (profile == static_cast<Profile*>(this)) 839 if (profile == static_cast<Profile*>(this))
859 return true; 840 return true;
860 Profile* otr_profile = off_the_record_profile_.get(); 841 Profile* otr_profile = off_the_record_profile_.get();
861 return otr_profile && profile == otr_profile; 842 return otr_profile && profile == otr_profile;
862 } 843 }
863 844
864 Time ProfileImpl::GetStartTime() const { 845 Time ProfileImpl::GetStartTime() const {
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 if (!path.empty()) 1121 if (!path.empty())
1141 *cache_path = path; 1122 *cache_path = path;
1142 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : 1123 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) :
1143 prefs_->GetInteger(prefs::kDiskCacheSize); 1124 prefs_->GetInteger(prefs::kDiskCacheSize);
1144 } 1125 }
1145 1126
1146 base::Callback<ChromeURLDataManagerBackend*(void)> 1127 base::Callback<ChromeURLDataManagerBackend*(void)>
1147 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { 1128 ProfileImpl::GetChromeURLDataManagerBackendGetter() const {
1148 return io_data_.GetChromeURLDataManagerBackendGetter(); 1129 return io_data_.GetChromeURLDataManagerBackendGetter();
1149 } 1130 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698