| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 ProtocolHandlerRegistry::ProtocolHandlerList | 77 ProtocolHandlerRegistry::ProtocolHandlerList |
| 78 ProtocolHandlerRegistry::GetIgnoredHandlers() { | 78 ProtocolHandlerRegistry::GetIgnoredHandlers() { |
| 79 return ignored_protocol_handlers_; | 79 return ignored_protocol_handlers_; |
| 80 } | 80 } |
| 81 | 81 |
| 82 void ProtocolHandlerRegistry::RegisterProtocolHandler( | 82 void ProtocolHandlerRegistry::RegisterProtocolHandler( |
| 83 const ProtocolHandler& handler) { | 83 const ProtocolHandler& handler) { |
| 84 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 84 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 85 DCHECK(CanSchemeBeOverridden(handler.protocol())); | 85 DCHECK(CanSchemeBeOverridden(handler.protocol())); |
| 86 DCHECK(!handler.IsEmpty()); | 86 DCHECK(!handler.IsEmpty()); |
| 87 if (HasRegisteredEquivalent(handler)) { | 87 if (IsRegistered(handler)) { |
| 88 return; | 88 return; |
| 89 } | 89 } |
| 90 if (enabled_ && !delegate_->IsExternalHandlerRegistered(handler.protocol())) | 90 if (enabled_ && !delegate_->IsExternalHandlerRegistered(handler.protocol())) |
| 91 delegate_->RegisterExternalHandler(handler.protocol()); | 91 delegate_->RegisterExternalHandler(handler.protocol()); |
| 92 InsertHandler(handler); | 92 InsertHandler(handler); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void ProtocolHandlerRegistry::InsertHandler(const ProtocolHandler& handler) { | 95 void ProtocolHandlerRegistry::InsertHandler(const ProtocolHandler& handler) { |
| 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 97 ProtocolHandlerMultiMap::iterator p = | 97 ProtocolHandlerMultiMap::iterator p = |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 Value* ProtocolHandlerRegistry::EncodeIgnoredHandlers() { | 421 Value* ProtocolHandlerRegistry::EncodeIgnoredHandlers() { |
| 422 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 422 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 423 ListValue* handlers = new ListValue(); | 423 ListValue* handlers = new ListValue(); |
| 424 for (ProtocolHandlerList::iterator i = ignored_protocol_handlers_.begin(); | 424 for (ProtocolHandlerList::iterator i = ignored_protocol_handlers_.begin(); |
| 425 i != ignored_protocol_handlers_.end(); ++i) { | 425 i != ignored_protocol_handlers_.end(); ++i) { |
| 426 handlers->Append(i->Encode()); | 426 handlers->Append(i->Encode()); |
| 427 } | 427 } |
| 428 return handlers; | 428 return handlers; |
| 429 } | 429 } |
| 430 | 430 |
| 431 bool ProtocolHandlerRegistry::SilentlyHandleRegisterHandlerRequest( |
| 432 const ProtocolHandler& handler) { |
| 433 if (handler.IsEmpty() || !CanSchemeBeOverridden(handler.protocol())) |
| 434 return true; |
| 435 |
| 436 if (!enabled() || IsRegistered(handler) || HasIgnoredEquivalent(handler)) |
| 437 return true; |
| 438 |
| 439 if (AttemptReplace(handler)) |
| 440 return true; |
| 441 |
| 442 return false; |
| 443 } |
| 444 |
| 431 void ProtocolHandlerRegistry::OnAcceptRegisterProtocolHandler( | 445 void ProtocolHandlerRegistry::OnAcceptRegisterProtocolHandler( |
| 432 const ProtocolHandler& handler) { | 446 const ProtocolHandler& handler) { |
| 433 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 447 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 434 RegisterProtocolHandler(handler); | 448 RegisterProtocolHandler(handler); |
| 435 SetDefault(handler); | 449 SetDefault(handler); |
| 436 Save(); | 450 Save(); |
| 437 NotifyChanged(); | 451 NotifyChanged(); |
| 438 } | 452 } |
| 439 | 453 |
| 440 void ProtocolHandlerRegistry::OnDenyRegisterProtocolHandler( | 454 void ProtocolHandlerRegistry::OnDenyRegisterProtocolHandler( |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 } | 704 } |
| 691 } else { | 705 } else { |
| 692 NOTREACHED(); | 706 NOTREACHED(); |
| 693 } | 707 } |
| 694 } | 708 } |
| 695 | 709 |
| 696 void ProtocolHandlerRegistry::DefaultClientObserver::SetWorker( | 710 void ProtocolHandlerRegistry::DefaultClientObserver::SetWorker( |
| 697 ShellIntegration::DefaultProtocolClientWorker* worker) { | 711 ShellIntegration::DefaultProtocolClientWorker* worker) { |
| 698 worker_ = worker; | 712 worker_ = worker; |
| 699 } | 713 } |
| OLD | NEW |