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_frame/test/net/test_automation_provider.h" | 5 #include "chrome_frame/test/net/test_automation_provider.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_version_info.h" | 8 #include "base/file_version_info.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "chrome/common/automation_messages.h" | 10 #include "chrome/common/automation_messages.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 DCHECK(tab_handle_ == -1) << "Currently only support one tab"; | 62 DCHECK(tab_handle_ == -1) << "Currently only support one tab"; |
63 tab_handle_ = msg->routing_id(); | 63 tab_handle_ = msg->routing_id(); |
64 DVLOG(1) << "Got tab handle: " << tab_handle_; | 64 DVLOG(1) << "Got tab handle: " << tab_handle_; |
65 DCHECK(tab_handle_ != -1 && tab_handle_ != 0); | 65 DCHECK(tab_handle_ != -1 && tab_handle_ != 0); |
66 delegate_->OnInitialTabLoaded(); | 66 delegate_->OnInitialTabLoaded(); |
67 } | 67 } |
68 | 68 |
69 return AutomationProvider::Send(msg); | 69 return AutomationProvider::Send(msg); |
70 } | 70 } |
71 | 71 |
72 net::URLRequestJob* TestAutomationProvider::Factory(net::URLRequest* request, | 72 net::URLRequestJob* TestAutomationProvider::Factory( |
73 const std::string& scheme) { | 73 net::URLRequest* request, |
| 74 net::NetworkDelegate* network_delegate, |
| 75 const std::string& scheme) { |
74 if (CFTestsDisabled()) | 76 if (CFTestsDisabled()) |
75 return NULL; | 77 return NULL; |
76 | 78 |
77 if (request->url().SchemeIs("http") || request->url().SchemeIs("https")) { | 79 if (request->url().SchemeIs("http") || request->url().SchemeIs("https")) { |
78 // Only look at requests that don't have any user data. | 80 // Only look at requests that don't have any user data. |
79 // ResourceDispatcherHost uses the user data for requests that it manages. | 81 // ResourceDispatcherHost uses the user data for requests that it manages. |
80 // We don't want to mess with those. | 82 // We don't want to mess with those. |
81 | 83 |
82 // We could also check if the current thread is our TestUrlRequest thread | 84 // We could also check if the current thread is our TestUrlRequest thread |
83 // and only intercept requests that belong to that thread. | 85 // and only intercept requests that belong to that thread. |
84 if (g_provider_instance_ && request->GetUserData(NULL) == NULL && | 86 if (g_provider_instance_ && request->GetUserData(NULL) == NULL && |
85 g_provider_instance_->tab_handle_ != -1) { | 87 g_provider_instance_->tab_handle_ != -1) { |
86 // We generate our own request id which is also what | 88 // We generate our own request id which is also what |
87 // ResourceDispatcherHost does (well, the id is actually generated by | 89 // ResourceDispatcherHost does (well, the id is actually generated by |
88 // ResourceDispatcher). Since these requests are divided into with | 90 // ResourceDispatcher). Since these requests are divided into with |
89 // and without userdata, we're OK. However, just to make debugging | 91 // and without userdata, we're OK. However, just to make debugging |
90 // a little easier, we have a significantly higher start value. | 92 // a little easier, we have a significantly higher start value. |
91 static int new_id = 0x00100000; | 93 static int new_id = 0x00100000; |
92 URLRequestAutomationJob* job = new URLRequestAutomationJob(request, | 94 URLRequestAutomationJob* job = new URLRequestAutomationJob( |
| 95 request, network_delegate, |
93 g_provider_instance_->tab_handle_, new_id++, | 96 g_provider_instance_->tab_handle_, new_id++, |
94 g_provider_instance_->automation_resource_message_filter_, false); | 97 g_provider_instance_->automation_resource_message_filter_, false); |
95 return job; | 98 return job; |
96 } | 99 } |
97 } | 100 } |
98 | 101 |
99 return NULL; | 102 return NULL; |
100 } | 103 } |
101 | 104 |
102 std::string TestAutomationProvider::GetProtocolVersion() { | 105 std::string TestAutomationProvider::GetProtocolVersion() { |
(...skipping 20 matching lines...) Expand all Loading... |
123 | 126 |
124 // static | 127 // static |
125 TestAutomationProvider* TestAutomationProvider::NewAutomationProvider( | 128 TestAutomationProvider* TestAutomationProvider::NewAutomationProvider( |
126 Profile* p, const std::string& channel, | 129 Profile* p, const std::string& channel, |
127 TestAutomationProviderDelegate* delegate) { | 130 TestAutomationProviderDelegate* delegate) { |
128 TestAutomationProvider* automation = new TestAutomationProvider(p, delegate); | 131 TestAutomationProvider* automation = new TestAutomationProvider(p, delegate); |
129 automation->InitializeChannel(channel); | 132 automation->InitializeChannel(channel); |
130 automation->SetExpectedTabCount(1); | 133 automation->SetExpectedTabCount(1); |
131 return automation; | 134 return automation; |
132 } | 135 } |
OLD | NEW |