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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 }; | 79 }; |
80 | 80 |
81 void AssertWillHandleIO( | 81 void AssertWillHandleIO( |
82 const std::string& scheme, | 82 const std::string& scheme, |
83 bool expected, | 83 bool expected, |
84 ProtocolHandlerRegistry::JobInterceptorFactory* interceptor) { | 84 ProtocolHandlerRegistry::JobInterceptorFactory* interceptor) { |
85 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 85 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
86 interceptor->Chain(scoped_ptr<net::URLRequestJobFactory>( | 86 interceptor->Chain(scoped_ptr<net::URLRequestJobFactory>( |
87 new FakeURLRequestJobFactory())); | 87 new FakeURLRequestJobFactory())); |
88 ASSERT_EQ(expected, interceptor->IsHandledProtocol(scheme)); | 88 ASSERT_EQ(expected, interceptor->IsHandledProtocol(scheme)); |
89 interceptor->Chain(scoped_ptr<net::URLRequestJobFactory>(NULL)); | 89 interceptor->Chain(scoped_ptr<net::URLRequestJobFactory>()); |
90 } | 90 } |
91 | 91 |
92 void AssertWillHandle( | 92 void AssertWillHandle( |
93 const std::string& scheme, | 93 const std::string& scheme, |
94 bool expected, | 94 bool expected, |
95 ProtocolHandlerRegistry::JobInterceptorFactory* interceptor) { | 95 ProtocolHandlerRegistry::JobInterceptorFactory* interceptor) { |
96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
97 BrowserThread::PostTask(BrowserThread::IO, | 97 BrowserThread::PostTask(BrowserThread::IO, |
98 FROM_HERE, | 98 FROM_HERE, |
99 base::Bind(AssertWillHandleIO, | 99 base::Bind(AssertWillHandleIO, |
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 | 916 |
917 TEST_F(ProtocolHandlerRegistryTest, MAYBE_TestInstallDefaultHandler) { | 917 TEST_F(ProtocolHandlerRegistryTest, MAYBE_TestInstallDefaultHandler) { |
918 RecreateRegistry(false); | 918 RecreateRegistry(false); |
919 registry()->AddPredefinedHandler(CreateProtocolHandler( | 919 registry()->AddPredefinedHandler(CreateProtocolHandler( |
920 "test", GURL("http://test.com/%s"), "Test")); | 920 "test", GURL("http://test.com/%s"), "Test")); |
921 registry()->InitProtocolSettings(); | 921 registry()->InitProtocolSettings(); |
922 std::vector<std::string> protocols; | 922 std::vector<std::string> protocols; |
923 registry()->GetRegisteredProtocols(&protocols); | 923 registry()->GetRegisteredProtocols(&protocols); |
924 ASSERT_EQ(static_cast<size_t>(1), protocols.size()); | 924 ASSERT_EQ(static_cast<size_t>(1), protocols.size()); |
925 } | 925 } |
OLD | NEW |