| 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 <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 55 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 56 BrowserThread::PostTask(BrowserThread::IO, | 56 BrowserThread::PostTask(BrowserThread::IO, |
| 57 FROM_HERE, | 57 FROM_HERE, |
| 58 base::Bind(AssertInterceptedIO, | 58 base::Bind(AssertInterceptedIO, |
| 59 url, | 59 url, |
| 60 base::Unretained(interceptor))); | 60 base::Unretained(interceptor))); |
| 61 base::RunLoop().RunUntilIdle(); | 61 base::RunLoop().RunUntilIdle(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 // FakeURLRequestJobFactory returns NULL for all job creation requests and false | 64 // FakeURLRequestJobFactory returns NULL for all job creation requests and false |
| 65 // for all IsHandled*() requests. FakeURLRequestJobFactory can be chained to | 65 // for all IsHandledProtocol() requests. FakeURLRequestJobFactory can be chained |
| 66 // ProtocolHandlerRegistry::JobInterceptorFactory so the result of | 66 // to ProtocolHandlerRegistry::JobInterceptorFactory so the result of |
| 67 // MaybeCreateJobWithProtocolHandler() indicates whether the | 67 // MaybeCreateJobWithProtocolHandler() indicates whether the |
| 68 // ProtocolHandlerRegistry properly handled a job creation request. | 68 // ProtocolHandlerRegistry properly handled a job creation request. |
| 69 class FakeURLRequestJobFactory : public net::URLRequestJobFactory { | 69 class FakeURLRequestJobFactory : public net::URLRequestJobFactory { |
| 70 // net::URLRequestJobFactory implementation: | 70 // net::URLRequestJobFactory implementation: |
| 71 net::URLRequestJob* MaybeCreateJobWithProtocolHandler( | 71 net::URLRequestJob* MaybeCreateJobWithProtocolHandler( |
| 72 const std::string& scheme, | 72 const std::string& scheme, |
| 73 net::URLRequest* request, | 73 net::URLRequest* request, |
| 74 net::NetworkDelegate* network_delegate) const override { | 74 net::NetworkDelegate* network_delegate) const override { |
| 75 return NULL; | 75 return NULL; |
| 76 } | 76 } |
| 77 | 77 |
| 78 net::URLRequestJob* MaybeInterceptRedirect( | 78 net::URLRequestJob* MaybeInterceptRedirect( |
| 79 net::URLRequest* request, | 79 net::URLRequest* request, |
| 80 net::NetworkDelegate* network_delegate, | 80 net::NetworkDelegate* network_delegate, |
| 81 const GURL& location) const override { | 81 const GURL& location) const override { |
| 82 return nullptr; | 82 return nullptr; |
| 83 } | 83 } |
| 84 | 84 |
| 85 net::URLRequestJob* MaybeInterceptResponse( | 85 net::URLRequestJob* MaybeInterceptResponse( |
| 86 net::URLRequest* request, | 86 net::URLRequest* request, |
| 87 net::NetworkDelegate* network_delegate) const override { | 87 net::NetworkDelegate* network_delegate) const override { |
| 88 return nullptr; | 88 return nullptr; |
| 89 } | 89 } |
| 90 | 90 |
| 91 bool IsHandledProtocol(const std::string& scheme) const override { | 91 bool IsHandledProtocol(const std::string& scheme) const override { |
| 92 return false; | 92 return false; |
| 93 } | 93 } |
| 94 bool IsHandledURL(const GURL& url) const override { return false; } | |
| 95 bool IsSafeRedirectTarget(const GURL& location) const override { | 94 bool IsSafeRedirectTarget(const GURL& location) const override { |
| 96 return true; | 95 return true; |
| 97 } | 96 } |
| 98 }; | 97 }; |
| 99 | 98 |
| 100 void AssertWillHandleIO( | 99 void AssertWillHandleIO( |
| 101 const std::string& scheme, | 100 const std::string& scheme, |
| 102 bool expected, | 101 bool expected, |
| 103 ProtocolHandlerRegistry::JobInterceptorFactory* interceptor) { | 102 ProtocolHandlerRegistry::JobInterceptorFactory* interceptor) { |
| 104 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 103 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| (...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 // added to pref. | 1083 // added to pref. |
| 1085 ASSERT_EQ(InPrefIgnoredHandlerCount(), 2); | 1084 ASSERT_EQ(InPrefIgnoredHandlerCount(), 2); |
| 1086 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); | 1085 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); |
| 1087 | 1086 |
| 1088 registry()->RemoveIgnoredHandler(p2u1); | 1087 registry()->RemoveIgnoredHandler(p2u1); |
| 1089 | 1088 |
| 1090 // p2u1 installed by user and policy, so it is removed from pref alone. | 1089 // p2u1 installed by user and policy, so it is removed from pref alone. |
| 1091 ASSERT_EQ(InPrefIgnoredHandlerCount(), 1); | 1090 ASSERT_EQ(InPrefIgnoredHandlerCount(), 1); |
| 1092 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); | 1091 ASSERT_EQ(InMemoryIgnoredHandlerCount(), 4); |
| 1093 } | 1092 } |
| OLD | NEW |