OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_AUTOMATION_TESTING_AUTOMATION_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_AUTOMATION_TESTING_AUTOMATION_PROVIDER_H_ |
6 #define CHROME_BROWSER_AUTOMATION_TESTING_AUTOMATION_PROVIDER_H_ | 6 #define CHROME_BROWSER_AUTOMATION_TESTING_AUTOMATION_PROVIDER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include <list> |
9 #include <string> | 10 #include <string> |
10 | 11 |
11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
14 #include "chrome/browser/automation/automation_provider.h" | 15 #include "chrome/browser/automation/automation_provider.h" |
15 #include "chrome/browser/automation/automation_provider_json.h" | 16 #include "chrome/browser/automation/automation_provider_json.h" |
16 #include "chrome/browser/history/history.h" | 17 #include "chrome/browser/history/history.h" |
17 #include "chrome/browser/importer/importer_list_observer.h" | 18 #include "chrome/browser/importer/importer_list_observer.h" |
18 #include "chrome/browser/sync/profile_sync_service_harness.h" | 19 #include "chrome/browser/sync/profile_sync_service_harness.h" |
19 #include "chrome/browser/ui/browser_list.h" | 20 #include "chrome/browser/ui/browser_list.h" |
| 21 #include "content/browser/trace_subscriber_stdio.h" |
20 #include "content/common/notification_registrar.h" | 22 #include "content/common/notification_registrar.h" |
21 #include "content/common/page_type.h" | 23 #include "content/common/page_type.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
23 | 25 |
24 class ImporterList; | 26 class ImporterList; |
25 class TemplateURLService; | 27 class TemplateURLService; |
26 | 28 |
27 namespace base { | 29 namespace base { |
28 class DictionaryValue; | 30 class DictionaryValue; |
29 } | 31 } |
30 | 32 |
31 // This is an automation provider containing testing calls. | 33 // This is an automation provider containing testing calls. |
32 class TestingAutomationProvider : public AutomationProvider, | 34 class TestingAutomationProvider : public AutomationProvider, |
33 public BrowserList::Observer, | 35 public BrowserList::Observer, |
34 public importer::ImporterListObserver, | 36 public importer::ImporterListObserver, |
35 public NotificationObserver { | 37 public NotificationObserver, |
| 38 public TraceSubscriber { |
36 public: | 39 public: |
37 explicit TestingAutomationProvider(Profile* profile); | 40 explicit TestingAutomationProvider(Profile* profile); |
38 | 41 |
39 virtual IPC::Channel::Mode GetChannelMode(bool use_named_interface); | 42 virtual IPC::Channel::Mode GetChannelMode(bool use_named_interface); |
40 | 43 |
41 // IPC::Channel::Listener: | 44 // IPC::Channel::Listener: |
42 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 45 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
43 virtual void OnChannelError() OVERRIDE; | 46 virtual void OnChannelError() OVERRIDE; |
44 | 47 |
45 private: | 48 private: |
46 class PopupMenuWaiter; | 49 class PopupMenuWaiter; |
47 | 50 |
48 // Storage for ImportSettings() to resume operations after a callback. | 51 // Storage for ImportSettings() to resume operations after a callback. |
49 struct ImportSettingsData { | 52 struct ImportSettingsData { |
50 string16 browser_name; | 53 string16 browser_name; |
51 int import_items; | 54 int import_items; |
52 bool first_run; | 55 bool first_run; |
53 Browser* browser; | 56 Browser* browser; |
54 IPC::Message* reply_message; | 57 IPC::Message* reply_message; |
55 }; | 58 }; |
56 | 59 |
| 60 // Storage for EndTracing() to resume operations after a callback. |
| 61 struct TracingData { |
| 62 std::list<std::string> json_output; |
| 63 scoped_ptr<IPC::Message> reply_message; |
| 64 }; |
| 65 |
57 virtual ~TestingAutomationProvider(); | 66 virtual ~TestingAutomationProvider(); |
58 | 67 |
59 // BrowserList::Observer: | 68 // BrowserList::Observer: |
60 virtual void OnBrowserAdded(const Browser* browser) OVERRIDE; | 69 virtual void OnBrowserAdded(const Browser* browser) OVERRIDE; |
61 virtual void OnBrowserRemoved(const Browser* browser) OVERRIDE; | 70 virtual void OnBrowserRemoved(const Browser* browser) OVERRIDE; |
62 | 71 |
63 // importer::ImporterListObserver: | 72 // importer::ImporterListObserver: |
64 virtual void OnSourceProfilesLoaded() OVERRIDE; | 73 virtual void OnSourceProfilesLoaded() OVERRIDE; |
65 | 74 |
66 // NotificationObserver: | 75 // NotificationObserver: |
67 virtual void Observe(int type, | 76 virtual void Observe(int type, |
68 const NotificationSource& source, | 77 const NotificationSource& source, |
69 const NotificationDetails& details) OVERRIDE; | 78 const NotificationDetails& details) OVERRIDE; |
70 | 79 |
| 80 // TraceSubscriber: |
| 81 virtual void OnEndTracingComplete() OVERRIDE; |
| 82 virtual void OnTraceDataCollected(const std::string& json_events) OVERRIDE; |
| 83 |
71 // IPC Message callbacks. | 84 // IPC Message callbacks. |
72 void CloseBrowser(int handle, IPC::Message* reply_message); | 85 void CloseBrowser(int handle, IPC::Message* reply_message); |
73 void CloseBrowserAsync(int browser_handle); | 86 void CloseBrowserAsync(int browser_handle); |
74 void ActivateTab(int handle, int at_index, int* status); | 87 void ActivateTab(int handle, int at_index, int* status); |
75 void AppendTab(int handle, const GURL& url, IPC::Message* reply_message); | 88 void AppendTab(int handle, const GURL& url, IPC::Message* reply_message); |
76 void GetActiveTabIndex(int handle, int* active_tab_index); | 89 void GetActiveTabIndex(int handle, int* active_tab_index); |
77 void CloseTab(int tab_handle, bool wait_until_closed, | 90 void CloseTab(int tab_handle, bool wait_until_closed, |
78 IPC::Message* reply_message); | 91 IPC::Message* reply_message); |
79 void GetCookies(const GURL& url, int handle, int* value_size, | 92 void GetCookies(const GURL& url, int handle, int* value_size, |
80 std::string* value); | 93 std::string* value); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 const gfx::Point& location); | 144 const gfx::Point& location); |
132 void WindowSimulateKeyPress(const IPC::Message& message, | 145 void WindowSimulateKeyPress(const IPC::Message& message, |
133 int handle, | 146 int handle, |
134 int key, | 147 int key, |
135 int flags); | 148 int flags); |
136 void GetTabCount(int handle, int* tab_count); | 149 void GetTabCount(int handle, int* tab_count); |
137 void GetType(int handle, int* type_as_int); | 150 void GetType(int handle, int* type_as_int); |
138 void IsBrowserInApplicationMode(int handle, | 151 void IsBrowserInApplicationMode(int handle, |
139 bool* is_application, | 152 bool* is_application, |
140 bool* success); | 153 bool* success); |
| 154 void BeginTracing(const std::vector<std::string>& included_categories, |
| 155 const std::vector<std::string>& excluded_categories, |
| 156 bool* result); |
| 157 void EndTracing(IPC::Message* reply_message); |
| 158 void GetTracingOutput(std::string* chunk, int* remaining_chunks); |
141 void GetTab(int win_handle, int tab_index, int* tab_handle); | 159 void GetTab(int win_handle, int tab_index, int* tab_handle); |
142 void GetTabProcessID(int handle, int* process_id); | 160 void GetTabProcessID(int handle, int* process_id); |
143 void GetTabTitle(int handle, int* title_string_size, std::wstring* title); | 161 void GetTabTitle(int handle, int* title_string_size, std::wstring* title); |
144 void GetTabIndex(int handle, int* tabstrip_index); | 162 void GetTabIndex(int handle, int* tabstrip_index); |
145 void GetTabURL(int handle, bool* success, GURL* url); | 163 void GetTabURL(int handle, bool* success, GURL* url); |
146 void GetShelfVisibility(int handle, bool* visible); | 164 void GetShelfVisibility(int handle, bool* visible); |
147 void IsFullscreen(int handle, bool* is_fullscreen); | 165 void IsFullscreen(int handle, bool* is_fullscreen); |
148 void GetFullscreenBubbleVisibility(int handle, bool* is_visible); | 166 void GetFullscreenBubbleVisibility(int handle, bool* is_visible); |
149 | 167 |
150 void ExecuteJavascript(int handle, | 168 void ExecuteJavascript(int handle, |
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1338 HistoryService::Handle redirect_query_; | 1356 HistoryService::Handle redirect_query_; |
1339 | 1357 |
1340 NotificationRegistrar registrar_; | 1358 NotificationRegistrar registrar_; |
1341 | 1359 |
1342 // Used to enumerate browser profiles. | 1360 // Used to enumerate browser profiles. |
1343 scoped_refptr<ImporterList> importer_list_; | 1361 scoped_refptr<ImporterList> importer_list_; |
1344 | 1362 |
1345 // The stored data for the ImportSettings operation. | 1363 // The stored data for the ImportSettings operation. |
1346 ImportSettingsData import_settings_data_; | 1364 ImportSettingsData import_settings_data_; |
1347 | 1365 |
| 1366 // Deferred IPC for EndTracing. |
| 1367 TracingData tracing_data_; |
| 1368 |
1348 DISALLOW_COPY_AND_ASSIGN(TestingAutomationProvider); | 1369 DISALLOW_COPY_AND_ASSIGN(TestingAutomationProvider); |
1349 }; | 1370 }; |
1350 | 1371 |
1351 #endif // CHROME_BROWSER_AUTOMATION_TESTING_AUTOMATION_PROVIDER_H_ | 1372 #endif // CHROME_BROWSER_AUTOMATION_TESTING_AUTOMATION_PROVIDER_H_ |
OLD | NEW |