| 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" |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 } | 732 } |
| 733 | 733 |
| 734 void ProtocolHandlerRegistry::Save() { | 734 void ProtocolHandlerRegistry::Save() { |
| 735 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 735 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 736 if (is_loading_) { | 736 if (is_loading_) { |
| 737 return; | 737 return; |
| 738 } | 738 } |
| 739 scoped_ptr<base::Value> registered_protocol_handlers( | 739 scoped_ptr<base::Value> registered_protocol_handlers( |
| 740 EncodeRegisteredHandlers()); | 740 EncodeRegisteredHandlers()); |
| 741 scoped_ptr<base::Value> ignored_protocol_handlers(EncodeIgnoredHandlers()); | 741 scoped_ptr<base::Value> ignored_protocol_handlers(EncodeIgnoredHandlers()); |
| 742 scoped_ptr<base::Value> enabled(base::Value::CreateBooleanValue(enabled_)); | |
| 743 profile_->GetPrefs()->Set(prefs::kRegisteredProtocolHandlers, | 742 profile_->GetPrefs()->Set(prefs::kRegisteredProtocolHandlers, |
| 744 *registered_protocol_handlers); | 743 *registered_protocol_handlers); |
| 745 profile_->GetPrefs()->Set(prefs::kIgnoredProtocolHandlers, | 744 profile_->GetPrefs()->Set(prefs::kIgnoredProtocolHandlers, |
| 746 *ignored_protocol_handlers); | 745 *ignored_protocol_handlers); |
| 747 profile_->GetPrefs()->Set(prefs::kCustomHandlersEnabled, *enabled); | 746 profile_->GetPrefs()->SetBoolean(prefs::kCustomHandlersEnabled, enabled_); |
| 748 } | 747 } |
| 749 | 748 |
| 750 const ProtocolHandlerRegistry::ProtocolHandlerList* | 749 const ProtocolHandlerRegistry::ProtocolHandlerList* |
| 751 ProtocolHandlerRegistry::GetHandlerList( | 750 ProtocolHandlerRegistry::GetHandlerList( |
| 752 const std::string& scheme) const { | 751 const std::string& scheme) const { |
| 753 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 752 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 754 ProtocolHandlerMultiMap::const_iterator p = protocol_handlers_.find(scheme); | 753 ProtocolHandlerMultiMap::const_iterator p = protocol_handlers_.find(scheme); |
| 755 if (p == protocol_handlers_.end()) { | 754 if (p == protocol_handlers_.end()) { |
| 756 return NULL; | 755 return NULL; |
| 757 } | 756 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 base::Value* ProtocolHandlerRegistry::EncodeRegisteredHandlers() { | 792 base::Value* ProtocolHandlerRegistry::EncodeRegisteredHandlers() { |
| 794 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 793 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 795 base::ListValue* protocol_handlers = new base::ListValue(); | 794 base::ListValue* protocol_handlers = new base::ListValue(); |
| 796 for (ProtocolHandlerMultiMap::iterator i = user_protocol_handlers_.begin(); | 795 for (ProtocolHandlerMultiMap::iterator i = user_protocol_handlers_.begin(); |
| 797 i != user_protocol_handlers_.end(); | 796 i != user_protocol_handlers_.end(); |
| 798 ++i) { | 797 ++i) { |
| 799 for (ProtocolHandlerList::iterator j = i->second.begin(); | 798 for (ProtocolHandlerList::iterator j = i->second.begin(); |
| 800 j != i->second.end(); ++j) { | 799 j != i->second.end(); ++j) { |
| 801 base::DictionaryValue* encoded = j->Encode(); | 800 base::DictionaryValue* encoded = j->Encode(); |
| 802 if (IsDefault(*j)) { | 801 if (IsDefault(*j)) { |
| 803 encoded->Set("default", base::Value::CreateBooleanValue(true)); | 802 encoded->Set("default", new base::FundamentalValue(true)); |
| 804 } | 803 } |
| 805 protocol_handlers->Append(encoded); | 804 protocol_handlers->Append(encoded); |
| 806 } | 805 } |
| 807 } | 806 } |
| 808 return protocol_handlers; | 807 return protocol_handlers; |
| 809 } | 808 } |
| 810 | 809 |
| 811 base::Value* ProtocolHandlerRegistry::EncodeIgnoredHandlers() { | 810 base::Value* ProtocolHandlerRegistry::EncodeIgnoredHandlers() { |
| 812 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 811 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 813 base::ListValue* handlers = new base::ListValue(); | 812 base::ListValue* handlers = new base::ListValue(); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 | 943 |
| 945 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 944 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 946 ProtocolHandlerRegistry::CreateJobInterceptorFactory() { | 945 ProtocolHandlerRegistry::CreateJobInterceptorFactory() { |
| 947 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 946 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 948 // this is always created on the UI thread (in profile_io's | 947 // this is always created on the UI thread (in profile_io's |
| 949 // InitializeOnUIThread. Any method calls must be done | 948 // InitializeOnUIThread. Any method calls must be done |
| 950 // on the IO thread (this is checked). | 949 // on the IO thread (this is checked). |
| 951 return scoped_ptr<JobInterceptorFactory>( | 950 return scoped_ptr<JobInterceptorFactory>( |
| 952 new JobInterceptorFactory(io_thread_delegate_.get())); | 951 new JobInterceptorFactory(io_thread_delegate_.get())); |
| 953 } | 952 } |
| OLD | NEW |