| 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/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
| 14 #include "chrome/browser/prefs/pref_service_syncable.h" | 14 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 15 #include "chrome/common/custom_handlers/protocol_handler.h" | 15 #include "chrome/common/custom_handlers/protocol_handler.h" |
| 16 #include "chrome/test/base/testing_browser_process.h" | 16 #include "chrome/test/base/testing_browser_process.h" |
| 17 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
| 18 #include "components/user_prefs/pref_registry_syncable.h" | 18 #include "components/user_prefs/pref_registry_syncable.h" |
| 19 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
| 20 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
| 21 #include "content/public/browser/notification_source.h" | 21 #include "content/public/browser/notification_source.h" |
| 22 #include "content/public/test/test_browser_thread.h" | 22 #include "content/public/test/test_browser_thread.h" |
| 23 #include "content/public/test/test_renderer_host.h" | 23 #include "content/public/test/test_renderer_host.h" |
| 24 #include "net/base/request_priority.h" |
| 24 #include "net/url_request/url_request.h" | 25 #include "net/url_request/url_request.h" |
| 25 #include "net/url_request/url_request_context.h" | 26 #include "net/url_request/url_request_context.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 27 | 28 |
| 28 using content::BrowserThread; | 29 using content::BrowserThread; |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 void AssertInterceptedIO( | 33 void AssertInterceptedIO( |
| 33 const GURL& url, | 34 const GURL& url, |
| 34 net::URLRequestJobFactory* interceptor) { | 35 net::URLRequestJobFactory* interceptor) { |
| 35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 36 net::URLRequestContext context; | 37 net::URLRequestContext context; |
| 37 net::NetworkDelegate *network_delegate = NULL; | 38 net::NetworkDelegate* network_delegate = NULL; |
| 38 net::URLRequest request(url, NULL, &context); | 39 net::URLRequest request( |
| 40 url, net::DEFAULT_PRIORITY, NULL, &context, network_delegate); |
| 39 scoped_refptr<net::URLRequestJob> job = | 41 scoped_refptr<net::URLRequestJob> job = |
| 40 interceptor->MaybeCreateJobWithProtocolHandler( | 42 interceptor->MaybeCreateJobWithProtocolHandler( |
| 41 url.scheme(), &request, network_delegate); | 43 url.scheme(), &request, network_delegate); |
| 42 ASSERT_TRUE(job.get() != NULL); | 44 ASSERT_TRUE(job.get() != NULL); |
| 43 } | 45 } |
| 44 | 46 |
| 45 void AssertIntercepted( | 47 void AssertIntercepted( |
| 46 const GURL& url, | 48 const GURL& url, |
| 47 net::URLRequestJobFactory* interceptor) { | 49 net::URLRequestJobFactory* interceptor) { |
| 48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 | 924 |
| 923 TEST_F(ProtocolHandlerRegistryTest, MAYBE_TestInstallDefaultHandler) { | 925 TEST_F(ProtocolHandlerRegistryTest, MAYBE_TestInstallDefaultHandler) { |
| 924 RecreateRegistry(false); | 926 RecreateRegistry(false); |
| 925 registry()->AddPredefinedHandler(CreateProtocolHandler( | 927 registry()->AddPredefinedHandler(CreateProtocolHandler( |
| 926 "test", GURL("http://test.com/%s"), "Test")); | 928 "test", GURL("http://test.com/%s"), "Test")); |
| 927 registry()->InitProtocolSettings(); | 929 registry()->InitProtocolSettings(); |
| 928 std::vector<std::string> protocols; | 930 std::vector<std::string> protocols; |
| 929 registry()->GetRegisteredProtocols(&protocols); | 931 registry()->GetRegisteredProtocols(&protocols); |
| 930 ASSERT_EQ(static_cast<size_t>(1), protocols.size()); | 932 ASSERT_EQ(static_cast<size_t>(1), protocols.size()); |
| 931 } | 933 } |
| OLD | NEW |