OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifndef CHROME_FRAME_TEST_NET_TEST_AUTOMATION_PROVIDER_H_ | 4 #ifndef CHROME_FRAME_TEST_NET_TEST_AUTOMATION_PROVIDER_H_ |
5 #define CHROME_FRAME_TEST_NET_TEST_AUTOMATION_PROVIDER_H_ | 5 #define CHROME_FRAME_TEST_NET_TEST_AUTOMATION_PROVIDER_H_ |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include "chrome/browser/automation/automation_provider.h" | 8 #include "chrome/browser/automation/automation_provider.h" |
9 | 9 |
10 class TestAutomationResourceMessageFilter; | 10 namespace net { |
11 class URLRequest; | 11 class URLRequest; |
12 class URLRequestJob; | 12 class URLRequestJob; |
| 13 } // namespace net |
| 14 |
| 15 class TestAutomationResourceMessageFilter; |
13 | 16 |
14 // Callback interface for TestAutomationProvider. | 17 // Callback interface for TestAutomationProvider. |
15 class TestAutomationProviderDelegate { | 18 class TestAutomationProviderDelegate { |
16 public: | 19 public: |
17 virtual void OnInitialTabLoaded() = 0; | 20 virtual void OnInitialTabLoaded() = 0; |
18 }; | 21 }; |
19 | 22 |
20 // A slightly customized version of AutomationProvider. | 23 // A slightly customized version of AutomationProvider. |
21 // We override AutomationProvider to be able to filter received messages | 24 // We override AutomationProvider to be able to filter received messages |
22 // (see TestAutomationResourceMessageFilter) and know when the initial | 25 // (see TestAutomationResourceMessageFilter) and know when the initial |
23 // ExternalTab has been loaded. | 26 // ExternalTab has been loaded. |
24 // In order to intercept UrlRequests and make the URLRequestAutomationJob class | 27 // In order to intercept UrlRequests and make the URLRequestAutomationJob class |
25 // handle requests from unit tests, we register a protocol factory for | 28 // handle requests from unit tests, we register a protocol factory for |
26 // http/https. | 29 // http/https. |
27 class TestAutomationProvider | 30 class TestAutomationProvider |
28 : public AutomationProvider { | 31 : public AutomationProvider { |
29 public: | 32 public: |
30 explicit TestAutomationProvider(Profile* profile, | 33 explicit TestAutomationProvider(Profile* profile, |
31 TestAutomationProviderDelegate* delegate); | 34 TestAutomationProviderDelegate* delegate); |
32 | 35 |
33 virtual ~TestAutomationProvider(); | 36 virtual ~TestAutomationProvider(); |
34 | 37 |
35 // AutomationProvider overrides. | 38 // AutomationProvider overrides. |
36 virtual void OnMessageReceived(const IPC::Message& msg); | 39 virtual void OnMessageReceived(const IPC::Message& msg); |
37 virtual bool Send(IPC::Message* msg); | 40 virtual bool Send(IPC::Message* msg); |
38 | 41 |
39 // Protocol factory for handling http/https requests over automation. | 42 // Protocol factory for handling http/https requests over automation. |
40 static URLRequestJob* Factory(URLRequest* request, | 43 static net::URLRequestJob* Factory(net::URLRequest* request, |
41 const std::string& scheme); | 44 const std::string& scheme); |
42 | 45 |
43 // Call to instantiate and initialize a new instance of | 46 // Call to instantiate and initialize a new instance of |
44 // TestAutomationProvider. | 47 // TestAutomationProvider. |
45 static TestAutomationProvider* NewAutomationProvider( | 48 static TestAutomationProvider* NewAutomationProvider( |
46 Profile* p, | 49 Profile* p, |
47 const std::string& channel, | 50 const std::string& channel, |
48 TestAutomationProviderDelegate* delegate); | 51 TestAutomationProviderDelegate* delegate); |
49 | 52 |
50 protected: | 53 protected: |
51 virtual std::string GetProtocolVersion(); | 54 virtual std::string GetProtocolVersion(); |
52 | 55 |
53 int tab_handle_; | 56 int tab_handle_; |
54 TestAutomationProviderDelegate* delegate_; | 57 TestAutomationProviderDelegate* delegate_; |
55 | 58 |
56 static TestAutomationProvider* g_provider_instance_; | 59 static TestAutomationProvider* g_provider_instance_; |
57 }; | 60 }; |
58 | 61 |
59 #endif // CHROME_FRAME_TEST_NET_TEST_AUTOMATION_PROVIDER_H_ | 62 #endif // CHROME_FRAME_TEST_NET_TEST_AUTOMATION_PROVIDER_H_ |
OLD | NEW |