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

Side by Side Diff: chrome/browser/custom_handlers/protocol_handler_registry.cc

Issue 293983004: Modify ProtocolHandlerRegistry to make room for policy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleans up the unit test Created 6 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/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"
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 329
330 if (AttemptReplace(handler)) 330 if (AttemptReplace(handler))
331 return true; 331 return true;
332 332
333 return false; 333 return false;
334 } 334 }
335 335
336 void ProtocolHandlerRegistry::OnAcceptRegisterProtocolHandler( 336 void ProtocolHandlerRegistry::OnAcceptRegisterProtocolHandler(
337 const ProtocolHandler& handler) { 337 const ProtocolHandler& handler) {
338 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 338 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
339 RegisterProtocolHandler(handler); 339 RegisterProtocolHandler(handler, USER);
340 SetDefault(handler); 340 SetDefault(handler);
341 Save(); 341 Save();
342 NotifyChanged(); 342 NotifyChanged();
343 } 343 }
344 344
345 void ProtocolHandlerRegistry::OnDenyRegisterProtocolHandler( 345 void ProtocolHandlerRegistry::OnDenyRegisterProtocolHandler(
346 const ProtocolHandler& handler) { 346 const ProtocolHandler& handler) {
347 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 347 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
348 RegisterProtocolHandler(handler); 348 RegisterProtocolHandler(handler, USER);
349 Save(); 349 Save();
350 NotifyChanged(); 350 NotifyChanged();
351 } 351 }
352 352
353 void ProtocolHandlerRegistry::OnIgnoreRegisterProtocolHandler( 353 void ProtocolHandlerRegistry::OnIgnoreRegisterProtocolHandler(
354 const ProtocolHandler& handler) { 354 const ProtocolHandler& handler) {
355 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 355 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
356 IgnoreProtocolHandler(handler); 356 IgnoreProtocolHandler(handler, USER);
357 Save(); 357 Save();
358 NotifyChanged(); 358 NotifyChanged();
359 } 359 }
360 360
361 bool ProtocolHandlerRegistry::AttemptReplace(const ProtocolHandler& handler) { 361 bool ProtocolHandlerRegistry::AttemptReplace(const ProtocolHandler& handler) {
362 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 362 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
363 ProtocolHandler old_default = GetHandlerFor(handler.protocol()); 363 ProtocolHandler old_default = GetHandlerFor(handler.protocol());
364 bool make_new_handler_default = handler.IsSameOrigin(old_default); 364 bool make_new_handler_default = handler.IsSameOrigin(old_default);
365 ProtocolHandlerList to_replace(GetReplacedHandlers(handler)); 365 ProtocolHandlerList to_replace(GetReplacedHandlers(handler));
366 if (to_replace.empty()) 366 if (to_replace.empty())
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 is_loading_ = true; 436 is_loading_ = true;
437 437
438 PrefService* prefs = profile_->GetPrefs(); 438 PrefService* prefs = profile_->GetPrefs();
439 if (prefs->HasPrefPath(prefs::kCustomHandlersEnabled)) { 439 if (prefs->HasPrefPath(prefs::kCustomHandlersEnabled)) {
440 if (prefs->GetBoolean(prefs::kCustomHandlersEnabled)) { 440 if (prefs->GetBoolean(prefs::kCustomHandlersEnabled)) {
441 Enable(); 441 Enable();
442 } else { 442 } else {
443 Disable(); 443 Disable();
444 } 444 }
445 } 445 }
446 std::vector<const base::DictionaryValue*> registered_handlers = 446
447 GetHandlersFromPref(prefs::kRegisteredProtocolHandlers); 447 RegisterProtocolHandlersFromPref(prefs::kPolicyRegisteredProtocolHandlers,
448 for (std::vector<const base::DictionaryValue*>::const_iterator p = 448 POLICY);
449 registered_handlers.begin(); 449 RegisterProtocolHandlersFromPref(prefs::kRegisteredProtocolHandlers, USER);
450 p != registered_handlers.end(); ++p) { 450 IgnoreProtocolHandlersFromPref(prefs::kPolicyIgnoredProtocolHandlers, POLICY);
451 ProtocolHandler handler = ProtocolHandler::CreateProtocolHandler(*p); 451 IgnoreProtocolHandlersFromPref(prefs::kIgnoredProtocolHandlers, USER);
452 RegisterProtocolHandler(handler); 452
453 bool is_default = false;
454 if ((*p)->GetBoolean("default", &is_default) && is_default) {
455 SetDefault(handler);
456 }
457 }
458 std::vector<const base::DictionaryValue*> ignored_handlers =
459 GetHandlersFromPref(prefs::kIgnoredProtocolHandlers);
460 for (std::vector<const base::DictionaryValue*>::const_iterator p =
461 ignored_handlers.begin();
462 p != ignored_handlers.end(); ++p) {
463 IgnoreProtocolHandler(ProtocolHandler::CreateProtocolHandler(*p));
464 }
465 is_loading_ = false; 453 is_loading_ = false;
466 454
467 // For each default protocol handler, check that we are still registered 455 // For each default protocol handler, check that we are still registered
468 // with the OS as the default application. 456 // with the OS as the default application.
469 if (ShouldRemoveHandlersNotInOS()) { 457 if (ShouldRemoveHandlersNotInOS()) {
470 for (ProtocolHandlerMap::const_iterator p = default_handlers_.begin(); 458 for (ProtocolHandlerMap::const_iterator p = default_handlers_.begin();
471 p != default_handlers_.end(); ++p) { 459 p != default_handlers_.end(); ++p) {
472 ProtocolHandler handler = p->second; 460 ProtocolHandler handler = p->second;
473 DefaultClientObserver* observer = delegate_->CreateShellObserver(this); 461 DefaultClientObserver* observer = delegate_->CreateShellObserver(this);
474 scoped_refptr<ShellIntegration::DefaultProtocolClientWorker> worker; 462 scoped_refptr<ShellIntegration::DefaultProtocolClientWorker> worker;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 return true; 572 return true;
585 } 573 }
586 } 574 }
587 return false; 575 return false;
588 } 576 }
589 577
590 void ProtocolHandlerRegistry::RemoveIgnoredHandler( 578 void ProtocolHandlerRegistry::RemoveIgnoredHandler(
591 const ProtocolHandler& handler) { 579 const ProtocolHandler& handler) {
592 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 580 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
593 bool should_notify = false; 581 bool should_notify = false;
594 ProtocolHandlerList::iterator p = std::find( 582 if (HandlerExists(handler, ignored_protocol_handlers_) &&
595 ignored_protocol_handlers_.begin(), ignored_protocol_handlers_.end(), 583 HandlerExists(handler, user_ignored_protocol_handlers_)) {
596 handler); 584 EraseHandler(handler, &user_ignored_protocol_handlers_);
597 if (p != ignored_protocol_handlers_.end()) {
598 ignored_protocol_handlers_.erase(p);
599 Save(); 585 Save();
600 should_notify = true; 586 if (!HandlerExists(handler, policy_ignored_protocol_handlers_)) {
587 EraseHandler(handler, &ignored_protocol_handlers_);
588 should_notify = true;
589 }
601 } 590 }
602 if (should_notify) 591 if (should_notify)
603 NotifyChanged(); 592 NotifyChanged();
604 } 593 }
605 594
606 bool ProtocolHandlerRegistry::IsHandledProtocol( 595 bool ProtocolHandlerRegistry::IsHandledProtocol(
607 const std::string& scheme) const { 596 const std::string& scheme) const {
608 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 597 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
609 return enabled_ && !GetHandlerFor(scheme).IsEmpty(); 598 return enabled_ && !GetHandlerFor(scheme).IsEmpty();
610 } 599 }
611 600
612 void ProtocolHandlerRegistry::RemoveHandler( 601 void ProtocolHandlerRegistry::RemoveHandler(
613 const ProtocolHandler& handler) { 602 const ProtocolHandler& handler) {
614 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 603 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
615 ProtocolHandlerList& handlers = protocol_handlers_[handler.protocol()]; 604 ProtocolHandlerList& handlers = protocol_handlers_[handler.protocol()];
616 ProtocolHandlerList::iterator p = 605 bool erase_success = false;
617 std::find(handlers.begin(), handlers.end(), handler); 606 if (HandlerExists(handler, handlers) &&
618 if (p != handlers.end()) { 607 HandlerExists(handler, &user_protocol_handlers_)) {
619 handlers.erase(p); 608 EraseHandler(handler, &user_protocol_handlers_);
609 if (!HandlerExists(handler, &policy_protocol_handlers_)) {
610 erase_success = true;
611 EraseHandler(handler, &protocol_handlers_);
612 }
620 } 613 }
621 ProtocolHandlerMap::iterator q = default_handlers_.find(handler.protocol()); 614 ProtocolHandlerMap::iterator q = default_handlers_.find(handler.protocol());
622 if (q != default_handlers_.end() && q->second == handler) { 615 if (erase_success && q != default_handlers_.end() && q->second == handler) {
623 // Make the new top handler in the list the default. 616 // Make the new top handler in the list the default.
624 if (!handlers.empty()) { 617 if (!handlers.empty()) {
625 // NOTE We pass a copy because SetDefault() modifies handlers. 618 // NOTE We pass a copy because SetDefault() modifies handlers.
626 SetDefault(ProtocolHandler(handlers[0])); 619 SetDefault(ProtocolHandler(handlers[0]));
627 } else { 620 } else {
628 BrowserThread::PostTask( 621 BrowserThread::PostTask(
629 BrowserThread::IO, FROM_HERE, 622 BrowserThread::IO, FROM_HERE,
630 base::Bind(&IOThreadDelegate::ClearDefault, io_thread_delegate_, 623 base::Bind(&IOThreadDelegate::ClearDefault, io_thread_delegate_,
631 q->second.protocol())); 624 q->second.protocol()));
632 625
633 default_handlers_.erase(q); 626 default_handlers_.erase(q);
634 } 627 }
635 } 628 }
636 629
637 if (!IsHandledProtocol(handler.protocol())) { 630 if (erase_success && !IsHandledProtocol(handler.protocol())) {
638 delegate_->DeregisterExternalHandler(handler.protocol()); 631 delegate_->DeregisterExternalHandler(handler.protocol());
639 } 632 }
640 Save(); 633 Save();
641 NotifyChanged(); 634 if (erase_success)
635 NotifyChanged();
642 } 636 }
643 637
644 void ProtocolHandlerRegistry::RemoveDefaultHandler(const std::string& scheme) { 638 void ProtocolHandlerRegistry::RemoveDefaultHandler(const std::string& scheme) {
645 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 639 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
646 ProtocolHandler current_default = GetHandlerFor(scheme); 640 ProtocolHandler current_default = GetHandlerFor(scheme);
647 if (!current_default.IsEmpty()) 641 if (!current_default.IsEmpty())
648 RemoveHandler(current_default); 642 RemoveHandler(current_default);
649 } 643 }
650 644
651 const ProtocolHandler& ProtocolHandlerRegistry::GetHandlerFor( 645 const ProtocolHandler& ProtocolHandlerRegistry::GetHandlerFor(
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 } 699 }
706 } 700 }
707 701
708 // static 702 // static
709 void ProtocolHandlerRegistry::RegisterProfilePrefs( 703 void ProtocolHandlerRegistry::RegisterProfilePrefs(
710 user_prefs::PrefRegistrySyncable* registry) { 704 user_prefs::PrefRegistrySyncable* registry) {
711 registry->RegisterListPref(prefs::kRegisteredProtocolHandlers, 705 registry->RegisterListPref(prefs::kRegisteredProtocolHandlers,
712 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 706 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
713 registry->RegisterListPref(prefs::kIgnoredProtocolHandlers, 707 registry->RegisterListPref(prefs::kIgnoredProtocolHandlers,
714 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 708 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
709 registry->RegisterListPref(prefs::kPolicyRegisteredProtocolHandlers,
710 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
711 registry->RegisterListPref(prefs::kPolicyIgnoredProtocolHandlers,
712 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
715 registry->RegisterBooleanPref( 713 registry->RegisterBooleanPref(
716 prefs::kCustomHandlersEnabled, 714 prefs::kCustomHandlersEnabled,
717 true, 715 true,
718 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 716 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
719 } 717 }
720 718
721 ProtocolHandlerRegistry::~ProtocolHandlerRegistry() { 719 ProtocolHandlerRegistry::~ProtocolHandlerRegistry() {
722 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 720 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
723 DCHECK(default_client_observers_.empty()); 721 DCHECK(default_client_observers_.empty());
724 } 722 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 } 786 }
789 787
790 ProtocolHandlerList new_list; 788 ProtocolHandlerList new_list;
791 new_list.push_back(handler); 789 new_list.push_back(handler);
792 protocol_handlers_[handler.protocol()] = new_list; 790 protocol_handlers_[handler.protocol()] = new_list;
793 } 791 }
794 792
795 base::Value* ProtocolHandlerRegistry::EncodeRegisteredHandlers() { 793 base::Value* ProtocolHandlerRegistry::EncodeRegisteredHandlers() {
796 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 794 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
797 base::ListValue* protocol_handlers = new base::ListValue(); 795 base::ListValue* protocol_handlers = new base::ListValue();
798 for (ProtocolHandlerMultiMap::iterator i = protocol_handlers_.begin(); 796 for (ProtocolHandlerMultiMap::iterator i = user_protocol_handlers_.begin();
799 i != protocol_handlers_.end(); ++i) { 797 i != user_protocol_handlers_.end();
798 ++i) {
800 for (ProtocolHandlerList::iterator j = i->second.begin(); 799 for (ProtocolHandlerList::iterator j = i->second.begin();
801 j != i->second.end(); ++j) { 800 j != i->second.end(); ++j) {
802 base::DictionaryValue* encoded = j->Encode(); 801 base::DictionaryValue* encoded = j->Encode();
803 if (IsDefault(*j)) { 802 if (IsDefault(*j)) {
804 encoded->Set("default", base::Value::CreateBooleanValue(true)); 803 encoded->Set("default", base::Value::CreateBooleanValue(true));
805 } 804 }
806 protocol_handlers->Append(encoded); 805 protocol_handlers->Append(encoded);
807 } 806 }
808 } 807 }
809 return protocol_handlers; 808 return protocol_handlers;
810 } 809 }
811 810
812 base::Value* ProtocolHandlerRegistry::EncodeIgnoredHandlers() { 811 base::Value* ProtocolHandlerRegistry::EncodeIgnoredHandlers() {
813 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 812 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
814 base::ListValue* handlers = new base::ListValue(); 813 base::ListValue* handlers = new base::ListValue();
815 for (ProtocolHandlerList::iterator i = ignored_protocol_handlers_.begin(); 814 for (ProtocolHandlerList::iterator i =
816 i != ignored_protocol_handlers_.end(); ++i) { 815 user_ignored_protocol_handlers_.begin();
816 i != user_ignored_protocol_handlers_.end();
817 ++i) {
817 handlers->Append(i->Encode()); 818 handlers->Append(i->Encode());
818 } 819 }
819 return handlers; 820 return handlers;
820 } 821 }
821 822
822 void ProtocolHandlerRegistry::NotifyChanged() { 823 void ProtocolHandlerRegistry::NotifyChanged() {
823 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 824 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
824 content::NotificationService::current()->Notify( 825 content::NotificationService::current()->Notify(
825 chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, 826 chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED,
826 content::Source<Profile>(profile_), 827 content::Source<Profile>(profile_),
827 content::NotificationService::NoDetails()); 828 content::NotificationService::NoDetails());
828 } 829 }
829 830
830 void ProtocolHandlerRegistry::RegisterProtocolHandler( 831 void ProtocolHandlerRegistry::RegisterProtocolHandler(
831 const ProtocolHandler& handler) { 832 const ProtocolHandler& handler,
833 const HandlerSource source) {
832 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 834 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
833 DCHECK(CanSchemeBeOverridden(handler.protocol())); 835 DCHECK(CanSchemeBeOverridden(handler.protocol()));
834 DCHECK(!handler.IsEmpty()); 836 DCHECK(!handler.IsEmpty());
837 ProtocolHandlerMultiMap& map =
838 (source == POLICY) ? policy_protocol_handlers_ : user_protocol_handlers_;
839 ProtocolHandlerList& list = map[handler.protocol()];
840 if (!HandlerExists(handler, list))
841 list.push_back(handler);
835 if (IsRegistered(handler)) { 842 if (IsRegistered(handler)) {
836 return; 843 return;
837 } 844 }
838 if (enabled_ && !delegate_->IsExternalHandlerRegistered(handler.protocol())) 845 if (enabled_ && !delegate_->IsExternalHandlerRegistered(handler.protocol()))
839 delegate_->RegisterExternalHandler(handler.protocol()); 846 delegate_->RegisterExternalHandler(handler.protocol());
840 InsertHandler(handler); 847 InsertHandler(handler);
841 } 848 }
842 849
843 std::vector<const base::DictionaryValue*> 850 std::vector<const base::DictionaryValue*>
844 ProtocolHandlerRegistry::GetHandlersFromPref(const char* pref_name) const { 851 ProtocolHandlerRegistry::GetHandlersFromPref(const char* pref_name) const {
(...skipping 11 matching lines...) Expand all
856 if (!handlers->GetDictionary(i, &dict)) 863 if (!handlers->GetDictionary(i, &dict))
857 continue; 864 continue;
858 if (ProtocolHandler::IsValidDict(dict)) { 865 if (ProtocolHandler::IsValidDict(dict)) {
859 result.push_back(dict); 866 result.push_back(dict);
860 } 867 }
861 } 868 }
862 } 869 }
863 return result; 870 return result;
864 } 871 }
865 872
873 void ProtocolHandlerRegistry::RegisterProtocolHandlersFromPref(
874 const char* pref_name,
875 const HandlerSource source) {
876 std::vector<const base::DictionaryValue*> registered_handlers =
877 GetHandlersFromPref(pref_name);
878 for (std::vector<const base::DictionaryValue*>::const_iterator p =
879 registered_handlers.begin();
880 p != registered_handlers.end();
881 ++p) {
882 ProtocolHandler handler = ProtocolHandler::CreateProtocolHandler(*p);
883 RegisterProtocolHandler(handler, source);
884 bool is_default = false;
885 if ((*p)->GetBoolean("default", &is_default) && is_default) {
886 SetDefault(handler);
887 }
888 }
889 }
890
866 void ProtocolHandlerRegistry::IgnoreProtocolHandler( 891 void ProtocolHandlerRegistry::IgnoreProtocolHandler(
867 const ProtocolHandler& handler) { 892 const ProtocolHandler& handler,
893 const HandlerSource source) {
868 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 894 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
895 ProtocolHandlerList& list = (source == POLICY)
896 ? policy_ignored_protocol_handlers_
897 : user_ignored_protocol_handlers_;
898 if (!HandlerExists(handler, list))
899 list.push_back(handler);
900 if (HandlerExists(handler, ignored_protocol_handlers_))
901 return;
869 ignored_protocol_handlers_.push_back(handler); 902 ignored_protocol_handlers_.push_back(handler);
870 } 903 }
871 904
905 void ProtocolHandlerRegistry::IgnoreProtocolHandlersFromPref(
906 const char* pref_name,
907 const HandlerSource source) {
908 std::vector<const base::DictionaryValue*> ignored_handlers =
909 GetHandlersFromPref(pref_name);
910 for (std::vector<const base::DictionaryValue*>::const_iterator p =
911 ignored_handlers.begin();
912 p != ignored_handlers.end();
913 ++p) {
914 IgnoreProtocolHandler(ProtocolHandler::CreateProtocolHandler(*p), source);
915 }
916 }
917
918 bool ProtocolHandlerRegistry::HandlerExists(const ProtocolHandler& handler,
919 ProtocolHandlerMultiMap* map) {
920 return HandlerExists(handler, (*map)[handler.protocol()]);
921 }
922
923 bool ProtocolHandlerRegistry::HandlerExists(const ProtocolHandler& handler,
924 const ProtocolHandlerList& list) {
925 return std::find(list.begin(), list.end(), handler) != list.end();
926 }
927
928 void ProtocolHandlerRegistry::EraseHandler(const ProtocolHandler& handler,
929 ProtocolHandlerMultiMap* map) {
930 EraseHandler(handler, &(*map)[handler.protocol()]);
931 }
932
933 void ProtocolHandlerRegistry::EraseHandler(const ProtocolHandler& handler,
934 ProtocolHandlerList* list) {
935 list->erase(std::find(list->begin(), list->end(), handler));
936 }
937
872 void ProtocolHandlerRegistry::AddPredefinedHandler( 938 void ProtocolHandlerRegistry::AddPredefinedHandler(
873 const ProtocolHandler& handler) { 939 const ProtocolHandler& handler) {
874 DCHECK(!is_loaded_); // Must be called prior InitProtocolSettings. 940 DCHECK(!is_loaded_); // Must be called prior InitProtocolSettings.
875 RegisterProtocolHandler(handler); 941 RegisterProtocolHandler(handler, USER);
876 SetDefault(handler); 942 SetDefault(handler);
877 } 943 }
878 944
879 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> 945 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
880 ProtocolHandlerRegistry::CreateJobInterceptorFactory() { 946 ProtocolHandlerRegistry::CreateJobInterceptorFactory() {
881 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 947 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
882 // this is always created on the UI thread (in profile_io's 948 // this is always created on the UI thread (in profile_io's
883 // InitializeOnUIThread. Any method calls must be done 949 // InitializeOnUIThread. Any method calls must be done
884 // on the IO thread (this is checked). 950 // on the IO thread (this is checked).
885 return scoped_ptr<JobInterceptorFactory>( 951 return scoped_ptr<JobInterceptorFactory>(
886 new JobInterceptorFactory(io_thread_delegate_.get())); 952 new JobInterceptorFactory(io_thread_delegate_.get()));
887 } 953 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698