| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 TestAutomationProvider::TestAutomationProvider( | 29 TestAutomationProvider::TestAutomationProvider( |
| 30 Profile* profile, | 30 Profile* profile, |
| 31 TestAutomationProviderDelegate* delegate) | 31 TestAutomationProviderDelegate* delegate) |
| 32 : AutomationProvider(profile), tab_handle_(-1), delegate_(delegate) { | 32 : AutomationProvider(profile), tab_handle_(-1), delegate_(delegate) { |
| 33 // We need to register the protocol factory before the | 33 // We need to register the protocol factory before the |
| 34 // AutomationResourceMessageFilter registers the automation job factory to | 34 // AutomationResourceMessageFilter registers the automation job factory to |
| 35 // ensure that we don't inadvarently end up handling http requests which | 35 // ensure that we don't inadvarently end up handling http requests which |
| 36 // we don't expect. The initial chrome frame page for the network tests | 36 // we don't expect. The initial chrome frame page for the network tests |
| 37 // issues http requests which our test factory should not handle. | 37 // issues http requests which our test factory should not handle. |
| 38 URLRequest::RegisterProtocolFactory("http", | 38 net::URLRequest::RegisterProtocolFactory("http", |
| 39 TestAutomationProvider::Factory); | 39 TestAutomationProvider::Factory); |
| 40 URLRequest::RegisterProtocolFactory("https", | 40 net::URLRequest::RegisterProtocolFactory("https", |
| 41 TestAutomationProvider::Factory); | 41 TestAutomationProvider::Factory); |
| 42 automation_resource_message_filter_ = | 42 automation_resource_message_filter_ = |
| 43 new TestAutomationResourceMessageFilter(this); | 43 new TestAutomationResourceMessageFilter(this); |
| 44 g_provider_instance_ = this; | 44 g_provider_instance_ = this; |
| 45 } | 45 } |
| 46 | 46 |
| 47 TestAutomationProvider::~TestAutomationProvider() { | 47 TestAutomationProvider::~TestAutomationProvider() { |
| 48 g_provider_instance_ = NULL; | 48 g_provider_instance_ = NULL; |
| 49 } | 49 } |
| 50 | 50 |
| 51 void TestAutomationProvider::OnMessageReceived(const IPC::Message& msg) { | 51 void TestAutomationProvider::OnMessageReceived(const IPC::Message& msg) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 62 void* iter = NULL; | 62 void* iter = NULL; |
| 63 CHECK(msg->ReadInt(&iter, &tab_handle_)); | 63 CHECK(msg->ReadInt(&iter, &tab_handle_)); |
| 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 URLRequestJob* TestAutomationProvider::Factory(URLRequest* request, | 72 URLRequestJob* TestAutomationProvider::Factory(net::URLRequest* request, |
| 73 const std::string& scheme) { | 73 const std::string& scheme) { |
| 74 if (CFTestsDisabled()) | 74 if (CFTestsDisabled()) |
| 75 return NULL; | 75 return NULL; |
| 76 | 76 |
| 77 if (request->url().SchemeIs("http") || request->url().SchemeIs("https")) { | 77 if (request->url().SchemeIs("http") || request->url().SchemeIs("https")) { |
| 78 // Only look at requests that don't have any user data. | 78 // Only look at requests that don't have any user data. |
| 79 // ResourceDispatcherHost uses the user data for requests that it manages. | 79 // ResourceDispatcherHost uses the user data for requests that it manages. |
| 80 // We don't want to mess with those. | 80 // We don't want to mess with those. |
| 81 | 81 |
| 82 // We could also check if the current thread is our TestUrlRequest thread | 82 // We could also check if the current thread is our TestUrlRequest thread |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 // static | 117 // static |
| 118 TestAutomationProvider* TestAutomationProvider::NewAutomationProvider( | 118 TestAutomationProvider* TestAutomationProvider::NewAutomationProvider( |
| 119 Profile* p, const std::string& channel, | 119 Profile* p, const std::string& channel, |
| 120 TestAutomationProviderDelegate* delegate) { | 120 TestAutomationProviderDelegate* delegate) { |
| 121 TestAutomationProvider* automation = new TestAutomationProvider(p, delegate); | 121 TestAutomationProvider* automation = new TestAutomationProvider(p, delegate); |
| 122 automation->InitializeChannel(channel); | 122 automation->InitializeChannel(channel); |
| 123 automation->SetExpectedTabCount(1); | 123 automation->SetExpectedTabCount(1); |
| 124 return automation; | 124 return automation; |
| 125 } | 125 } |
| OLD | NEW |