| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 MessageLoop::current()->RunUntilIdle(); | 53 MessageLoop::current()->RunUntilIdle(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 // FakeURLRequestJobFactory returns NULL for all job creation requests and false | 56 // FakeURLRequestJobFactory returns NULL for all job creation requests and false |
| 57 // for all IsHandled*() requests. FakeURLRequestJobFactory can be chained to | 57 // for all IsHandled*() requests. FakeURLRequestJobFactory can be chained to |
| 58 // ProtocolHandlerRegistry::JobInterceptorFactory so the result of | 58 // ProtocolHandlerRegistry::JobInterceptorFactory so the result of |
| 59 // MaybeCreateJobWithProtocolHandler() indicates whether the | 59 // MaybeCreateJobWithProtocolHandler() indicates whether the |
| 60 // ProtocolHandlerRegistry properly handled a job creation request. | 60 // ProtocolHandlerRegistry properly handled a job creation request. |
| 61 class FakeURLRequestJobFactory : public net::URLRequestJobFactory { | 61 class FakeURLRequestJobFactory : public net::URLRequestJobFactory { |
| 62 // net::URLRequestJobFactory implementation: | 62 // net::URLRequestJobFactory implementation: |
| 63 virtual bool SetProtocolHandler(const std::string& scheme, | |
| 64 ProtocolHandler* protocol_handler) OVERRIDE { | |
| 65 return false; | |
| 66 } | |
| 67 virtual void AddInterceptor(Interceptor* interceptor) OVERRIDE { | |
| 68 } | |
| 69 virtual net::URLRequestJob* MaybeCreateJobWithInterceptor( | 63 virtual net::URLRequestJob* MaybeCreateJobWithInterceptor( |
| 70 net::URLRequest* request, | 64 net::URLRequest* request, |
| 71 net::NetworkDelegate* network_delegate) const OVERRIDE { | 65 net::NetworkDelegate* network_delegate) const OVERRIDE { |
| 72 return NULL; | 66 return NULL; |
| 73 } | 67 } |
| 74 virtual net::URLRequestJob* MaybeCreateJobWithProtocolHandler( | 68 virtual net::URLRequestJob* MaybeCreateJobWithProtocolHandler( |
| 75 const std::string& scheme, | 69 const std::string& scheme, |
| 76 net::URLRequest* request, | 70 net::URLRequest* request, |
| 77 net::NetworkDelegate* network_delegate) const OVERRIDE { | 71 net::NetworkDelegate* network_delegate) const OVERRIDE { |
| 78 return NULL; | 72 return NULL; |
| (...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 | 928 |
| 935 TEST_F(ProtocolHandlerRegistryTest, MAYBE_TestInstallDefaultHandler) { | 929 TEST_F(ProtocolHandlerRegistryTest, MAYBE_TestInstallDefaultHandler) { |
| 936 RecreateRegistry(false); | 930 RecreateRegistry(false); |
| 937 registry()->AddPredefinedHandler(CreateProtocolHandler( | 931 registry()->AddPredefinedHandler(CreateProtocolHandler( |
| 938 "test", GURL("http://test.com/%s"), "Test")); | 932 "test", GURL("http://test.com/%s"), "Test")); |
| 939 registry()->InitProtocolSettings(); | 933 registry()->InitProtocolSettings(); |
| 940 std::vector<std::string> protocols; | 934 std::vector<std::string> protocols; |
| 941 registry()->GetRegisteredProtocols(&protocols); | 935 registry()->GetRegisteredProtocols(&protocols); |
| 942 ASSERT_EQ(static_cast<size_t>(1), protocols.size()); | 936 ASSERT_EQ(static_cast<size_t>(1), protocols.size()); |
| 943 } | 937 } |
| OLD | NEW |