1 // Copyright 2013 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.
5 #ifndef CHROME_BROWSER_AUTOMATION_TESTING_AUTOMATION_PROVIDER_H_
6 #define CHROME_BROWSER_AUTOMATION_TESTING_AUTOMATION_PROVIDER_H_
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "chrome/browser/automation/automation_event_observers.h"
16 #include "chrome/browser/automation/automation_event_queue.h"
17 #include "chrome/browser/automation/automation_provider.h"
18 #include "chrome/browser/automation/automation_provider_json.h"
19 #include "chrome/browser/history/history_service.h"
20 #include "chrome/browser/ui/browser_list_observer.h"
21 #include "content/public/browser/notification_registrar.h"
22 #include "content/public/common/page_type.h"
23 #include "content/public/common/security_style.h"
24 #include "net/cert/cert_status_flags.h"
25 #include "third_party/WebKit/public/web/WebInputEvent.h"
27 #if defined(OS_CHROMEOS)
28 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h"
29 #include "chromeos/dbus/power_manager_client.h"
35 class DictionaryValue
;
40 struct NativeWebKeyboardEvent
;
48 // This is an automation provider containing testing calls.
49 class TestingAutomationProvider
: public AutomationProvider
,
50 public chrome::BrowserListObserver
,
51 #if defined(OS_CHROMEOS)
52 public chromeos::PowerManagerClient::Observer
,
54 public content::NotificationObserver
{
56 explicit TestingAutomationProvider(Profile
* profile
);
58 virtual IPC::Channel::Mode
GetChannelMode(bool use_named_interface
);
61 virtual bool OnMessageReceived(const IPC::Message
& msg
) OVERRIDE
;
62 virtual void OnChannelError() OVERRIDE
;
65 virtual ~TestingAutomationProvider();
67 // chrome::BrowserListObserver:
68 virtual void OnBrowserAdded(Browser
* browser
) OVERRIDE
;
69 virtual void OnBrowserRemoved(Browser
* browser
) OVERRIDE
;
71 // content::NotificationObserver:
72 virtual void Observe(int type
,
73 const content::NotificationSource
& source
,
74 const content::NotificationDetails
& details
) OVERRIDE
;
76 #if defined(OS_CHROMEOS)
77 // chromeos::PowerManagerClient::Observer:
78 virtual void PowerChanged(const power_manager::PowerSupplyProperties
& proto
);
81 // IPC Message callbacks.
82 void CloseBrowser(int handle
, IPC::Message
* reply_message
);
83 void ActivateTab(int handle
, int at_index
, int* status
);
84 void AppendTab(int handle
, const GURL
& url
, IPC::Message
* reply_message
);
85 void GetMachPortCount(int* port_count
);
86 void GetActiveTabIndex(int handle
, int* active_tab_index
);
87 void CloseTab(int tab_handle
, bool wait_until_closed
,
88 IPC::Message
* reply_message
);
89 void GetCookies(const GURL
& url
, int handle
, int* value_size
,
91 void NavigateToURLBlockUntilNavigationsComplete(int handle
, const GURL
& url
,
92 int number_of_navigations
,
93 IPC::Message
* reply_message
);
94 void NavigationAsync(int handle
, const GURL
& url
, bool* status
);
95 void Reload(int handle
, IPC::Message
* reply_message
);
96 void GetRedirectsFrom(int tab_handle
,
97 const GURL
& source_url
,
98 IPC::Message
* reply_message
);
99 void GetBrowserWindowCount(int* window_count
);
100 void GetNormalBrowserWindowCount(int* window_count
);
101 // Be aware that the browser window returned might be of non TYPE_TABBED
102 // or in incognito mode.
103 void GetBrowserWindow(int index
, int* handle
);
104 void ExecuteBrowserCommandAsync(int handle
, int command
, bool* success
);
105 void ExecuteBrowserCommand(int handle
, int command
,
106 IPC::Message
* reply_message
);
107 void TerminateSession(int handle
, bool* success
);
108 void WindowGetViewBounds(int handle
, int view_id
, bool screen_coordinates
,
109 bool* success
, gfx::Rect
* bounds
);
110 void SetWindowBounds(int handle
, const gfx::Rect
& bounds
, bool* result
);
111 void SetWindowVisible(int handle
, bool visible
, bool* result
);
112 void GetTabCount(int handle
, int* tab_count
);
113 void GetType(int handle
, int* type_as_int
);
114 void GetTab(int win_handle
, int tab_index
, int* tab_handle
);
115 void GetTabTitle(int handle
, int* title_string_size
, std::wstring
* title
);
116 void GetTabIndex(int handle
, int* tabstrip_index
);
117 void GetTabURL(int handle
, bool* success
, GURL
* url
);
118 void ExecuteJavascript(int handle
,
119 const std::wstring
& frame_xpath
,
120 const std::wstring
& script
,
121 IPC::Message
* reply_message
);
123 // If |show| is true, call Show() on the new window after creating it.
124 void OpenNewBrowserWindowOfType(int type
,
126 IPC::Message
* reply_message
);
128 // Retrieves a Browser from a Window and vice-versa.
129 void GetWindowForBrowser(int window_handle
, bool* success
, int* handle
);
131 // Gets the duration in ms of the last event matching |event_name|.
132 // |duration_ms| is -1 if the event hasn't occurred yet.
133 void GetMetricEventDuration(const std::string
& event_name
, int* duration_ms
);
135 // Brings the browser window to the front and activates it.
136 void BringBrowserToFront(int browser_handle
, bool* success
);
138 // Responds to requests to open the FindInPage window.
139 void HandleOpenFindInPageRequest(const IPC::Message
& message
,
142 // Get the visibility state of the Find window.
143 void GetFindWindowVisibility(int handle
, bool* visible
);
145 // Wait for the bookmark model to load.
146 void WaitForBookmarkModelToLoad(int handle
, IPC::Message
* reply_message
);
148 // Set |loaded| to true if the bookmark model has loaded, else false.
149 void BookmarkModelHasLoaded(int handle
, bool* loaded
);
151 // Get the visibility state of the Bookmark bar.
152 // Returns a status dictionary over the JSON interface.
153 void GetBookmarkBarStatus(base::DictionaryValue
* args
,
154 IPC::Message
* reply_message
);
156 // Get the bookmarks as a JSON string.
157 void GetBookmarksAsJSON(base::DictionaryValue
* args
,
158 IPC::Message
* reply_message
);
160 // Editing, modification, and removal of bookmarks through the JSON interface.
161 // Bookmarks are referenced by id.
162 void WaitForBookmarkModelToLoadJSON(base::DictionaryValue
* args
,
163 IPC::Message
* reply_message
);
164 void AddBookmark(base::DictionaryValue
* args
,
165 IPC::Message
* reply_message
);
166 void ReparentBookmark(base::DictionaryValue
* args
,
167 IPC::Message
* reply_message
);
168 void SetBookmarkTitle(base::DictionaryValue
* args
,
169 IPC::Message
* reply_message
);
170 void SetBookmarkURL(base::DictionaryValue
* args
,
171 IPC::Message
* reply_message
);
172 void RemoveBookmark(base::DictionaryValue
* args
,
173 IPC::Message
* reply_message
);
175 void WaitForBrowserWindowCountToBecome(int target_count
,
176 IPC::Message
* reply_message
);
178 void GoBackBlockUntilNavigationsComplete(int handle
,
179 int number_of_navigations
,
180 IPC::Message
* reply_message
);
182 void GoForwardBlockUntilNavigationsComplete(int handle
,
183 int number_of_navigations
,
184 IPC::Message
* reply_message
);
186 // Generic pattern for pyautolib
187 // Uses the JSON interface for input/output.
188 void SendJSONRequestWithBrowserHandle(int handle
,
189 const std::string
& json_request
,
190 IPC::Message
* reply_message
);
191 void SendJSONRequestWithBrowserIndex(int index
,
192 const std::string
& json_request
,
193 IPC::Message
* reply_message
);
194 void SendJSONRequest(Browser
* browser
,
195 const std::string
& json_request
,
196 IPC::Message
* reply_message
);
198 // Method ptr for json handlers.
199 // Uses the JSON interface for input/output.
200 typedef void (TestingAutomationProvider::*JsonHandler
)(base::DictionaryValue
*,
203 // Method ptr for json handlers that take a browser argument.
204 // Uses the JSON interface for input/output.
205 typedef void (TestingAutomationProvider::*BrowserJsonHandler
)(
207 base::DictionaryValue
*,
210 // JSON interface helper functions.
211 static scoped_ptr
<base::DictionaryValue
> ParseJSONRequestCommand(
212 const std::string
& json_request
,
213 std::string
* command
,
215 void BuildJSONHandlerMaps();
217 // Set window dimensions.
218 // Uses the JSON interface for input/output.
219 void SetWindowDimensions(Browser
* browser
,
220 base::DictionaryValue
* args
,
221 IPC::Message
* reply_message
);
223 // Get info about infobars in the given WebContents object.
224 // This includes info about the type of infobars, the message text,
226 // Caller owns the returned object.
227 base::ListValue
* GetInfobarsInfo(content::WebContents
* tc
);
229 // Perform actions on an infobar like dismiss, accept, cancel.
230 // This method can handle dismiss for all infobars. It can also handle
231 // accept / cancel (where it will assume the infobar is a confirm infobar) and
232 // allow / deny (where it will assume the infobar is a media stream infobar).
233 // For the media stream infobar, passing 'allow' will just select the first
234 // video and audio device available to the bar, or report an error if there
235 // are no devices available.
237 // Uses the JSON interface for input/output.
238 void PerformActionOnInfobar(Browser
* browser
,
239 base::DictionaryValue
* args
,
240 IPC::Message
* reply_message
);
242 // Create a new profile and open a new browser window with this profile. Uses
243 // the JSON interface for input/output.
244 void OpenNewBrowserWindowWithNewProfile(
245 base::DictionaryValue
* args
,
246 IPC::Message
* reply_message
);
248 // Open a new browser window.
249 // Uses the JSON interface for input/output.
250 void OpenNewBrowserWindow(base::DictionaryValue
* args
,
251 IPC::Message
* reply_message
);
252 // Close a browser window.
253 // Uses the JSON interface for input/output.
254 void CloseBrowserWindow(base::DictionaryValue
* args
,
255 IPC::Message
* reply_message
);
257 // Get info about multi-profile users.
258 // Uses the JSON interface for input/output.
259 void GetMultiProfileInfo(
260 base::DictionaryValue
* args
,
261 IPC::Message
* reply_message
);
262 // Open a new browser window for an existing profile.
263 // Uses the JSON interface for input/output.
264 void OpenProfileWindow(
265 base::DictionaryValue
* args
, IPC::Message
* reply_message
);
267 // Get info about the chromium/chrome in use.
268 // This includes things like version, executable name, executable path.
269 // Uses the JSON interface for input/output.
270 void GetBrowserInfo(base::DictionaryValue
* args
,
271 IPC::Message
* reply_message
);
273 // Get the browser window count. Uses the JSON interface.
274 void GetBrowserWindowCountJSON(base::DictionaryValue
* args
,
275 IPC::Message
* reply_message
);
277 // Get info about browser-related processes that currently exist.
278 void GetProcessInfo(base::DictionaryValue
* args
,
279 IPC::Message
* reply_message
);
281 // Get info about the state of navigation in a given tab.
282 // This includes ssl info.
283 // Uses the JSON interface for input/output.
284 void GetNavigationInfo(Browser
* browser
,
285 base::DictionaryValue
* args
,
286 IPC::Message
* reply_message
);
288 // Get info about downloads. This includes only ones that have been
289 // registered by the history system.
290 // Uses the JSON interface for input/output.
291 void GetDownloadsInfo(Browser
* browser
,
292 base::DictionaryValue
* args
,
293 IPC::Message
* reply_message
);
295 // Wait for all downloads to complete.
296 // Uses the JSON interface for input/output.
297 void WaitForAllDownloadsToComplete(Browser
* browser
,
298 base::DictionaryValue
* args
,
299 IPC::Message
* reply_message
);
301 // Performs the given action on the specified download.
302 // Uses the JSON interface for input/output.
303 void PerformActionOnDownload(Browser
* browser
,
304 base::DictionaryValue
* args
,
305 IPC::Message
* reply_message
);
307 // Get info about history.
308 // Uses the JSON interface for input/output.
309 void GetHistoryInfo(Browser
* browser
,
310 base::DictionaryValue
* args
,
311 IPC::Message
* reply_message
);
313 // Invoke loading of template url model.
314 // Uses the JSON interface for input/output.
315 void LoadSearchEngineInfo(Browser
* browser
,
316 base::DictionaryValue
* args
,
317 IPC::Message
* reply_message
);
319 // Sets the visibility of the download shelf. Uses the JSON interface.
321 // input: { "is_visible": true,
325 void SetDownloadShelfVisibleJSON(base::DictionaryValue
* args
,
326 IPC::Message
* reply_message
);
328 // Gets the visibility of the download shelf. Uses the JSON interface.
330 // input: { "windex": 1 }
331 // output: { "is_visible": true }
332 void IsDownloadShelfVisibleJSON(base::DictionaryValue
* args
,
333 IPC::Message
* reply_message
);
335 // Gets the download path of the given tab. Uses the JSON interface.
337 // input: { "tab_index": 1,
340 // output: { "path": "/home/foobar/Downloads" }
341 void GetDownloadDirectoryJSON(base::DictionaryValue
* args
,
342 IPC::Message
* reply_message
);
344 // Get search engines list.
345 // Assumes that the profile's template url model is loaded.
346 // Uses the JSON interface for input/output.
347 void GetSearchEngineInfo(Browser
* browser
,
348 base::DictionaryValue
* args
,
349 IPC::Message
* reply_message
);
351 // Add or edit search engine.
352 // Assumes that the profile's template url model is loaded.
353 // Uses the JSON interface for input/output.
354 void AddOrEditSearchEngine(Browser
* browser
,
355 base::DictionaryValue
* args
,
356 IPC::Message
* reply_message
);
358 // Perform a given action on an existing search engine.
359 // Assumes that the profile's template url model is loaded.
360 // Uses the JSON interface for input/output.
361 void PerformActionOnSearchEngine(Browser
* browser
,
362 base::DictionaryValue
* args
,
363 IPC::Message
* reply_message
);
365 // Get info about preferences stored in Local State.
366 // Uses the JSON interface for input/output.
367 void GetLocalStatePrefsInfo(base::DictionaryValue
* args
,
368 IPC::Message
* reply_message
);
370 // Set local state prefs.
371 // Uses the JSON interface for input/output.
372 void SetLocalStatePrefs(base::DictionaryValue
* args
,
373 IPC::Message
* reply_message
);
375 // Get info about preferences.
376 // Uses the JSON interface for input/output.
377 void GetPrefsInfo(base::DictionaryValue
* args
,
378 IPC::Message
* reply_message
);
381 // Uses the JSON interface for input/output.
382 void SetPrefs(base::DictionaryValue
* args
,
383 IPC::Message
* reply_message
);
385 // Return load times of initial tabs.
386 // Uses the JSON interface for input/output.
387 // Only includes tabs from command line arguments or session restore.
388 // See declaration of InitialLoadObserver in automation_provider_observers.h
389 // for example response.
390 void GetInitialLoadTimes(Browser
* browser
,
391 base::DictionaryValue
* args
,
392 IPC::Message
* reply_message
);
394 // Get info about plugins.
395 // Uses the JSON interface for input/output.
396 void GetPluginsInfo(Browser
* browser
,
397 base::DictionaryValue
* args
,
398 IPC::Message
* reply_message
);
399 void GetPluginsInfoCallback(Browser
* browser
,
400 base::DictionaryValue
* args
,
401 IPC::Message
* reply_message
,
402 const std::vector
<content::WebPluginInfo
>& plugins
);
405 // Uses the JSON interface for input/output.
406 void EnablePlugin(Browser
* browser
,
407 base::DictionaryValue
* args
,
408 IPC::Message
* reply_message
);
411 // Uses the JSON interface for input/output.
412 void DisablePlugin(Browser
* browser
,
413 base::DictionaryValue
* args
,
414 IPC::Message
* reply_message
);
416 // Get info about omnibox.
417 // Contains data about the matches (url, content, description)
418 // in the omnibox popup, the text in the omnibox.
419 // Uses the JSON interface for input/output.
420 void GetOmniboxInfo(Browser
* browser
,
421 base::DictionaryValue
* args
,
422 IPC::Message
* reply_message
);
424 // Set text in the omnibox. This sets focus to the omnibox.
425 // Uses the JSON interface for input/output.
426 void SetOmniboxText(Browser
* browser
,
427 base::DictionaryValue
* args
,
428 IPC::Message
* reply_message
);
430 // Move omnibox popup selection up or down.
431 // Uses the JSON interface for input/output.
432 void OmniboxMovePopupSelection(Browser
* browser
,
433 base::DictionaryValue
* args
,
434 IPC::Message
* reply_message
);
436 // Accept the current string of text in the omnibox.
437 // This is equivalent to clicking or hiting enter on a popup selection.
438 // Blocks until the page loads.
439 // Uses the JSON interface for input/output.
440 void OmniboxAcceptInput(Browser
* browser
,
441 base::DictionaryValue
* args
,
442 IPC::Message
* reply_message
);
444 // Save the contents of a tab into a file.
445 // Uses the JSON interface for input/output.
446 void SaveTabContents(Browser
* browser
,
447 base::DictionaryValue
* args
,
448 IPC::Message
* reply_message
);
450 // Add a new entry to the password store based on the password information
451 // provided. This method can also be used to add a blacklisted site (which
452 // will never fill in the password).
453 // Uses the JSON interface for input/output.
454 void AddSavedPassword(Browser
* browser
,
455 base::DictionaryValue
* args
,
456 IPC::Message
* reply_message
);
458 // Removes the password matching the information provided. This method can
459 // also be used to remove a blacklisted site.
460 // Uses the JSON interface for input/output.
461 void RemoveSavedPassword(Browser
* browser
,
462 base::DictionaryValue
* args
,
463 IPC::Message
* reply_message
);
465 // Return the saved username/password combinations.
466 // Uses the JSON interface for input/output.
467 void GetSavedPasswords(Browser
* browser
,
468 base::DictionaryValue
* args
,
469 IPC::Message
* reply_message
);
471 // Install the given unpacked/packed extension.
472 // Uses the JSON interface for input/output.
473 void InstallExtension(base::DictionaryValue
* args
,
474 IPC::Message
* reply_message
);
476 // Get info about all intalled extensions.
477 // Uses the JSON interface for input/output.
478 void GetExtensionsInfo(base::DictionaryValue
* args
,
479 IPC::Message
* reply_message
);
481 // Uninstalls the extension with the given id.
482 // Uses the JSON interface for input/output.
483 void UninstallExtensionById(base::DictionaryValue
* args
,
484 IPC::Message
* reply_message
);
486 // Set extension states:
487 // Enable/disable extension.
488 // Allow/disallow extension in incognito mode.
489 // Uses the JSON interface for input/output.
490 void SetExtensionStateById(base::DictionaryValue
* args
,
491 IPC::Message
* reply_message
);
493 // Trigger page action asynchronously in the active tab.
494 // Uses the JSON interface for input/output.
495 void TriggerPageActionById(base::DictionaryValue
* args
,
496 IPC::Message
* reply_message
);
498 // Trigger browser action asynchronously in the active tab.
499 // Uses the JSON interface for input/output.
500 void TriggerBrowserActionById(base::DictionaryValue
* args
,
501 IPC::Message
* reply_message
);
503 // Auto-updates installed extensions.
504 // Uses the JSON interface for input/output.
505 void UpdateExtensionsNow(base::DictionaryValue
* args
,
506 IPC::Message
* reply_message
);
508 // Overrides the current geoposition.
509 // Uses the JSON interface for input/output.
510 void OverrideGeoposition(base::DictionaryValue
* args
,
511 IPC::Message
* reply_message
);
513 // Responds to the Find request and returns the match count.
514 void FindInPage(Browser
* browser
,
515 base::DictionaryValue
* args
,
516 IPC::Message
* reply_message
);
518 // Opens the find request dialogue in the given browser.
520 // input: { "windex": 1 }
522 void OpenFindInPage(base::DictionaryValue
* args
,
523 IPC::Message
* reply_message
);
525 // Returns whether the find request dialogue is visible in the given browser.
527 // input: { "windex": 1 }
528 // output: { "is_visible": true }
529 void IsFindInPageVisible(base::DictionaryValue
* args
,
530 IPC::Message
* reply_message
);
532 // Get ordered list of all active and queued HTML5 notifications.
533 // Uses the JSON interface for input/output.
534 void GetAllNotifications(Browser
* browser
,
535 base::DictionaryValue
* args
,
536 IPC::Message
* reply_message
);
538 // Close an active HTML5 notification.
539 // Uses the JSON interface for input/output.
540 void CloseNotification(Browser
* browser
,
541 base::DictionaryValue
* args
,
542 IPC::Message
* reply_message
);
544 // Waits for the number of active HTML5 notifications to reach a given count.
545 // Uses the JSON interface for input/output.
546 void WaitForNotificationCount(Browser
* browser
,
547 base::DictionaryValue
* args
,
548 IPC::Message
* reply_message
);
550 // Gets info about the elements in the NTP.
551 // Uses the JSON interface for input/output.
552 void GetNTPInfo(Browser
* browser
,
553 base::DictionaryValue
* args
,
554 IPC::Message
* reply_message
);
556 // Removes a thumbnail from the NTP's Most Visited sites section.
557 // Uses the JSON interface for input/output.
558 void RemoveNTPMostVisitedThumbnail(Browser
* browser
,
559 base::DictionaryValue
* args
,
560 IPC::Message
* reply_message
);
562 // Restores all thumbnails that have been removed (i.e., blacklisted) from the
563 // NTP's Most Visited sites section.
564 // Uses the JSON interface for input/output.
565 void RestoreAllNTPMostVisitedThumbnails(Browser
* browser
,
566 base::DictionaryValue
* args
,
567 IPC::Message
* reply_message
);
569 // Kills the given renderer process and returns after the associated
570 // RenderProcessHost receives notification of its closing.
571 void KillRendererProcess(Browser
* browser
,
572 base::DictionaryValue
* args
,
573 IPC::Message
* reply_message
);
575 // Populates the fields of the event parameter with what is found in the
576 // args parameter. Upon failure, returns false and puts the error message in
577 // the error parameter, otherwise returns true.
578 bool BuildWebKeyEventFromArgs(base::DictionaryValue
* args
,
580 content::NativeWebKeyboardEvent
* event
);
582 // Launches the specified app from the currently-selected tab.
583 void LaunchApp(Browser
* browser
,
584 base::DictionaryValue
* args
,
585 IPC::Message
* reply_message
);
587 // Sets the launch type for the specified app.
588 void SetAppLaunchType(Browser
* browser
,
589 base::DictionaryValue
* args
,
590 IPC::Message
* reply_message
);
592 // Gets statistics about the v8 heap in a renderer process.
593 void GetV8HeapStats(Browser
* browser
,
594 base::DictionaryValue
* args
,
595 IPC::Message
* reply_message
);
597 // Gets the current FPS associated with a renderer process view.
598 void GetFPS(Browser
* browser
,
599 base::DictionaryValue
* args
,
600 IPC::Message
* reply_message
);
602 // Fullscreen and Mouse Lock hooks. They take no JSON parameters.
603 void IsFullscreenForBrowser(Browser
* browser
,
604 base::DictionaryValue
* args
,
605 IPC::Message
* reply_message
);
606 void IsFullscreenForTab(Browser
* browser
,
607 base::DictionaryValue
* args
,
608 IPC::Message
* reply_message
);
609 void IsMouseLocked(Browser
* browser
,
610 base::DictionaryValue
* args
,
611 IPC::Message
* reply_message
);
612 void IsMouseLockPermissionRequested(Browser
* browser
,
613 base::DictionaryValue
* args
,
614 IPC::Message
* reply_message
);
615 void IsFullscreenPermissionRequested(Browser
* browser
,
616 base::DictionaryValue
* args
,
617 IPC::Message
* reply_message
);
618 void IsFullscreenBubbleDisplayed(Browser
* browser
,
619 base::DictionaryValue
* args
,
620 IPC::Message
* reply_message
);
621 void IsFullscreenBubbleDisplayingButtons(Browser
* browser
,
622 base::DictionaryValue
* args
,
623 IPC::Message
* reply_message
);
624 void AcceptCurrentFullscreenOrMouseLockRequest(Browser
* browser
,
625 base::DictionaryValue
* args
,
626 IPC::Message
* reply_message
);
627 void DenyCurrentFullscreenOrMouseLockRequest(Browser
* browser
,
628 base::DictionaryValue
* args
,
629 IPC::Message
* reply_message
);
631 // Gets the browser and tab index of the given tab. Uses the JSON interface.
632 // Either "tab_id" or "tab_handle" must be specified, but not both. "tab_id"
633 // refers to the ID from the |NavigationController|, while "tab_handle" is
634 // the handle number assigned by the automation system.
636 // input: { "tab_id": 1, // optional
637 // "tab_handle": 3 // optional
639 // output: { "windex": 1, "tab_index": 5 }
640 void GetIndicesFromTab(base::DictionaryValue
* args
,
641 IPC::Message
* reply_message
);
643 // Executes a browser command on the given browser window. Does not wait for
644 // the command to complete.
646 // input: { "accelerator": 1,
649 void ExecuteBrowserCommandAsyncJSON(base::DictionaryValue
* args
,
650 IPC::Message
* reply_message
);
652 // Executes a browser command on the given browser window. Waits for the
653 // command to complete before returning.
655 // input: { "accelerator": 1,
658 void ExecuteBrowserCommandJSON(base::DictionaryValue
* args
,
659 IPC::Message
* reply_message
);
661 // Checks if a browser command is enabled on the given browser window.
663 // input: { "accelerator": 1,
666 // output: { "enabled": true }
667 void IsMenuCommandEnabledJSON(base::DictionaryValue
* args
,
668 IPC::Message
* reply_message
);
670 // Returns a dictionary of information about the given tab.
672 // input: { "tab_index": 1,
675 // output: { "title": "Hello World",
676 // "url": "http://foo.bar" }
677 void GetTabInfo(base::DictionaryValue
* args
,
678 IPC::Message
* reply_message
);
680 // Returns the tab count for the given browser window.
682 // input: { "windex": 1 }
683 // output: { "tab_count": 5 }
684 void GetTabCountJSON(base::DictionaryValue
* args
,
685 IPC::Message
* reply_message
);
687 // Navigates to the given URL. Uses the JSON interface.
688 // The pair |windex| and |tab_index| or the single |auto_id| must be given
689 // to specify the tab.
691 // input: { "windex": 1,
693 // "auto_id": { "type": 0, "id": "awoein" },
694 // "url": "http://www.google.com",
695 // "navigation_count": 1 // number of navigations to wait for
697 // output: { "result": AUTOMATION_MSG_NAVIGATION_SUCCESS }
698 void NavigateToURL(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
700 // Get the index of the currently active tab. Uses the JSON interface.
701 // The integer |windex| must be given to specify the browser window.
703 // input: { "windex": 1 }
704 // output: { "tab_index": 3 }
705 void GetActiveTabIndexJSON(base::DictionaryValue
* args
,
706 IPC::Message
* reply_message
);
708 // Append a new tab. Uses the JSON interface.
709 // The integer |windex| must be given to specify the browser window. The tab
710 // is opened to |url| and blocks until the page loads.
712 // input: { "windex": 1,
713 // "url": "http://google.com"
715 // output: { "result": AUTOMATION_MSG_NAVIGATION_SUCCESS }
716 void AppendTabJSON(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
718 // Waits until any pending navigation completes in the specified tab.
719 // The pair |windex| and |tab_index| or the single |auto_id| must be given
720 // to specify the tab.
722 // input: { "windex": 1,
724 // "auto_id": { "type": 0, "id": "awoein" },
726 // output: { "result": AUTOMATION_MSG_NAVIGATION_SUCCESS }
727 void WaitUntilNavigationCompletes(
728 base::DictionaryValue
* args
, IPC::Message
* reply_message
);
730 // Executes javascript in the specified frame. Uses the JSON interface.
731 // Waits for a result from the |DOMAutomationController|. The javascript
732 // must send a string.
733 // The pair |windex| and |tab_index| or the single |auto_id| must be given
734 // to specify the tab.
736 // input: { "windex": 1,
738 // "auto_id": { "type": 0, "id": "awoein" },
739 // "frame_xpath": "//frames[1]",
741 // "window.domAutomationController.send(window.name)",
743 // output: { "result": "My Window Name" }
744 // This and some following methods have a suffix of JSON to distingush them
745 // from already existing methods which perform the same function, but use
746 // custom IPC messages instead of the JSON IPC message. These functions will
747 // eventually be replaced with the JSON ones and the JSON suffix will be
749 // TODO(kkania): Replace the non-JSON counterparts and drop the JSON suffix.
750 void ExecuteJavascriptJSON(
751 base::DictionaryValue
* args
, IPC::Message
* reply_message
);
753 // Creates a DomEventObserver associated with the AutomationEventQueue.
755 // input: { "event_name": "login complete",
756 // "automation_id": 4444,
757 // "recurring": False
759 // output: { "observer_id": 1 }
760 void AddDomEventObserver(
761 base::DictionaryValue
* args
, IPC::Message
* reply_message
);
763 // Removes an event observer associated with the AutomationEventQueue.
765 // input: { "observer_id": 1 }
767 void RemoveEventObserver(
768 base::DictionaryValue
* args
, IPC::Message
* reply_message
);
770 // Retrieves an event from the AutomationEventQueue.
771 // Blocks if 'blocking' is true, otherwise returns immediately.
773 // input: { "observer_id": 1,
776 // output: { "type": "raised",
777 // "name": "login complete"
780 void GetNextEvent(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
782 // Removes all events and observers attached to the AutomationEventQueue.
786 void ClearEventQueue(
787 base::DictionaryValue
* args
, IPC::Message
* reply_message
);
789 // Executes javascript in the specified frame of a render view.
790 // Uses the JSON interface. Waits for a result from the
791 // |DOMAutomationController|. The javascript must send a string.
793 // input: { "view": {
794 // "render_process_id": 1,
795 // "render_view_id": 2,
797 // "frame_xpath": "//frames[1]",
799 // "window.domAutomationController.send(window.name)",
801 // output: { "result": "My Window Name" }
802 void ExecuteJavascriptInRenderView(
803 base::DictionaryValue
* args
, IPC::Message
* reply_message
);
805 // Goes forward in the specified tab. Uses the JSON interface.
806 // The pair |windex| and |tab_index| or the single |auto_id| must be given
807 // to specify the tab.
809 // input: { "windex": 1,
811 // "auto_id": { "type": 0, "id": "awoein" }
813 // output: { "did_go_forward": true, // optional
814 // "result": AUTOMATION_MSG_NAVIGATION_SUCCESS // optional
816 void GoForward(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
818 // Goes back in the specified tab. Uses the JSON interface.
819 // The pair |windex| and |tab_index| or the single |auto_id| must be given
820 // to specify the tab.
822 // input: { "windex": 1,
824 // "auto_id": { "type": 0, "id": "awoein" }
826 // output: { "did_go_back": true, // optional
827 // "result": AUTOMATION_MSG_NAVIGATION_SUCCESS // optional
829 void GoBack(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
831 // Reload the specified tab. Uses the JSON interface.
832 // The pair |windex| and |tab_index| or the single |auto_id| must be given
833 // to specify the tab.
835 // input: { "windex": 1,
837 // "auto_id": { "type": 0, "id": "awoein" }
839 // output: { "result": AUTOMATION_MSG_NAVIGATION_SUCCESS // optional }
840 void ReloadJSON(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
842 // Gets the cookies for the given URL. Uses the JSON interface.
843 // "expiry" refers to the amount of seconds since the Unix epoch. If omitted,
844 // the cookie is valid for the duration of the browser session.
846 // input: { "url": "http://www.google.com" }
847 // output: { "cookies": [
850 // "value": "123101",
852 // "domain": "www.google.com",
854 // "expiry": 1401982012
858 void GetCookiesJSON(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
860 // Deletes the cookie with the given name for the URL. Uses the JSON
864 // "url": "http://www.google.com",
865 // "name": "my_cookie"
868 void DeleteCookieJSON(base::DictionaryValue
* args
,
869 IPC::Message
* reply_message
);
871 // Sets a cookie for the given URL. Uses the JSON interface.
872 // "expiry" refers to the amount of seconds since the Unix epoch. If omitted,
873 // the cookie will be valid for the duration of the browser session.
874 // "domain" refers to the applicable domain for the cookie. Valid domain
875 // choices for the site "http://www.google.com" and resulting cookie
877 // [.]www.google.com - applicable on www.google.com and its subdomains
878 // [.]google.com - applicable on google.com and its subdomains
879 // <none> - applicable only on www.google.com
882 // input: { "url": "http://www.google.com",
885 // "value": "123101",
886 // "path": "/", // optional
887 // "domain": ".www.google.com", // optional
888 // "secure": false, // optional
889 // "expiry": 1401982012 // optional
893 void SetCookieJSON(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
895 // Gets the cookies for the given URL in the context of a given browser
896 // window. Uses the JSON interface.
898 // input: { "url": "http://www.google.com",
902 // output: { "cookies": "foo=bar" }
903 void GetCookiesInBrowserContext(base::DictionaryValue
* args
,
904 IPC::Message
* reply_message
);
906 // Deletes the cookie with the given name for the URL in the context of a
907 // given browser window. Uses the JSON interface.
909 // input: { "url": "http://www.google.com",
910 // "cookie_name": "my_cookie"
915 void DeleteCookieInBrowserContext(base::DictionaryValue
* args
,
916 IPC::Message
* reply_message
);
918 // Sets a cookie for the given URL in the context of a given browser window.
919 // Uses the JSON interface.
922 // input: { "url": "http://www.google.com",
923 // "value": "name=value; Expires=Wed, 09 Jun 2021 10:18:14 GMT",
928 void SetCookieInBrowserContext(base::DictionaryValue
* args
,
929 IPC::Message
* reply_message
);
931 // Gets the ID for every open tab. This ID is unique per session.
934 // output: { "ids": [213, 1] }
935 void GetTabIds(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
937 // Checks if the given tab ID refers to an open tab.
939 // input: { "id": 41 }
940 // output: { "is_valid": false }
941 void IsTabIdValid(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
943 // Closes the specified tab.
944 // The pair |windex| and |tab_index| or the single |auto_id| must be given
945 // to specify the tab.
947 // input: { "windex": 1,
949 // "auto_id": { "type": 0, "id": "awoein" }
952 void CloseTabJSON(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
954 // Sets the specified web view bounds.
955 // The single |auto_id| must be given to specify the view.
956 // This method currently is only supported for tabs.
958 // input: { "auto_id": { "type": 0, "id": "awoein" },
967 void SetViewBounds(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
969 // Maximizes the web view.
970 // The single |auto_id| must be given to specify the view.
971 // This method currently is only supported for tabs.
973 // input: { "auto_id": { "type": 0, "id": "awoein" } }
975 void MaximizeView(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
977 // Sends the WebKit events for a mouse click at a given coordinate.
978 // The pair |windex| and |tab_index| or the single |auto_id| must be given
979 // to specify the render view.
981 // input: { "windex": 1,
983 // "auto_id": { "type": 0, "id": "awoein" },
984 // "button": automation::kLeftButton,
989 void WebkitMouseClick(base::DictionaryValue
* args
,
990 IPC::Message
* message
);
992 // Sends the WebKit event for a mouse move to a given coordinate.
993 // The pair |windex| and |tab_index| or the single |auto_id| must be given
994 // to specify the render view.
996 // input: { "windex": 1,
998 // "auto_id": { "type": 0, "id": "awoein" },
1003 void WebkitMouseMove(base::DictionaryValue
* args
,
1004 IPC::Message
* message
);
1006 // Sends the WebKit events for a mouse drag between two coordinates.
1007 // The pair |windex| and |tab_index| or the single |auto_id| must be given
1008 // to specify the render view.
1010 // input: { "windex": 1,
1012 // "auto_id": { "type": 0, "id": "awoein" },
1019 void WebkitMouseDrag(base::DictionaryValue
* args
,
1020 IPC::Message
* message
);
1022 // Sends the WebKit events for a mouse button down at a given coordinate.
1023 // The pair |windex| and |tab_index| or the single |auto_id| must be given
1024 // to specify the render view.
1026 // input: { "windex": 1,
1028 // "auto_id": { "type": 0, "id": "awoein" },
1033 void WebkitMouseButtonDown(base::DictionaryValue
* args
,
1034 IPC::Message
* message
);
1036 // Sends the WebKit events for a mouse button up at a given coordinate.
1037 // The pair |windex| and |tab_index| or the single |auto_id| must be given
1038 // to specify the render view.
1040 // input: { "windex": 1,
1042 // "auto_id": { "type": 0, "id": "awoein" },
1047 void WebkitMouseButtonUp(base::DictionaryValue
* args
,
1048 IPC::Message
* message
);
1050 // Sends the WebKit events for a mouse double click at a given coordinate.
1051 // The pair |windex| and |tab_index| or the single |auto_id| must be given
1052 // to specify the render view.
1054 // input: { "windex": 1,
1056 // "auto_id": { "type": 0, "id": "awoein" },
1061 void WebkitMouseDoubleClick(base::DictionaryValue
* args
,
1062 IPC::Message
* message
);
1064 // Drag and drop file paths at a given coordinate.
1065 // The pair |windex| and |tab_index| or the single |auto_id| must be given
1066 // to specify the render view.
1068 // input: { "windex": 1,
1070 // "auto_id": { "type": 0, "id": "awoein" },
1078 void DragAndDropFilePaths(base::DictionaryValue
* args
,
1079 IPC::Message
* message
);
1081 // Sends the WebKit key event with the specified properties.
1082 // The pair |windex| and |tab_index| or the single |auto_id| must be given
1083 // to specify the render view.
1085 // input: { "windex": 1,
1087 // "auto_id": { "type": 0, "id": "awoein" },
1088 // "type": automation::kRawKeyDownType,
1089 // "nativeKeyCode": ui::VKEY_X,
1090 // "windowsKeyCode": ui::VKEY_X,
1091 // "unmodifiedText": "x",
1093 // "modifiers": automation::kShiftKeyMask,
1094 // "isSystemKey": false
1097 void SendWebkitKeyEvent(base::DictionaryValue
* args
,
1098 IPC::Message
* message
);
1100 // Gets the active JavaScript modal dialog's message.
1103 // output: { "message": "This is an alert!" }
1104 void GetAppModalDialogMessage(
1105 base::DictionaryValue
* args
, IPC::Message
* reply_message
);
1107 // Accepts or dismisses the active JavaScript modal dialog. If optional
1108 // prompt text is given, it will be used as the result of the prompt dialog.
1110 // input: { "accept": true,
1111 // "prompt_text": "hello" // optional
1114 void AcceptOrDismissAppModalDialog(
1115 base::DictionaryValue
* args
, IPC::Message
* reply_message
);
1117 // Activates the given tab.
1118 // The pair |windex| and |tab_index| or the single |auto_id| must be given
1119 // to specify the tab.
1121 // input: { "windex": 1,
1123 // "auto_id": { "type": 0, "id": "awoein" }
1126 void ActivateTabJSON(base::DictionaryValue
* args
, IPC::Message
* message
);
1128 // Blocks until the given tab is restored.
1129 // Uses the JSON interface.
1130 void WaitForTabToBeRestored(base::DictionaryValue
* args
,
1131 IPC::Message
* reply_message
);
1133 // Simulates an action on the SSL blocking page at the specified tab.
1134 // If |proceed| is true, it is equivalent to the user pressing the
1135 // 'Proceed' button, if false the 'Get me out of there button'.
1136 // Note that this fails if the tab is not displaying a SSL blocking page.
1137 // Uses the JSON interface.
1139 // input: { "windex": 1,
1144 void ActionOnSSLBlockingPage(base::DictionaryValue
* args
,
1145 IPC::Message
* reply_message
);
1147 // Gets the security state for the given tab. Uses the JSON interface.
1149 // input: { "windex": 1,
1152 // output: { "security_style": SECURITY_STYLE_AUTHENTICATED,
1153 // "ssl_cert_status": 3, // bitmask of status flags
1154 // "insecure_content_status": 1, // bitmask of ContentStatusFlags
1156 void GetSecurityState(base::DictionaryValue
* args
,
1157 IPC::Message
* reply_message
);
1159 // Brings the given brower's window to the front.
1161 // input: { "windex": 1 }
1163 void BringBrowserToFrontJSON(base::DictionaryValue
* args
,
1164 IPC::Message
* message
);
1166 // Determines whether the extension page action is visible in the given tab.
1168 // input: { "auto_id": { "type": 0, "id": "awoein" },
1169 // "extension_id": "byzaaoiea",
1172 void IsPageActionVisible(base::DictionaryValue
* args
,
1173 IPC::Message
* reply_message
);
1175 // Creates a new |TestingAutomationProvider| that opens a server channel
1176 // for the given |channel_id|.
1177 // The server channel will be available for connection when this returns.
1179 // input: { "channel_id": "testChannel123" }
1180 void CreateNewAutomationProvider(base::DictionaryValue
* args
,
1181 IPC::Message
* reply_message
);
1183 // Triggers a policy update on the platform and cloud providers, if they
1184 // exist. Returns after the update notifications are received.
1188 void RefreshPolicies(base::DictionaryValue
* args
,
1189 IPC::Message
* reply_message
);
1191 // Simulates a memory bug (reference an array out of bounds) to cause Address
1192 // Sanitizer (if it was built it) to catch the bug and abort the process.
1196 void SimulateAsanMemoryBug(base::DictionaryValue
* args
,
1197 IPC::Message
* reply_message
);
1199 #if defined(OS_CHROMEOS)
1202 // Accepts the network screen and continues to EULA.
1205 // ouput: { "next_screen": "eula" }
1206 void AcceptOOBENetworkScreen(base::DictionaryValue
* args
,
1207 IPC::Message
* reply_message
);
1209 // Accepts or declines EULA, moving forward or back from EULA screen.
1211 // input: { "accepted": true, "usage_stats_reporting": false }
1212 // output: { "next_screen": "update" }
1213 void AcceptOOBEEula(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
1215 // Forces the ongoing update to cancel and proceed to the login screen.
1218 // output: { "next_screen": "login" }
1219 void CancelOOBEUpdate(base::DictionaryValue
* args
,
1220 IPC::Message
* reply_message
);
1222 // Chooses user image on the image picker screen and starts browser session.
1224 // input: { "image": "profile" } - Google profile image
1225 // input: { "image": 2 } - default image number 2 (0-based)
1226 // output: { "next_screen": "session" }
1227 void PickUserImage(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
1229 // Skips OOBE to login step. Can be called when already at login screen,
1230 // in which case does nothing and sends return value immediately.
1232 // input: { "skip_image_selection": true }
1233 // output: { "next_screen": "login" }
1234 void SkipToLogin(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
1236 // Returns info about the current OOBE screen.
1239 // output: { "screen_name": "network" }
1240 // output: none (when already logged in)
1241 void GetOOBEScreenInfo(base::DictionaryValue
* args
,
1242 IPC::Message
* reply_message
);
1245 void GetLoginInfo(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
1247 void ShowCreateAccountUI(base::DictionaryValue
* args
,
1248 IPC::Message
* reply_message
);
1250 void LoginAsGuest(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
1252 // Submits the Chrome OS login form. Watch for the login to complete using
1253 // the AddLoginObserver and GetNextEvent commands.
1255 // input: { "username": "user@gmail.com",
1256 // "password": "fakepassword",
1258 void SubmitLoginForm(base::DictionaryValue
* args
,
1259 IPC::Message
* reply_message
);
1261 void AddLoginEventObserver(base::DictionaryValue
* args
,
1262 IPC::Message
* reply_message
);
1264 // Executes javascript in the specified frame in the OOBE WebUI on chromeos.
1265 // Waits for a result from the |DOMAutomationController|. The javascript must
1266 // send a string. Must be run before a user has logged in.
1268 // input: { "frame_xpath": "//frames[1]",
1270 // "window.domAutomationController.send(window.name)",
1272 // output: { "result": "My Window Name" }
1273 void ExecuteJavascriptInOOBEWebUI(
1274 base::DictionaryValue
* args
, IPC::Message
* reply_message
);
1276 void SignOut(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
1279 void LockScreen(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
1281 void UnlockScreen(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
1283 void SignoutInScreenLocker(base::DictionaryValue
* args
,
1284 IPC::Message
* reply_message
);
1287 void GetBatteryInfo(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
1290 void EnableSpokenFeedback(base::DictionaryValue
* args
,
1291 IPC::Message
* reply_message
);
1293 void IsSpokenFeedbackEnabled(base::DictionaryValue
* args
,
1294 IPC::Message
* reply_message
);
1297 void GetTimeInfo(Browser
* browser
, base::DictionaryValue
* args
,
1298 IPC::Message
* reply_message
);
1300 void GetTimeInfo(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
1302 void SetTimezone(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
1304 void UpdateCheck(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
1307 void GetVolumeInfo(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
1309 void SetVolume(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
1311 void SetMute(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
1313 void CaptureProfilePhoto(Browser
* browser
,
1314 base::DictionaryValue
* args
,
1315 IPC::Message
* reply_message
);
1318 void OpenCrosh(base::DictionaryValue
* args
, IPC::Message
* reply_message
);
1320 void AddChromeosObservers();
1321 void RemoveChromeosObservers();
1323 #endif // defined(OS_CHROMEOS)
1325 void WaitForTabCountToBecome(int browser_handle
,
1326 int target_tab_count
,
1327 IPC::Message
* reply_message
);
1329 void WaitForInfoBarCount(int tab_handle
,
1330 size_t target_count
,
1331 IPC::Message
* reply_message
);
1333 void WaitForProcessLauncherThreadToGoIdle(IPC::Message
* reply_message
);
1335 void OnRemoveProvider(); // Called via PostTask
1337 // Execute Javascript in the context of a specific render view.
1338 void ExecuteJavascriptInRenderViewFrame(
1339 const base::string16
& frame_xpath
, const base::string16
& script
,
1340 IPC::Message
* reply_message
, content::RenderViewHost
* render_view_host
);
1342 // Selects the given |tab| if not selected already.
1343 void EnsureTabSelected(Browser
* browser
, content::WebContents
* tab
);
1345 #if defined(OS_CHROMEOS)
1346 power_manager::PowerSupplyProperties power_supply_properties_
;
1347 #endif // defined(OS_CHROMEOS)
1349 std::map
<std::string
, JsonHandler
> handler_map_
;
1350 std::map
<std::string
, BrowserJsonHandler
> browser_handler_map_
;
1352 content::NotificationRegistrar registrar_
;
1354 // The automation event observer queue. It is lazily created when an observer
1355 // is added to avoid overhead when not needed.
1356 scoped_ptr
<AutomationEventQueue
> automation_event_queue_
;
1358 // List of commands which just finish synchronously and don't require
1359 // setting up an observer.
1360 static const int kSynchronousCommands
[];
1362 DISALLOW_COPY_AND_ASSIGN(TestingAutomationProvider
);
1365 #endif // CHROME_BROWSER_AUTOMATION_TESTING_AUTOMATION_PROVIDER_H_