| OLD | NEW |
| 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/custom_handlers/protocol_handler_registry.h" | 5 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg
ate.h" | 12 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg
ate.h" |
| 13 #include "chrome/browser/net/chrome_url_request_context.h" | 13 #include "chrome/browser/net/chrome_url_request_context.h" |
| 14 #include "chrome/browser/prefs/pref_registry_syncable.h" |
| 14 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
| 15 #include "chrome/browser/profiles/profile_io_data.h" | 16 #include "chrome/browser/profiles/profile_io_data.h" |
| 16 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
| 17 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/common/custom_handlers/protocol_handler.h" | 19 #include "chrome/common/custom_handlers/protocol_handler.h" |
| 19 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 20 #include "content/public/browser/child_process_security_policy.h" | 21 #include "content/public/browser/child_process_security_policy.h" |
| 21 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
| 22 #include "net/base/network_delegate.h" | 23 #include "net/base/network_delegate.h" |
| 23 #include "net/url_request/url_request_redirect_job.h" | 24 #include "net/url_request/url_request_redirect_job.h" |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 // protocol handler registry after it was deleted. | 726 // protocol handler registry after it was deleted. |
| 726 // Observers remove themselves from this list when they are deleted; so | 727 // Observers remove themselves from this list when they are deleted; so |
| 727 // we delete the last item until none are left in the list. | 728 // we delete the last item until none are left in the list. |
| 728 while (!default_client_observers_.empty()) { | 729 while (!default_client_observers_.empty()) { |
| 729 delete default_client_observers_.back(); | 730 delete default_client_observers_.back(); |
| 730 } | 731 } |
| 731 } | 732 } |
| 732 | 733 |
| 733 // static | 734 // static |
| 734 void ProtocolHandlerRegistry::RegisterUserPrefs( | 735 void ProtocolHandlerRegistry::RegisterUserPrefs( |
| 735 PrefServiceSyncable* pref_service) { | 736 PrefRegistrySyncable* registry) { |
| 736 pref_service->RegisterListPref(prefs::kRegisteredProtocolHandlers, | 737 registry->RegisterListPref(prefs::kRegisteredProtocolHandlers, |
| 737 PrefServiceSyncable::UNSYNCABLE_PREF); | 738 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 738 pref_service->RegisterListPref(prefs::kIgnoredProtocolHandlers, | 739 registry->RegisterListPref(prefs::kIgnoredProtocolHandlers, |
| 739 PrefServiceSyncable::UNSYNCABLE_PREF); | 740 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 740 pref_service->RegisterBooleanPref(prefs::kCustomHandlersEnabled, true, | 741 registry->RegisterBooleanPref(prefs::kCustomHandlersEnabled, true, |
| 741 PrefServiceSyncable::UNSYNCABLE_PREF); | 742 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 742 } | 743 } |
| 743 | 744 |
| 744 ProtocolHandlerRegistry::~ProtocolHandlerRegistry() { | 745 ProtocolHandlerRegistry::~ProtocolHandlerRegistry() { |
| 745 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 746 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 746 DCHECK(default_client_observers_.empty()); | 747 DCHECK(default_client_observers_.empty()); |
| 747 } | 748 } |
| 748 | 749 |
| 749 void ProtocolHandlerRegistry::PromoteHandler(const ProtocolHandler& handler) { | 750 void ProtocolHandlerRegistry::PromoteHandler(const ProtocolHandler& handler) { |
| 750 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 751 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 751 DCHECK(IsRegistered(handler)); | 752 DCHECK(IsRegistered(handler)); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 | 901 |
| 901 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 902 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 902 ProtocolHandlerRegistry::CreateJobInterceptorFactory() { | 903 ProtocolHandlerRegistry::CreateJobInterceptorFactory() { |
| 903 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 904 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 904 // this is always created on the UI thread (in profile_io's | 905 // this is always created on the UI thread (in profile_io's |
| 905 // InitializeOnUIThread. Any method calls must be done | 906 // InitializeOnUIThread. Any method calls must be done |
| 906 // on the IO thread (this is checked). | 907 // on the IO thread (this is checked). |
| 907 return scoped_ptr<JobInterceptorFactory>(new JobInterceptorFactory( | 908 return scoped_ptr<JobInterceptorFactory>(new JobInterceptorFactory( |
| 908 io_thread_delegate_)); | 909 io_thread_delegate_)); |
| 909 } | 910 } |
| OLD | NEW |