summaryrefslogtreecommitdiffstats
path: root/chrome_frame/test
diff options
context:
space:
mode:
Diffstat (limited to 'chrome_frame/test')
-rw-r--r--chrome_frame/test/net/fake_external_tab.cc3
-rw-r--r--chrome_frame/test/net/test_automation_provider.cc20
-rw-r--r--chrome_frame/test/net/test_automation_provider.h17
3 files changed, 26 insertions, 14 deletions
diff --git a/chrome_frame/test/net/fake_external_tab.cc b/chrome_frame/test/net/fake_external_tab.cc
index 5168372..5caadd33 100644
--- a/chrome_frame/test/net/fake_external_tab.cc
+++ b/chrome_frame/test/net/fake_external_tab.cc
@@ -19,6 +19,7 @@
#include "base/scoped_variant_win.h"
#include "chrome/browser/browser_prefs.h"
+#include "chrome/browser/plugin_service.h"
#include "chrome/browser/process_singleton.h"
#include "chrome/browser/profile_manager.h"
#include "chrome/browser/renderer_host/render_process_host.h"
@@ -28,7 +29,6 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
-
#include "chrome_frame/utils.h"
#include "chrome_frame/test/chrome_frame_test_utils.h"
#include "chrome_frame/test/net/dialog_watchdog.h"
@@ -386,6 +386,7 @@ int main(int argc, char** argv) {
watchdog.AddObserver(&credentials);
testing::InitGoogleTest(&argc, argv);
FilterDisabledTests();
+ PluginService::EnableChromePlugins(false);
CFUrlRequestUnittestRunner test_suite(argc, argv);
test_suite.RunMainUIThread();
return 0;
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;
}
}
diff --git a/chrome_frame/test/net/test_automation_provider.h b/chrome_frame/test/net/test_automation_provider.h
index 75830ba..a745537 100644
--- a/chrome_frame/test/net/test_automation_provider.h
+++ b/chrome_frame/test/net/test_automation_provider.h
@@ -19,22 +19,23 @@ class TestAutomationProviderDelegate {
// (see TestAutomationResourceMessageFilter) and know when the initial
// ExternalTab has been loaded.
// In order to intercept UrlRequests and make the URLRequestAutomationJob class
-// handle requests from unit tests, we also implement URLRequest::Interceptor.
+// handle requests from unit tests, we register a protocol factory for
+// http/https.
class TestAutomationProvider
- : public AutomationProvider,
- public URLRequest::Interceptor {
+ : public AutomationProvider {
public:
explicit TestAutomationProvider(Profile* profile,
TestAutomationProviderDelegate* delegate);
virtual ~TestAutomationProvider();
-
+
// AutomationProvider overrides.
virtual void OnMessageReceived(const IPC::Message& msg);
virtual bool Send(IPC::Message* msg);
- // URLRequest::Interceptor.
- virtual URLRequestJob* MaybeIntercept(URLRequest* request);
+ // Protocol factory for handling http/https requests over automation.
+ static URLRequestJob* Factory(URLRequest* request,
+ const std::string& scheme);
// Call to instantiate and initialize a new instance of
// TestAutomationProvider.
@@ -47,6 +48,8 @@ class TestAutomationProvider
scoped_refptr<TestAutomationResourceMessageFilter> filter_;
int tab_handle_;
TestAutomationProviderDelegate* delegate_;
+
+ static TestAutomationProvider* g_provider_instance_;
};
-#endif CHROME_FRAME_TEST_NET_TEST_AUTOMATION_PROVIDER_H_
+#endif // CHROME_FRAME_TEST_NET_TEST_AUTOMATION_PROVIDER_H_