diff options
Diffstat (limited to 'chrome_frame/test/net/test_automation_provider.cc')
-rw-r--r-- | chrome_frame/test/net/test_automation_provider.cc | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/chrome_frame/test/net/test_automation_provider.cc b/chrome_frame/test/net/test_automation_provider.cc index f1a3b13..d9cd8db 100644 --- a/chrome_frame/test/net/test_automation_provider.cc +++ b/chrome_frame/test/net/test_automation_provider.cc @@ -23,16 +23,22 @@ bool CFTestsDisabled() { } // end namespace +TestAutomationProvider* TestAutomationProvider::g_provider_instance_ = NULL; + TestAutomationProvider::TestAutomationProvider( Profile* profile, TestAutomationProviderDelegate* delegate) : AutomationProvider(profile), tab_handle_(-1), delegate_(delegate) { filter_ = new TestAutomationResourceMessageFilter(this); - URLRequest::RegisterRequestInterceptor(this); + URLRequest::RegisterProtocolFactory("http", + TestAutomationProvider::Factory); + URLRequest::RegisterProtocolFactory("https", + TestAutomationProvider::Factory); + g_provider_instance_ = this; } TestAutomationProvider::~TestAutomationProvider() { - URLRequest::UnregisterRequestInterceptor(this); + g_provider_instance_ = NULL; } void TestAutomationProvider::OnMessageReceived(const IPC::Message& msg) { @@ -56,7 +62,8 @@ bool TestAutomationProvider::Send(IPC::Message* msg) { return AutomationProvider::Send(msg); } -URLRequestJob* TestAutomationProvider::MaybeIntercept(URLRequest* request) { +URLRequestJob* TestAutomationProvider::Factory(URLRequest* request, + const std::string& scheme) { if (CFTestsDisabled()) return NULL; @@ -67,8 +74,8 @@ URLRequestJob* TestAutomationProvider::MaybeIntercept(URLRequest* request) { // We could also check if the current thread is our TestUrlRequest thread // and only intercept requests that belong to that thread. - if (request->GetUserData(NULL) == NULL) { - DCHECK(tab_handle_ != -1); + if (g_provider_instance_ && request->GetUserData(NULL) == NULL) { + DCHECK(g_provider_instance_->tab_handle_ != -1); // We generate our own request id which is also what // ResourceDispatcherHost does (well, the id is actually generated by // ResourceDispatcher). Since these requests are divided into with @@ -76,7 +83,8 @@ URLRequestJob* TestAutomationProvider::MaybeIntercept(URLRequest* request) { // a little easier, we have a significantly higher start value. static int new_id = 0x00100000; URLRequestAutomationJob* job = new URLRequestAutomationJob(request, - tab_handle_, new_id++, filter_); + g_provider_instance_->tab_handle_, new_id++, + g_provider_instance_->filter_); return job; } } |