OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 // This implements a browser-side endpoint for UI automation activity. | 5 // This implements a browser-side endpoint for UI automation activity. |
6 // The client-side endpoint is implemented by AutomationProxy. | 6 // The client-side endpoint is implemented by AutomationProxy. |
7 // The entire lifetime of this object should be contained within that of | 7 // The entire lifetime of this object should be contained within that of |
8 // the BrowserProcess, and in particular the NotificationService that's | 8 // the BrowserProcess, and in particular the NotificationService that's |
9 // hung off of it. | 9 // hung off of it. |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "base/memory/weak_ptr.h" | 22 #include "base/memory/weak_ptr.h" |
23 #include "base/observer_list.h" | 23 #include "base/observer_list.h" |
24 #include "base/sequenced_task_runner_helpers.h" | 24 #include "base/sequenced_task_runner_helpers.h" |
25 #include "base/strings/string16.h" | 25 #include "base/strings/string16.h" |
26 #include "chrome/browser/common/cancelable_request.h" | 26 #include "chrome/browser/common/cancelable_request.h" |
27 #include "chrome/common/automation_constants.h" | 27 #include "chrome/common/automation_constants.h" |
28 #include "chrome/common/content_settings.h" | 28 #include "chrome/common/content_settings.h" |
29 #include "components/autofill/core/browser/field_types.h" | 29 #include "components/autofill/core/browser/field_types.h" |
30 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
31 #include "content/public/browser/notification_observer.h" | 31 #include "content/public/browser/notification_observer.h" |
32 #include "content/public/browser/trace_subscriber.h" | |
33 #include "ipc/ipc_channel.h" | 32 #include "ipc/ipc_channel.h" |
34 #include "ipc/ipc_listener.h" | 33 #include "ipc/ipc_listener.h" |
35 #include "ipc/ipc_sender.h" | 34 #include "ipc/ipc_sender.h" |
36 | 35 |
37 #if defined(OS_WIN) && !defined(USE_AURA) | 36 #if defined(OS_WIN) && !defined(USE_AURA) |
38 #include "ui/gfx/native_widget_types.h" | 37 #include "ui/gfx/native_widget_types.h" |
39 #endif // defined(OS_WIN) && !defined(USE_AURA) | 38 #endif // defined(OS_WIN) && !defined(USE_AURA) |
40 | 39 |
41 class AutomationBrowserTracker; | 40 class AutomationBrowserTracker; |
42 class AutomationResourceMessageFilter; | 41 class AutomationResourceMessageFilter; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 74 |
76 namespace gfx { | 75 namespace gfx { |
77 class Point; | 76 class Point; |
78 } | 77 } |
79 | 78 |
80 class AutomationProvider | 79 class AutomationProvider |
81 : public IPC::Listener, | 80 : public IPC::Listener, |
82 public IPC::Sender, | 81 public IPC::Sender, |
83 public base::SupportsWeakPtr<AutomationProvider>, | 82 public base::SupportsWeakPtr<AutomationProvider>, |
84 public base::RefCountedThreadSafe< | 83 public base::RefCountedThreadSafe< |
85 AutomationProvider, content::BrowserThread::DeleteOnUIThread>, | 84 AutomationProvider, content::BrowserThread::DeleteOnUIThread> { |
86 public content::TraceSubscriber { | |
87 public: | 85 public: |
88 explicit AutomationProvider(Profile* profile); | 86 explicit AutomationProvider(Profile* profile); |
89 | 87 |
90 Profile* profile() const { return profile_; } | 88 Profile* profile() const { return profile_; } |
91 | 89 |
92 void set_profile(Profile* profile); | 90 void set_profile(Profile* profile); |
93 | 91 |
94 // Initializes a channel for a connection to an AutomationProxy. | 92 // Initializes a channel for a connection to an AutomationProxy. |
95 // If channel_id starts with kNamedInterfacePrefix, it will act | 93 // If channel_id starts with kNamedInterfacePrefix, it will act |
96 // as a server, create a named IPC socket with channel_id as its | 94 // as a server, create a named IPC socket with channel_id as its |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 bool find_next, | 206 bool find_next, |
209 IPC::Message* reply_message); | 207 IPC::Message* reply_message); |
210 | 208 |
211 scoped_refptr<AutomationResourceMessageFilter> | 209 scoped_refptr<AutomationResourceMessageFilter> |
212 automation_resource_message_filter_; | 210 automation_resource_message_filter_; |
213 | 211 |
214 // True iff we should open a new automation IPC channel if it closes. | 212 // True iff we should open a new automation IPC channel if it closes. |
215 bool reinitialize_on_channel_error_; | 213 bool reinitialize_on_channel_error_; |
216 | 214 |
217 private: | 215 private: |
218 // Storage for EndTracing() to resume operations after a callback. | |
219 struct TracingData { | |
220 std::list<std::string> trace_output; | |
221 scoped_ptr<IPC::Message> reply_message; | |
222 }; | |
223 | |
224 // TraceSubscriber: | |
225 virtual void OnEndTracingComplete() OVERRIDE; | |
226 virtual void OnTraceDataCollected( | |
227 const scoped_refptr<base::RefCountedString>& trace_fragment) OVERRIDE; | |
228 | |
229 void OnUnhandledMessage(const IPC::Message& message); | 216 void OnUnhandledMessage(const IPC::Message& message); |
230 | 217 |
231 // Clear and reinitialize the automation IPC channel. | 218 // Clear and reinitialize the automation IPC channel. |
232 bool ReinitializeChannel(); | 219 bool ReinitializeChannel(); |
233 | 220 |
234 void HandleUnused(const IPC::Message& message, int handle); | 221 void HandleUnused(const IPC::Message& message, int handle); |
235 void GetFilteredInetHitCount(int* hit_count); | 222 void GetFilteredInetHitCount(int* hit_count); |
236 void SetProxyConfig(const std::string& new_proxy_config); | 223 void SetProxyConfig(const std::string& new_proxy_config); |
237 | 224 |
238 // Responds to the FindInPage request, retrieves the search query parameters, | 225 // Responds to the FindInPage request, retrieves the search query parameters, |
239 // launches an observer to listen for results and issues a StartFind request. | 226 // launches an observer to listen for results and issues a StartFind request. |
240 void HandleFindRequest(int handle, | 227 void HandleFindRequest(int handle, |
241 const AutomationMsg_Find_Params& params, | 228 const AutomationMsg_Find_Params& params, |
242 IPC::Message* reply_message); | 229 IPC::Message* reply_message); |
243 | 230 |
244 void OnSetPageFontSize(int tab_handle, int font_size); | 231 void OnSetPageFontSize(int tab_handle, int font_size); |
245 | 232 |
246 // See browsing_data_remover.h for explanation of bitmap fields. | 233 // See browsing_data_remover.h for explanation of bitmap fields. |
247 void RemoveBrowsingData(int remove_mask); | 234 void RemoveBrowsingData(int remove_mask); |
248 | 235 |
249 // Notify the JavaScript engine in the render to change its parameters | 236 // Notify the JavaScript engine in the render to change its parameters |
250 // while performing stress testing. See | 237 // while performing stress testing. See |
251 // |ViewHostMsg_JavaScriptStressTestControl_Commands| in render_messages.h | 238 // |ViewHostMsg_JavaScriptStressTestControl_Commands| in render_messages.h |
252 // for information on the arguments. | 239 // for information on the arguments. |
253 void JavaScriptStressTestControl(int handle, int cmd, int param); | 240 void JavaScriptStressTestControl(int handle, int cmd, int param); |
254 | 241 |
255 void BeginTracing(const std::string& category_patterns, bool* success); | 242 void BeginTracing(const std::string& category_patterns, bool* success); |
256 void EndTracing(IPC::Message* reply_message); | 243 void EndTracing(IPC::Message* reply_message); |
257 void GetTracingOutput(std::string* chunk, bool* success); | 244 void OnTraceDataCollected(IPC::Message* reply_message, |
| 245 const base::FilePath& path); |
258 | 246 |
259 // Asynchronous request for printing the current tab. | 247 // Asynchronous request for printing the current tab. |
260 void PrintAsync(int tab_handle); | 248 void PrintAsync(int tab_handle); |
261 | 249 |
262 // Uses the specified encoding to override the encoding of the page in the | 250 // Uses the specified encoding to override the encoding of the page in the |
263 // specified tab. | 251 // specified tab. |
264 void OverrideEncoding(int tab_handle, | 252 void OverrideEncoding(int tab_handle, |
265 const std::string& encoding_name, | 253 const std::string& encoding_name, |
266 bool* success); | 254 bool* success); |
267 | 255 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 | 332 |
345 // True iff browser finished loading initial set of tabs. | 333 // True iff browser finished loading initial set of tabs. |
346 bool initial_tab_loads_complete_; | 334 bool initial_tab_loads_complete_; |
347 | 335 |
348 // True iff ChromeOS webui login ui is ready. | 336 // True iff ChromeOS webui login ui is ready. |
349 bool login_webui_ready_; | 337 bool login_webui_ready_; |
350 | 338 |
351 // ID of automation channel. | 339 // ID of automation channel. |
352 std::string channel_id_; | 340 std::string channel_id_; |
353 | 341 |
354 // Trace data that has been collected but not flushed to the automation | |
355 // client. | |
356 TracingData tracing_data_; | |
357 | |
358 DISALLOW_COPY_AND_ASSIGN(AutomationProvider); | 342 DISALLOW_COPY_AND_ASSIGN(AutomationProvider); |
359 }; | 343 }; |
360 | 344 |
361 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_H_ | 345 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_H_ |
OLD | NEW |