| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 if (worker_) { | 254 if (worker_) { |
| 255 if (ShouldRemoveHandlersNotInOS() && | 255 if (ShouldRemoveHandlersNotInOS() && |
| 256 (state == ShellIntegration::STATE_NOT_DEFAULT)) { | 256 (state == ShellIntegration::STATE_NOT_DEFAULT)) { |
| 257 registry_->ClearDefault(worker_->protocol()); | 257 registry_->ClearDefault(worker_->protocol()); |
| 258 } | 258 } |
| 259 } else { | 259 } else { |
| 260 NOTREACHED(); | 260 NOTREACHED(); |
| 261 } | 261 } |
| 262 } | 262 } |
| 263 | 263 |
| 264 bool ProtocolHandlerRegistry::DefaultClientObserver:: | |
| 265 IsInteractiveSetDefaultPermitted() { | |
| 266 return true; | |
| 267 } | |
| 268 | |
| 269 void ProtocolHandlerRegistry::DefaultClientObserver::SetWorker( | 264 void ProtocolHandlerRegistry::DefaultClientObserver::SetWorker( |
| 270 ShellIntegration::DefaultProtocolClientWorker* worker) { | 265 ShellIntegration::DefaultProtocolClientWorker* worker) { |
| 271 worker_ = worker; | 266 worker_ = worker; |
| 272 } | 267 } |
| 273 | 268 |
| 274 bool ProtocolHandlerRegistry::DefaultClientObserver::IsOwnedByWorker() { | |
| 275 return true; | |
| 276 } | |
| 277 | |
| 278 // Delegate -------------------------------------------------------------------- | 269 // Delegate -------------------------------------------------------------------- |
| 279 | 270 |
| 280 ProtocolHandlerRegistry::Delegate::~Delegate() {} | 271 ProtocolHandlerRegistry::Delegate::~Delegate() {} |
| 281 | 272 |
| 282 void ProtocolHandlerRegistry::Delegate::RegisterExternalHandler( | 273 void ProtocolHandlerRegistry::Delegate::RegisterExternalHandler( |
| 283 const std::string& protocol) { | 274 const std::string& protocol) { |
| 284 ChildProcessSecurityPolicy* policy = | 275 ChildProcessSecurityPolicy* policy = |
| 285 ChildProcessSecurityPolicy::GetInstance(); | 276 ChildProcessSecurityPolicy::GetInstance(); |
| 286 if (!policy->IsWebSafeScheme(protocol)) { | 277 if (!policy->IsWebSafeScheme(protocol)) { |
| 287 policy->RegisterWebSafeScheme(protocol); | 278 policy->RegisterWebSafeScheme(protocol); |
| 288 } | 279 } |
| 289 } | 280 } |
| 290 | 281 |
| 291 void ProtocolHandlerRegistry::Delegate::DeregisterExternalHandler( | 282 void ProtocolHandlerRegistry::Delegate::DeregisterExternalHandler( |
| 292 const std::string& protocol) { | 283 const std::string& protocol) { |
| 293 } | 284 } |
| 294 | 285 |
| 295 bool ProtocolHandlerRegistry::Delegate::IsExternalHandlerRegistered( | 286 bool ProtocolHandlerRegistry::Delegate::IsExternalHandlerRegistered( |
| 296 const std::string& protocol) { | 287 const std::string& protocol) { |
| 297 // NOTE(koz): This function is safe to call from any thread, despite living | 288 // NOTE(koz): This function is safe to call from any thread, despite living |
| 298 // in ProfileIOData. | 289 // in ProfileIOData. |
| 299 return ProfileIOData::IsHandledProtocol(protocol); | 290 return ProfileIOData::IsHandledProtocol(protocol); |
| 300 } | 291 } |
| 301 | 292 |
| 302 ShellIntegration::DefaultProtocolClientWorker* | 293 ShellIntegration::DefaultProtocolClientWorker* |
| 303 ProtocolHandlerRegistry::Delegate::CreateShellWorker( | 294 ProtocolHandlerRegistry::Delegate::CreateShellWorker( |
| 304 ShellIntegration::DefaultWebClientObserver* observer, | 295 ShellIntegration::DefaultWebClientObserver* observer, |
| 305 const std::string& protocol) { | 296 const std::string& protocol) { |
| 306 return new ShellIntegration::DefaultProtocolClientWorker(observer, protocol); | 297 return new ShellIntegration::DefaultProtocolClientWorker(observer, protocol, |
| 298 true, true); |
| 307 } | 299 } |
| 308 | 300 |
| 309 ProtocolHandlerRegistry::DefaultClientObserver* | 301 ProtocolHandlerRegistry::DefaultClientObserver* |
| 310 ProtocolHandlerRegistry::Delegate::CreateShellObserver( | 302 ProtocolHandlerRegistry::Delegate::CreateShellObserver( |
| 311 ProtocolHandlerRegistry* registry) { | 303 ProtocolHandlerRegistry* registry) { |
| 312 return new DefaultClientObserver(registry); | 304 return new DefaultClientObserver(registry); |
| 313 } | 305 } |
| 314 | 306 |
| 315 void ProtocolHandlerRegistry::Delegate::RegisterWithOSAsDefaultClient( | 307 void ProtocolHandlerRegistry::Delegate::RegisterWithOSAsDefaultClient( |
| 316 const std::string& protocol, ProtocolHandlerRegistry* registry) { | 308 const std::string& protocol, ProtocolHandlerRegistry* registry) { |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 | 958 |
| 967 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 959 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 968 ProtocolHandlerRegistry::CreateJobInterceptorFactory() { | 960 ProtocolHandlerRegistry::CreateJobInterceptorFactory() { |
| 969 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 961 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 970 // this is always created on the UI thread (in profile_io's | 962 // this is always created on the UI thread (in profile_io's |
| 971 // InitializeOnUIThread. Any method calls must be done | 963 // InitializeOnUIThread. Any method calls must be done |
| 972 // on the IO thread (this is checked). | 964 // on the IO thread (this is checked). |
| 973 return scoped_ptr<JobInterceptorFactory>( | 965 return scoped_ptr<JobInterceptorFactory>( |
| 974 new JobInterceptorFactory(io_thread_delegate_.get())); | 966 new JobInterceptorFactory(io_thread_delegate_.get())); |
| 975 } | 967 } |
| OLD | NEW |