| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "chrome/browser/custom_handlers/protocol_handler.h" | 8 #include "chrome/browser/custom_handlers/protocol_handler.h" |
| 9 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg
ate.h" | 9 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg
ate.h" |
| 10 #include "chrome/browser/net/chrome_url_request_context.h" | 10 #include "chrome/browser/net/chrome_url_request_context.h" |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 const ProtocolHandler& handler) { | 238 const ProtocolHandler& handler) { |
| 239 } | 239 } |
| 240 | 240 |
| 241 void ProtocolHandlerRegistry::OnIgnoreRegisterProtocolHandler( | 241 void ProtocolHandlerRegistry::OnIgnoreRegisterProtocolHandler( |
| 242 const ProtocolHandler& handler) { | 242 const ProtocolHandler& handler) { |
| 243 IgnoreProtocolHandler(handler); | 243 IgnoreProtocolHandler(handler); |
| 244 Save(); | 244 Save(); |
| 245 } | 245 } |
| 246 | 246 |
| 247 void ProtocolHandlerRegistry::RegisterPrefs(PrefService* prefService) { | 247 void ProtocolHandlerRegistry::RegisterPrefs(PrefService* prefService) { |
| 248 prefService->RegisterListPref(prefs::kRegisteredProtocolHandlers); | 248 prefService->RegisterListPref(prefs::kRegisteredProtocolHandlers, |
| 249 prefService->RegisterListPref(prefs::kIgnoredProtocolHandlers); | 249 false /* don't sync pref */); |
| 250 prefService->RegisterBooleanPref(prefs::kCustomHandlersEnabled, true); | 250 prefService->RegisterListPref(prefs::kIgnoredProtocolHandlers, |
| 251 false /* don't sync pref */); |
| 252 prefService->RegisterBooleanPref(prefs::kCustomHandlersEnabled, true, |
| 253 false /* don't sync pref */); |
| 251 } | 254 } |
| 252 | 255 |
| 253 // Delegate -------------------------------------------------------------------- | 256 // Delegate -------------------------------------------------------------------- |
| 254 | 257 |
| 255 ProtocolHandlerRegistry::Delegate::~Delegate() { | 258 ProtocolHandlerRegistry::Delegate::~Delegate() { |
| 256 } | 259 } |
| 257 | 260 |
| 258 void ProtocolHandlerRegistry::Delegate::RegisterExternalHandler( | 261 void ProtocolHandlerRegistry::Delegate::RegisterExternalHandler( |
| 259 const std::string& protocol) { | 262 const std::string& protocol) { |
| 260 ChildProcessSecurityPolicy* policy = | 263 ChildProcessSecurityPolicy* policy = |
| 261 ChildProcessSecurityPolicy::GetInstance(); | 264 ChildProcessSecurityPolicy::GetInstance(); |
| 262 if (!policy->IsWebSafeScheme(protocol)) { | 265 if (!policy->IsWebSafeScheme(protocol)) { |
| 263 policy->RegisterWebSafeScheme(protocol); | 266 policy->RegisterWebSafeScheme(protocol); |
| 264 } | 267 } |
| 265 net::URLRequest::RegisterProtocolFactory(protocol, | 268 net::URLRequest::RegisterProtocolFactory(protocol, |
| 266 &ProtocolHandlerRegistry::Factory); | 269 &ProtocolHandlerRegistry::Factory); |
| 267 } | 270 } |
| 268 | 271 |
| 269 void ProtocolHandlerRegistry::Delegate::DeregisterExternalHandler( | 272 void ProtocolHandlerRegistry::Delegate::DeregisterExternalHandler( |
| 270 const std::string& protocol) { | 273 const std::string& protocol) { |
| 271 net::URLRequest::RegisterProtocolFactory(protocol, NULL); | 274 net::URLRequest::RegisterProtocolFactory(protocol, NULL); |
| 272 } | 275 } |
| 273 | 276 |
| 274 bool ProtocolHandlerRegistry::Delegate::IsExternalHandlerRegistered( | 277 bool ProtocolHandlerRegistry::Delegate::IsExternalHandlerRegistered( |
| 275 const std::string& protocol) { | 278 const std::string& protocol) { |
| 276 return net::URLRequest::IsHandledProtocol(protocol); | 279 return net::URLRequest::IsHandledProtocol(protocol); |
| 277 } | 280 } |
| OLD | NEW |