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
3 // found in the LICENSE file.
4 #ifndef CHROME_FRAME_TEST_NET_TEST_AUTOMATION_PROVIDER_H_
5 #define CHROME_FRAME_TEST_NET_TEST_AUTOMATION_PROVIDER_H_
8 #include "chrome/browser/automation/automation_provider.h"
11 class NetworkDelegate;
16 class TestAutomationResourceMessageFilter;
18 // Callback interface for TestAutomationProvider.
19 class TestAutomationProviderDelegate {
21 virtual void OnInitialTabLoaded() = 0;
22 virtual void OnProviderDestroyed() = 0;
25 // A slightly customized version of AutomationProvider.
26 // We override AutomationProvider to be able to filter received messages
27 // (see TestAutomationResourceMessageFilter) and know when the initial
28 // ExternalTab has been loaded.
29 // In order to intercept UrlRequests and make the URLRequestAutomationJob class
30 // handle requests from unit tests, we register a protocol factory for
32 class TestAutomationProvider
33 : public AutomationProvider {
35 TestAutomationProvider(Profile* profile,
36 TestAutomationProviderDelegate* delegate);
38 virtual ~TestAutomationProvider();
40 // AutomationProvider overrides.
41 virtual bool OnMessageReceived(const IPC::Message& msg);
42 virtual bool Send(IPC::Message* msg);
44 // Protocol factory for handling http/https requests over automation.
45 static net::URLRequestJob* Factory(net::URLRequest* request,
46 net::NetworkDelegate* network_delegate,
47 const std::string& scheme);
49 // Call to instantiate and initialize a new instance of
50 // TestAutomationProvider.
51 static TestAutomationProvider* NewAutomationProvider(
53 const std::string& channel,
54 TestAutomationProviderDelegate* delegate);
57 virtual std::string GetProtocolVersion();
60 TestAutomationProviderDelegate* delegate_;
62 static TestAutomationProvider* g_provider_instance_;
65 #endif // CHROME_FRAME_TEST_NET_TEST_AUTOMATION_PROVIDER_H_