| 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 <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 class FakeClientObserver | 85 class FakeClientObserver |
| 86 : public ProtocolHandlerRegistry::DefaultClientObserver { | 86 : public ProtocolHandlerRegistry::DefaultClientObserver { |
| 87 public: | 87 public: |
| 88 FakeClientObserver(ProtocolHandlerRegistry* registry, | 88 FakeClientObserver(ProtocolHandlerRegistry* registry, |
| 89 FakeDelegate* registry_delegate) | 89 FakeDelegate* registry_delegate) |
| 90 : ProtocolHandlerRegistry::DefaultClientObserver(registry), | 90 : ProtocolHandlerRegistry::DefaultClientObserver(registry), |
| 91 delegate_(registry_delegate) {} | 91 delegate_(registry_delegate) {} |
| 92 | 92 |
| 93 virtual void SetDefaultWebClientUIState( | 93 virtual void SetDefaultWebClientUIState( |
| 94 ShellIntegration::DefaultWebClientUIState state) { | 94 ShellIntegration::DefaultWebClientUIState state, |
| 95 ShellIntegration::SetDefaultWebClientResult call_result) { |
| 95 ProtocolHandlerRegistry::DefaultClientObserver::SetDefaultWebClientUIState( | 96 ProtocolHandlerRegistry::DefaultClientObserver::SetDefaultWebClientUIState( |
| 96 state); | 97 state, call_result); |
| 97 if (state == ShellIntegration::STATE_IS_DEFAULT) { | 98 if (state == ShellIntegration::STATE_IS_DEFAULT) { |
| 98 delegate_->FakeRegisterWithOS(worker_->protocol()); | 99 delegate_->FakeRegisterWithOS(worker_->protocol()); |
| 99 } | 100 } |
| 100 if (state != ShellIntegration::STATE_PROCESSING) { | 101 if (state != ShellIntegration::STATE_PROCESSING) { |
| 101 MessageLoop::current()->Quit(); | 102 MessageLoop::current()->Quit(); |
| 102 } | 103 } |
| 103 } | 104 } |
| 104 | 105 |
| 105 private: | 106 private: |
| 106 FakeDelegate* delegate_; | 107 FakeDelegate* delegate_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 119 virtual ~FakeProtocolClientWorker() {} | 120 virtual ~FakeProtocolClientWorker() {} |
| 120 | 121 |
| 121 virtual ShellIntegration::DefaultWebClientState CheckIsDefault() { | 122 virtual ShellIntegration::DefaultWebClientState CheckIsDefault() { |
| 122 if (force_failure_) { | 123 if (force_failure_) { |
| 123 return ShellIntegration::NOT_DEFAULT_WEB_CLIENT; | 124 return ShellIntegration::NOT_DEFAULT_WEB_CLIENT; |
| 124 } else { | 125 } else { |
| 125 return ShellIntegration::IS_DEFAULT_WEB_CLIENT; | 126 return ShellIntegration::IS_DEFAULT_WEB_CLIENT; |
| 126 } | 127 } |
| 127 } | 128 } |
| 128 | 129 |
| 129 virtual void SetAsDefault(bool interactive_permitted) {} | 130 virtual ShellIntegration::SetDefaultWebClientResult |
| 131 SetAsDefault(bool interactive_permitted) { |
| 132 return ShellIntegration::RESULT_SET_DEFAULT_OK; |
| 133 } |
| 130 | 134 |
| 131 private: | 135 private: |
| 132 bool force_failure_; | 136 bool force_failure_; |
| 133 }; | 137 }; |
| 134 | 138 |
| 135 ProtocolHandlerRegistry::DefaultClientObserver* | 139 ProtocolHandlerRegistry::DefaultClientObserver* |
| 136 FakeDelegate::CreateShellObserver(ProtocolHandlerRegistry* registry) { | 140 FakeDelegate::CreateShellObserver(ProtocolHandlerRegistry* registry) { |
| 137 return new FakeClientObserver(registry, this); | 141 return new FakeClientObserver(registry, this); |
| 138 } | 142 } |
| 139 | 143 |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 ASSERT_EQ(ph3.url().GetOrigin() == ph2.url().GetOrigin(), | 837 ASSERT_EQ(ph3.url().GetOrigin() == ph2.url().GetOrigin(), |
| 834 ph3.IsSameOrigin(ph2)); | 838 ph3.IsSameOrigin(ph2)); |
| 835 } | 839 } |
| 836 | 840 |
| 837 TEST_F(ProtocolHandlerRegistryTest, TestInstallDefaultHandler) { | 841 TEST_F(ProtocolHandlerRegistryTest, TestInstallDefaultHandler) { |
| 838 ReloadProtocolHandlerRegistryAndInstallDefaultHandler(); | 842 ReloadProtocolHandlerRegistryAndInstallDefaultHandler(); |
| 839 std::vector<std::string> protocols; | 843 std::vector<std::string> protocols; |
| 840 registry()->GetRegisteredProtocols(&protocols); | 844 registry()->GetRegisteredProtocols(&protocols); |
| 841 ASSERT_EQ(static_cast<size_t>(1), protocols.size()); | 845 ASSERT_EQ(static_cast<size_t>(1), protocols.size()); |
| 842 } | 846 } |
| OLD | NEW |