Home | History | Annotate | Download | only in automation
      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.
      4 
      5 #ifndef CHROME_BROWSER_AUTOMATION_TESTING_AUTOMATION_PROVIDER_H_
      6 #define CHROME_BROWSER_AUTOMATION_TESTING_AUTOMATION_PROVIDER_H_
      7 
      8 #include <map>
      9 #include <string>
     10 #include <vector>
     11 
     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"
     26 
     27 #if defined(OS_CHROMEOS)
     28 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h"
     29 #include "chromeos/dbus/power_manager_client.h"
     30 #endif
     31 
     32 class CreditCard;
     33 
     34 namespace base {
     35 class DictionaryValue;
     36 }
     37 
     38 namespace content {
     39 class RenderViewHost;
     40 struct NativeWebKeyboardEvent;
     41 struct WebPluginInfo;
     42 }
     43 
     44 namespace gfx {
     45 class Rect;
     46 }
     47 
     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,
     53 #endif
     54                                   public content::NotificationObserver {
     55  public:
     56   explicit TestingAutomationProvider(Profile* profile);
     57 
     58   virtual IPC::Channel::Mode GetChannelMode(bool use_named_interface);
     59 
     60   // IPC::Listener:
     61   virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
     62   virtual void OnChannelError() OVERRIDE;
     63 
     64  private:
     65   virtual ~TestingAutomationProvider();
     66 
     67   // chrome::BrowserListObserver:
     68   virtual void OnBrowserAdded(Browser* browser) OVERRIDE;
     69   virtual void OnBrowserRemoved(Browser* browser) OVERRIDE;
     70 
     71   // content::NotificationObserver:
     72   virtual void Observe(int type,
     73                        const content::NotificationSource& source,
     74                        const content::NotificationDetails& details) OVERRIDE;
     75 
     76 #if defined(OS_CHROMEOS)
     77   // chromeos::PowerManagerClient::Observer:
     78   virtual void PowerChanged(const power_manager::PowerSupplyProperties& proto);
     79 #endif
     80 
     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,
     90                   std::string* value);
     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);
    122 
    123   // If |show| is true, call Show() on the new window after creating it.
    124   void OpenNewBrowserWindowOfType(int type,
    125                                   bool show,
    126                                   IPC::Message* reply_message);
    127 
    128   // Retrieves a Browser from a Window and vice-versa.
    129   void GetWindowForBrowser(int window_handle, bool* success, int* handle);
    130 
    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);
    134 
    135   // Brings the browser window to the front and activates it.
    136   void BringBrowserToFront(int browser_handle, bool* success);
    137 
    138   // Responds to requests to open the FindInPage window.
    139   void HandleOpenFindInPageRequest(const IPC::Message& message,
    140                                    int handle);
    141 
    142   // Get the visibility state of the Find window.
    143   void GetFindWindowVisibility(int handle, bool* visible);
    144 
    145   // Wait for the bookmark model to load.
    146   void WaitForBookmarkModelToLoad(int handle, IPC::Message* reply_message);
    147 
    148   // Set |loaded| to true if the bookmark model has loaded, else false.
    149   void BookmarkModelHasLoaded(int handle, bool* loaded);
    150 
    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);
    155 
    156   // Get the bookmarks as a JSON string.
    157   void GetBookmarksAsJSON(base::DictionaryValue* args,
    158                           IPC::Message* reply_message);
    159 
    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);
    174 
    175   void WaitForBrowserWindowCountToBecome(int target_count,
    176                                          IPC::Message* reply_message);
    177 
    178   void GoBackBlockUntilNavigationsComplete(int handle,
    179                                            int number_of_navigations,
    180                                            IPC::Message* reply_message);
    181 
    182   void GoForwardBlockUntilNavigationsComplete(int handle,
    183                                               int number_of_navigations,
    184                                               IPC::Message* reply_message);
    185 
    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);
    197 
    198   // Method ptr for json handlers.
    199   // Uses the JSON interface for input/output.
    200   typedef void (TestingAutomationProvider::*JsonHandler)(base::DictionaryValue*,
    201                                                          IPC::Message*);
    202 
    203   // Method ptr for json handlers that take a browser argument.
    204   // Uses the JSON interface for input/output.
    205   typedef void (TestingAutomationProvider::*BrowserJsonHandler)(
    206       Browser* browser,
    207       base::DictionaryValue*,
    208       IPC::Message*);
    209 
    210   // JSON interface helper functions.
    211   static scoped_ptr<DictionaryValue> ParseJSONRequestCommand(
    212       const std::string& json_request,
    213       std::string* command,
    214       std::string* error);
    215   void BuildJSONHandlerMaps();
    216 
    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);
    222 
    223   // Get info about infobars in the given WebContents object.
    224   // This includes info about the type of infobars, the message text,
    225   // buttons, etc.
    226   // Caller owns the returned object.
    227   ListValue* GetInfobarsInfo(content::WebContents* tc);
    228 
    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.
    236   //
    237   // Uses the JSON interface for input/output.
    238   void PerformActionOnInfobar(Browser* browser,
    239                               base::DictionaryValue* args,
    240                               IPC::Message* reply_message);
    241 
    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);
    247 
    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);
    256 
    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);
    266 
    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);
    272 
    273   // Get the browser window count. Uses the JSON interface.
    274   void GetBrowserWindowCountJSON(base::DictionaryValue* args,
    275                                  IPC::Message* reply_message);
    276 
    277   // Get info about browser-related processes that currently exist.
    278   void GetProcessInfo(base::DictionaryValue* args,
    279                       IPC::Message* reply_message);
    280 
    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);
    287 
    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);
    294 
    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);
    300 
    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);
    306 
    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);
    312 
    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);
    318 
    319   // Sets the visibility of the download shelf. Uses the JSON interface.
    320   // Example:
    321   //   input: { "is_visible": true,
    322   //            "windex": 1,
    323   //          }
    324   //   output: none
    325   void SetDownloadShelfVisibleJSON(base::DictionaryValue* args,
    326                                    IPC::Message* reply_message);
    327 
    328   // Gets the visibility of the download shelf. Uses the JSON interface.
    329   // Example:
    330   //   input: { "windex": 1 }
    331   //   output: { "is_visible": true }
    332   void IsDownloadShelfVisibleJSON(base::DictionaryValue* args,
    333                                   IPC::Message* reply_message);
    334 
    335   // Gets the download path of the given tab. Uses the JSON interface.
    336   // Example:
    337   //   input: { "tab_index": 1,
    338   //            "windex": 1,
    339   //          }
    340   //   output: { "path": "/home/foobar/Downloads" }
    341   void GetDownloadDirectoryJSON(base::DictionaryValue* args,
    342                                 IPC::Message* reply_message);
    343 
    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);
    350 
    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);
    357 
    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);
    364 
    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);
    369 
    370   // Set local state prefs.
    371   // Uses the JSON interface for input/output.
    372   void SetLocalStatePrefs(base::DictionaryValue* args,
    373                           IPC::Message* reply_message);
    374 
    375   // Get info about preferences.
    376   // Uses the JSON interface for input/output.
    377   void GetPrefsInfo(base::DictionaryValue* args,
    378                     IPC::Message* reply_message);
    379 
    380   // Set prefs.
    381   // Uses the JSON interface for input/output.
    382   void SetPrefs(base::DictionaryValue* args,
    383                 IPC::Message* reply_message);
    384 
    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);
    393 
    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);
    403 
    404   // Enable a plugin.
    405   // Uses the JSON interface for input/output.
    406   void EnablePlugin(Browser* browser,
    407                     base::DictionaryValue* args,
    408                     IPC::Message* reply_message);
    409 
    410   // Disable a plugin.
    411   // Uses the JSON interface for input/output.
    412   void DisablePlugin(Browser* browser,
    413                      base::DictionaryValue* args,
    414                      IPC::Message* reply_message);
    415 
    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);
    423 
    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);
    429 
    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);
    435 
    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);
    443 
    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);
    449 
    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);
    457 
    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);
    464 
    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);
    470 
    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);
    475 
    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);
    480 
    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);
    485 
    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);
    492 
    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);
    497 
    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);
    502 
    503   // Auto-updates installed extensions.
    504   // Uses the JSON interface for input/output.
    505   void UpdateExtensionsNow(base::DictionaryValue* args,
    506                            IPC::Message* reply_message);
    507 
    508   // Overrides the current geoposition.
    509   // Uses the JSON interface for input/output.
    510   void OverrideGeoposition(base::DictionaryValue* args,
    511                            IPC::Message* reply_message);
    512 
    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);
    517 
    518   // Opens the find request dialogue in the given browser.
    519   // Example:
    520   //   input: { "windex": 1 }
    521   //   output: none
    522   void OpenFindInPage(base::DictionaryValue* args,
    523                       IPC::Message* reply_message);
    524 
    525   // Returns whether the find request dialogue is visible in the given browser.
    526   // Example:
    527   //   input: { "windex": 1 }
    528   //   output: { "is_visible": true }
    529   void IsFindInPageVisible(base::DictionaryValue* args,
    530                            IPC::Message* reply_message);
    531 
    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);
    537 
    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);
    543 
    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);
    549 
    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);
    555 
    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);
    561 
    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);
    568 
    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);
    574 
    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,
    579                                 std::string* error,
    580                                 content::NativeWebKeyboardEvent* event);
    581 
    582   // Launches the specified app from the currently-selected tab.
    583   void LaunchApp(Browser* browser,
    584                  base::DictionaryValue* args,
    585                  IPC::Message* reply_message);
    586 
    587   // Sets the launch type for the specified app.
    588   void SetAppLaunchType(Browser* browser,
    589                         base::DictionaryValue* args,
    590                         IPC::Message* reply_message);
    591 
    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);
    596 
    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);
    601 
    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);
    630 
    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.
    635   // Example:
    636   //   input: { "tab_id": 1,     // optional
    637   //            "tab_handle": 3  // optional
    638   //          }
    639   //   output: { "windex": 1, "tab_index": 5 }
    640   void GetIndicesFromTab(base::DictionaryValue* args,
    641                          IPC::Message* reply_message);
    642 
    643   // Executes a browser command on the given browser window. Does not wait for
    644   // the command to complete.
    645   // Example:
    646   //   input: { "accelerator": 1,
    647   //            "windex": 1
    648   //          }
    649   void ExecuteBrowserCommandAsyncJSON(DictionaryValue* args,
    650                                       IPC::Message* reply_message);
    651 
    652   // Executes a browser command on the given browser window. Waits for the
    653   // command to complete before returning.
    654   // Example:
    655   //   input: { "accelerator": 1,
    656   //            "windex": 1
    657   //          }
    658   void ExecuteBrowserCommandJSON(DictionaryValue* args,
    659                                  IPC::Message* reply_message);
    660 
    661   // Checks if a browser command is enabled on the given browser window.
    662   // Example:
    663   //   input: { "accelerator": 1,
    664   //            "windex": 1
    665   //          }
    666   //   output: { "enabled": true }
    667   void IsMenuCommandEnabledJSON(DictionaryValue* args,
    668                                 IPC::Message* reply_message);
    669 
    670   // Returns a dictionary of information about the given tab.
    671   // Example:
    672   //   input: { "tab_index": 1,
    673   //            "windex": 1
    674   //          }
    675   //   output: { "title": "Hello World",
    676   //             "url": "http://foo.bar" }
    677   void GetTabInfo(DictionaryValue* args,
    678                   IPC::Message* reply_message);
    679 
    680   // Returns the tab count for the given browser window.
    681   // Example:
    682   //   input: { "windex": 1 }
    683   //   output: { "tab_count": 5 }
    684   void GetTabCountJSON(DictionaryValue* args,
    685                        IPC::Message* reply_message);
    686 
    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.
    690   // Example:
    691   //   input: { "windex": 1,
    692   //            "tab_index": 3,
    693   //            "auto_id": { "type": 0, "id": "awoein" },
    694   //            "url": "http://www.google.com",
    695   //            "navigation_count": 1  // number of navigations to wait for
    696   //          }
    697   //   output: { "result": AUTOMATION_MSG_NAVIGATION_SUCCESS }
    698   void NavigateToURL(base::DictionaryValue* args, IPC::Message* reply_message);
    699 
    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.
    702   // Example:
    703   //   input: { "windex": 1 }
    704   //   output: { "tab_index": 3 }
    705   void GetActiveTabIndexJSON(DictionaryValue* args,
    706                              IPC::Message* reply_message);
    707 
    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.
    711   // Example:
    712   //   input: { "windex": 1,
    713   //            "url": "http://google.com"
    714   //          }
    715   //   output: { "result": AUTOMATION_MSG_NAVIGATION_SUCCESS }
    716   void AppendTabJSON(DictionaryValue* args, IPC::Message* reply_message);
    717 
    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.
    721   // Example:
    722   //   input: { "windex": 1,
    723   //            "tab_index": 1,
    724   //            "auto_id": { "type": 0, "id": "awoein" },
    725   //           }
    726   //   output: { "result": AUTOMATION_MSG_NAVIGATION_SUCCESS }
    727   void WaitUntilNavigationCompletes(
    728       base::DictionaryValue* args, IPC::Message* reply_message);
    729 
    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.
    735   // Example:
    736   //   input: { "windex": 1,
    737   //            "tab_index": 1,
    738   //            "auto_id": { "type": 0, "id": "awoein" },
    739   //            "frame_xpath": "//frames[1]",
    740   //            "javascript":
    741   //                "window.domAutomationController.send(window.name)",
    742   //           }
    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
    748   // dropped.
    749   // TODO(kkania): Replace the non-JSON counterparts and drop the JSON suffix.
    750   void ExecuteJavascriptJSON(
    751       base::DictionaryValue* args, IPC::Message* reply_message);
    752 
    753   // Creates a DomEventObserver associated with the AutomationEventQueue.
    754   // Example:
    755   //   input: { "event_name": "login complete",
    756   //            "automation_id": 4444,
    757   //            "recurring": False
    758   //          }
    759   //   output: { "observer_id": 1 }
    760   void AddDomEventObserver(
    761       base::DictionaryValue* args, IPC::Message* reply_message);
    762 
    763   // Removes an event observer associated with the AutomationEventQueue.
    764   // Example:
    765   //   input: { "observer_id": 1 }
    766   //   output: none
    767   void RemoveEventObserver(
    768       base::DictionaryValue* args, IPC::Message* reply_message);
    769 
    770   // Retrieves an event from the AutomationEventQueue.
    771   // Blocks if 'blocking' is true, otherwise returns immediately.
    772   // Example:
    773   //   input: { "observer_id": 1,
    774   //            "blocking": true,
    775   //          }
    776   //   output: { "type": "raised",
    777   //             "name": "login complete"
    778   //             "id": 1,
    779   //           }
    780   void GetNextEvent(base::DictionaryValue* args, IPC::Message* reply_message);
    781 
    782   // Removes all events and observers attached to the AutomationEventQueue.
    783   // Example:
    784   //   input: none
    785   //   output: none
    786   void ClearEventQueue(
    787       base::DictionaryValue* args, IPC::Message* reply_message);
    788 
    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.
    792   // Example:
    793   //   input: { "view": {
    794   //              "render_process_id": 1,
    795   //              "render_view_id": 2,
    796   //            }
    797   //            "frame_xpath": "//frames[1]",
    798   //            "javascript":
    799   //                "window.domAutomationController.send(window.name)",
    800   //           }
    801   //   output: { "result": "My Window Name" }
    802   void ExecuteJavascriptInRenderView(
    803       base::DictionaryValue* args, IPC::Message* reply_message);
    804 
    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.
    808   // Example:
    809   //   input: { "windex": 1,
    810   //            "tab_index": 1,
    811   //            "auto_id": { "type": 0, "id": "awoein" }
    812   //          }
    813   //   output: { "did_go_forward": true,                      // optional
    814   //             "result": AUTOMATION_MSG_NAVIGATION_SUCCESS  // optional
    815   //           }
    816   void GoForward(base::DictionaryValue* args, IPC::Message* reply_message);
    817 
    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.
    821   // Example:
    822   //   input: { "windex": 1,
    823   //            "tab_index": 1,
    824   //            "auto_id": { "type": 0, "id": "awoein" }
    825   //          }
    826   //   output: { "did_go_back": true,                         // optional
    827   //             "result": AUTOMATION_MSG_NAVIGATION_SUCCESS  // optional
    828   //           }
    829   void GoBack(base::DictionaryValue* args, IPC::Message* reply_message);
    830 
    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.
    834   // Example:
    835   //   input: { "windex": 1,
    836   //            "tab_index": 1,
    837   //            "auto_id": { "type": 0, "id": "awoein" }
    838   //          }
    839   //   output: { "result": AUTOMATION_MSG_NAVIGATION_SUCCESS  // optional }
    840   void ReloadJSON(base::DictionaryValue* args, IPC::Message* reply_message);
    841 
    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.
    845   // Example:
    846   //   input: { "url": "http://www.google.com" }
    847   //   output: { "cookies": [
    848   //               {
    849   //                 "name": "PREF",
    850   //                 "value": "123101",
    851   //                 "path": "/",
    852   //                 "domain": "www.google.com",
    853   //                 "secure": false,
    854   //                 "expiry": 1401982012
    855   //               }
    856   //             ]
    857   //           }
    858   void GetCookiesJSON(base::DictionaryValue* args, IPC::Message* reply_message);
    859 
    860   // Deletes the cookie with the given name for the URL. Uses the JSON
    861   // interface.
    862   // Example:
    863   //   input: {
    864   //            "url": "http://www.google.com",
    865   //            "name": "my_cookie"
    866   //          }
    867   //   output: none
    868   void DeleteCookieJSON(base::DictionaryValue* args,
    869                         IPC::Message* reply_message);
    870 
    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
    876   // applicability:
    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
    880   //
    881   // Example:
    882   //   input: { "url": "http://www.google.com",
    883   //            "cookie": {
    884   //              "name": "PREF",
    885   //              "value": "123101",
    886   //              "path": "/",                  // optional
    887   //              "domain": ".www.google.com",  // optional
    888   //              "secure": false,              // optional
    889   //              "expiry": 1401982012          // optional
    890   //            }
    891   //          }
    892   //   output: none
    893   void SetCookieJSON(base::DictionaryValue* args, IPC::Message* reply_message);
    894 
    895   // Gets the cookies for the given URL in the context of a given browser
    896   // window. Uses the JSON interface.
    897   // Example:
    898   //   input: { "url": "http://www.google.com",
    899   //            "tab_index": 1,
    900   //            "windex": 1,
    901   //          }
    902   //   output: { "cookies": "foo=bar" }
    903   void GetCookiesInBrowserContext(base::DictionaryValue* args,
    904                                   IPC::Message* reply_message);
    905 
    906   // Deletes the cookie with the given name for the URL in the context of a
    907   // given browser window. Uses the JSON interface.
    908   // Example:
    909   //   input: { "url": "http://www.google.com",
    910   //            "cookie_name": "my_cookie"
    911   //            "tab_index": 1,
    912   //            "windex": 1,
    913   //          }
    914   //   output: none
    915   void DeleteCookieInBrowserContext(base::DictionaryValue* args,
    916                                     IPC::Message* reply_message);
    917 
    918   // Sets a cookie for the given URL in the context of a given browser window.
    919   // Uses the JSON interface.
    920   //
    921   // Example:
    922   //   input: { "url": "http://www.google.com",
    923   //            "value": "name=value; Expires=Wed, 09 Jun 2021 10:18:14 GMT",
    924   //            "tab_index": 1,
    925   //            "windex": 1,
    926   //          }
    927   //   output: none
    928   void SetCookieInBrowserContext(base::DictionaryValue* args,
    929                                  IPC::Message* reply_message);
    930 
    931   // Gets the ID for every open tab. This ID is unique per session.
    932   // Example:
    933   //   input: none
    934   //   output: { "ids": [213, 1] }
    935   void GetTabIds(base::DictionaryValue* args, IPC::Message* reply_message);
    936 
    937   // Gets info about all open views. Each view ID is unique per session.
    938   // Example:
    939   //   input: none
    940   //   output: { "views": [
    941   //               {
    942   //                 "auto_id": { "type": 0, "id": "awoein" },
    943   //                 "extension_id": "askjeoias3"  // optional
    944   //               }
    945   //             ]
    946   //           }
    947   void GetViews(base::DictionaryValue* args, IPC::Message* reply_message);
    948 
    949   // Checks if the given tab ID refers to an open tab.
    950   // Example:
    951   //   input: { "id": 41 }
    952   //   output: { "is_valid": false }
    953   void IsTabIdValid(base::DictionaryValue* args, IPC::Message* reply_message);
    954 
    955   // Checks if the given automation ID refers to an actual object.
    956   // Example:
    957   //   input: { "auto_id": { "type": 0, "id": "awoein" } }
    958   //   output: { "does_exist": false }
    959   void DoesAutomationObjectExist(
    960       base::DictionaryValue* args, IPC::Message* reply_message);
    961 
    962   // Closes the specified tab.
    963   // The pair |windex| and |tab_index| or the single |auto_id| must be given
    964   // to specify the tab.
    965   // Example:
    966   //   input: { "windex": 1,
    967   //            "tab_index": 1,
    968   //            "auto_id": { "type": 0, "id": "awoein" }
    969   //          }
    970   //   output: none
    971   void CloseTabJSON(base::DictionaryValue* args, IPC::Message* reply_message);
    972 
    973   // Sets the specified web view bounds.
    974   // The single |auto_id| must be given to specify the view.
    975   // This method currently is only supported for tabs.
    976   // Example:
    977   //   input: { "auto_id": { "type": 0, "id": "awoein" },
    978   //            "bounds": {
    979   //              "x": 100,
    980   //              "y": 200,
    981   //              "width": 500,
    982   //              "height": 800
    983   //            }
    984   //          }
    985   //   output: none
    986   void SetViewBounds(base::DictionaryValue* args, IPC::Message* reply_message);
    987 
    988   // Maximizes the web view.
    989   // The single |auto_id| must be given to specify the view.
    990   // This method currently is only supported for tabs.
    991   // Example:
    992   //   input: { "auto_id": { "type": 0, "id": "awoein" } }
    993   //   output: none
    994   void MaximizeView(base::DictionaryValue* args, IPC::Message* reply_message);
    995 
    996   // Sends the WebKit events for a mouse click at a given coordinate.
    997   // The pair |windex| and |tab_index| or the single |auto_id| must be given
    998   // to specify the render view.
    999   // Example:
   1000   //   input: { "windex": 1,
   1001   //            "tab_index": 1,
   1002   //            "auto_id": { "type": 0, "id": "awoein" },
   1003   //            "button": automation::kLeftButton,
   1004   //            "x": 100,
   1005   //            "y": 100
   1006   //          }
   1007   //   output: none
   1008   void WebkitMouseClick(base::DictionaryValue* args,
   1009                         IPC::Message* message);
   1010 
   1011   // Sends the WebKit event for a mouse move to a given coordinate.
   1012   // The pair |windex| and |tab_index| or the single |auto_id| must be given
   1013   // to specify the render view.
   1014   // Example:
   1015   //   input: { "windex": 1,
   1016   //            "tab_index": 1,
   1017   //            "auto_id": { "type": 0, "id": "awoein" },
   1018   //            "x": 100,
   1019   //            "y": 100
   1020   //          }
   1021   //   output: none
   1022   void WebkitMouseMove(base::DictionaryValue* args,
   1023                        IPC::Message* message);
   1024 
   1025   // Sends the WebKit events for a mouse drag between two coordinates.
   1026   // The pair |windex| and |tab_index| or the single |auto_id| must be given
   1027   // to specify the render view.
   1028   // Example:
   1029   //   input: { "windex": 1,
   1030   //            "tab_index": 1,
   1031   //            "auto_id": { "type": 0, "id": "awoein" },
   1032   //            "start_x": 100,
   1033   //            "start_y": 100,
   1034   //            "end_x": 100,
   1035   //            "end_y": 100
   1036   //          }
   1037   //   output: none
   1038   void WebkitMouseDrag(base::DictionaryValue* args,
   1039                        IPC::Message* message);
   1040 
   1041   // Sends the WebKit events for a mouse button down at a given coordinate.
   1042   // The pair |windex| and |tab_index| or the single |auto_id| must be given
   1043   // to specify the render view.
   1044   // Example:
   1045   //   input: { "windex": 1,
   1046   //            "tab_index": 1,
   1047   //            "auto_id": { "type": 0, "id": "awoein" },
   1048   //            "x": 100,
   1049   //            "y": 100
   1050   //          }
   1051   //   output: none
   1052   void WebkitMouseButtonDown(base::DictionaryValue* args,
   1053                              IPC::Message* message);
   1054 
   1055   // Sends the WebKit events for a mouse button up at a given coordinate.
   1056   // The pair |windex| and |tab_index| or the single |auto_id| must be given
   1057   // to specify the render view.
   1058   // Example:
   1059   //   input: { "windex": 1,
   1060   //            "tab_index": 1,
   1061   //            "auto_id": { "type": 0, "id": "awoein" },
   1062   //            "x": 100,
   1063   //            "y": 100
   1064   //          }
   1065   //   output: none
   1066   void WebkitMouseButtonUp(base::DictionaryValue* args,
   1067                            IPC::Message* message);
   1068 
   1069   // Sends the WebKit events for a mouse double click at a given coordinate.
   1070   // The pair |windex| and |tab_index| or the single |auto_id| must be given
   1071   // to specify the render view.
   1072   // Example:
   1073   //   input: { "windex": 1,
   1074   //            "tab_index": 1,
   1075   //            "auto_id": { "type": 0, "id": "awoein" },
   1076   //            "x": 100,
   1077   //            "y": 100
   1078   //          }
   1079   //   output: none
   1080   void WebkitMouseDoubleClick(base::DictionaryValue* args,
   1081                               IPC::Message* message);
   1082 
   1083   // Drag and drop file paths at a given coordinate.
   1084   // The pair |windex| and |tab_index| or the single |auto_id| must be given
   1085   // to specify the render view.
   1086   // Example:
   1087   //   input: { "windex": 1,
   1088   //            "tab_index": 1,
   1089   //            "auto_id": { "type": 0, "id": "awoein" },
   1090   //            "x": 100,
   1091   //            "y": 100,
   1092   //            "paths": [
   1093   //              "/tmp/file.txt"
   1094   //            ],
   1095   //          }
   1096   //   output: none
   1097   void DragAndDropFilePaths(base::DictionaryValue* args,
   1098                             IPC::Message* message);
   1099 
   1100   // Sends the WebKit key event with the specified properties.
   1101   // The pair |windex| and |tab_index| or the single |auto_id| must be given
   1102   // to specify the render view.
   1103   // Example:
   1104   //   input: { "windex": 1,
   1105   //            "tab_index": 1,
   1106   //            "auto_id": { "type": 0, "id": "awoein" },
   1107   //            "type": automation::kRawKeyDownType,
   1108   //            "nativeKeyCode": ui::VKEY_X,
   1109   //            "windowsKeyCode": ui::VKEY_X,
   1110   //            "unmodifiedText": "x",
   1111   //            "text": "X",
   1112   //            "modifiers": automation::kShiftKeyMask,
   1113   //            "isSystemKey": false
   1114   //          }
   1115   //   output: none
   1116   void SendWebkitKeyEvent(base::DictionaryValue* args,
   1117                           IPC::Message* message);
   1118 
   1119   // Gets the active JavaScript modal dialog's message.
   1120   // Example:
   1121   //   input: none
   1122   //   output: { "message": "This is an alert!" }
   1123   void GetAppModalDialogMessage(
   1124       base::DictionaryValue* args, IPC::Message* reply_message);
   1125 
   1126   // Accepts or dismisses the active JavaScript modal dialog. If optional
   1127   // prompt text is given, it will be used as the result of the prompt dialog.
   1128   // Example:
   1129   //   input: { "accept": true,
   1130   //            "prompt_text": "hello"  // optional
   1131   //          }
   1132   //   output: none
   1133   void AcceptOrDismissAppModalDialog(
   1134       base::DictionaryValue* args, IPC::Message* reply_message);
   1135 
   1136   // Activates the given tab.
   1137   // The pair |windex| and |tab_index| or the single |auto_id| must be given
   1138   // to specify the tab.
   1139   // Example:
   1140   //   input: { "windex": 1,
   1141   //            "tab_index": 1,
   1142   //            "auto_id": { "type": 0, "id": "awoein" }
   1143   //          }
   1144   //   output: none
   1145   void ActivateTabJSON(base::DictionaryValue* args, IPC::Message* message);
   1146 
   1147   // Blocks until the given tab is restored.
   1148   // Uses the JSON interface.
   1149   void WaitForTabToBeRestored(DictionaryValue* args,
   1150                               IPC::Message* reply_message);
   1151 
   1152   // Simulates an action on the SSL blocking page at the specified tab.
   1153   // If |proceed| is true, it is equivalent to the user pressing the
   1154   // 'Proceed' button, if false the 'Get me out of there button'.
   1155   // Note that this fails if the tab is not displaying a SSL blocking page.
   1156   // Uses the JSON interface.
   1157   // Example:
   1158   //   input: { "windex": 1,
   1159   //            "tab_index": 1,
   1160   //            "proceed": true
   1161   //          }
   1162   //   output: none
   1163   void ActionOnSSLBlockingPage(DictionaryValue* args,
   1164                                IPC::Message* reply_message);
   1165 
   1166   // Gets the security state for the given tab. Uses the JSON interface.
   1167   // Example:
   1168   //   input: { "windex": 1,
   1169   //            "tab_index": 1,
   1170   //          }
   1171   //   output: { "security_style": SECURITY_STYLE_AUTHENTICATED,
   1172   //             "ssl_cert_status": 3,  // bitmask of status flags
   1173   //             "insecure_content_status": 1,  // bitmask of ContentStatusFlags
   1174   //           }
   1175   void GetSecurityState(DictionaryValue* args,
   1176                         IPC::Message* reply_message);
   1177 
   1178   // Brings the given brower's window to the front.
   1179   // Example:
   1180   //   input: { "windex": 1 }
   1181   //   output: none
   1182   void BringBrowserToFrontJSON(base::DictionaryValue* args,
   1183                                IPC::Message* message);
   1184 
   1185   // Gets the version of ChromeDriver automation supported by this server.
   1186   // Example:
   1187   //   input: none
   1188   //   output: { "version": 1 }
   1189   void GetChromeDriverAutomationVersion(base::DictionaryValue* args,
   1190                                         IPC::Message* message);
   1191 
   1192   // Determines whether the extension page action is visible in the given tab.
   1193   // Example:
   1194   //   input: { "auto_id": { "type": 0, "id": "awoein" },
   1195   //            "extension_id": "byzaaoiea",
   1196   //          }
   1197   //   output: none
   1198   void IsPageActionVisible(base::DictionaryValue* args,
   1199                            IPC::Message* reply_message);
   1200 
   1201   // Creates a new |TestingAutomationProvider| that opens a server channel
   1202   // for the given |channel_id|.
   1203   // The server channel will be available for connection when this returns.
   1204   // Example:
   1205   //   input: { "channel_id": "testChannel123" }
   1206   void CreateNewAutomationProvider(base::DictionaryValue* args,
   1207                                    IPC::Message* reply_message);
   1208 
   1209   // Triggers a policy update on the platform and cloud providers, if they
   1210   // exist. Returns after the update notifications are received.
   1211   // Example:
   1212   //   input: none
   1213   //   output: none
   1214   void RefreshPolicies(base::DictionaryValue* args,
   1215                        IPC::Message* reply_message);
   1216 
   1217   // Simulates a memory bug (reference an array out of bounds) to cause Address
   1218   // Sanitizer (if it was built it) to catch the bug and abort the process.
   1219   // Example:
   1220   //   input: none
   1221   //   output: none
   1222   void SimulateAsanMemoryBug(base::DictionaryValue* args,
   1223                              IPC::Message* reply_message);
   1224 
   1225 #if defined(OS_CHROMEOS)
   1226   // OOBE wizard.
   1227 
   1228   // Accepts the network screen and continues to EULA.
   1229   // Example:
   1230   //   input: none
   1231   //   ouput: { "next_screen": "eula" }
   1232   void AcceptOOBENetworkScreen(base::DictionaryValue* args,
   1233                                IPC::Message* reply_message);
   1234 
   1235   // Accepts or declines EULA, moving forward or back from EULA screen.
   1236   // Example:
   1237   //    input: { "accepted": true, "usage_stats_reporting": false }
   1238   //    output: { "next_screen": "update" }
   1239   void AcceptOOBEEula(base::DictionaryValue* args, IPC::Message* reply_message);
   1240 
   1241   // Forces the ongoing update to cancel and proceed to the login screen.
   1242   // Example:
   1243   //    input: none
   1244   //    output: { "next_screen": "login" }
   1245   void CancelOOBEUpdate(base::DictionaryValue* args,
   1246                         IPC::Message* reply_message);
   1247 
   1248   // Chooses user image on the image picker screen and starts browser session.
   1249   // Example:
   1250   //    input: { "image": "profile" } - Google profile image
   1251   //    input: { "image": 2 } - default image number 2 (0-based)
   1252   //    output: { "next_screen": "session" }
   1253   void PickUserImage(base::DictionaryValue* args, IPC::Message* reply_message);
   1254 
   1255   // Skips OOBE to login step. Can be called when already at login screen,
   1256   // in which case does nothing and sends return value immediately.
   1257   // Example:
   1258   //    input: { "skip_image_selection": true }
   1259   //    output: { "next_screen": "login" }
   1260   void SkipToLogin(DictionaryValue* args, IPC::Message* reply_message);
   1261 
   1262   // Returns info about the current OOBE screen.
   1263   // Example:
   1264   //    input: none
   1265   //    output: { "screen_name": "network" }
   1266   //    output: none  (when already logged in)
   1267   void GetOOBEScreenInfo(DictionaryValue* args, IPC::Message* reply_message);
   1268 
   1269   // Login / Logout.
   1270   void GetLoginInfo(base::DictionaryValue* args, IPC::Message* reply_message);
   1271 
   1272   void ShowCreateAccountUI(base::DictionaryValue* args,
   1273                            IPC::Message* reply_message);
   1274 
   1275   void LoginAsGuest(base::DictionaryValue* args, IPC::Message* reply_message);
   1276 
   1277   // Submits the Chrome OS login form. Watch for the login to complete using
   1278   // the AddLoginObserver and GetNextEvent commands.
   1279   // Example:
   1280   //   input: { "username": "user (at) gmail.com",
   1281   //            "password": "fakepassword",
   1282   //          }
   1283   void SubmitLoginForm(base::DictionaryValue* args,
   1284                        IPC::Message* reply_message);
   1285 
   1286   void AddLoginEventObserver(DictionaryValue* args,
   1287                              IPC::Message* reply_message);
   1288 
   1289   // Executes javascript in the specified frame in the OOBE WebUI on chromeos.
   1290   // Waits for a result from the |DOMAutomationController|. The javascript must
   1291   // send a string. Must be run before a user has logged in.
   1292   // Example:
   1293   //   input: { "frame_xpath": "//frames[1]",
   1294   //            "javascript":
   1295   //                "window.domAutomationController.send(window.name)",
   1296   //           }
   1297   //   output: { "result": "My Window Name" }
   1298   void ExecuteJavascriptInOOBEWebUI(
   1299       base::DictionaryValue* args, IPC::Message* reply_message);
   1300 
   1301   void SignOut(base::DictionaryValue* args, IPC::Message* reply_message);
   1302 
   1303   // Screen locker.
   1304   void LockScreen(base::DictionaryValue* args, IPC::Message* reply_message);
   1305 
   1306   void UnlockScreen(base::DictionaryValue* args, IPC::Message* reply_message);
   1307 
   1308   void SignoutInScreenLocker(base::DictionaryValue* args,
   1309                              IPC::Message* reply_message);
   1310 
   1311   // Battery.
   1312   void GetBatteryInfo(base::DictionaryValue* args, IPC::Message* reply_message);
   1313 
   1314   // Network.
   1315   void GetNetworkInfo(base::DictionaryValue* args, IPC::Message* reply_message);
   1316 
   1317   void NetworkScan(base::DictionaryValue* args, IPC::Message* reply_message);
   1318 
   1319   void ToggleNetworkDevice(base::DictionaryValue* args,
   1320                            IPC::Message* reply_message);
   1321 
   1322   void SetProxySettings(base::DictionaryValue* args,
   1323                         IPC::Message* reply_message);
   1324 
   1325   void SetSharedProxies(base::DictionaryValue* args,
   1326                         IPC::Message* reply_message);
   1327 
   1328   void ConnectToCellularNetwork(base::DictionaryValue* args,
   1329                             IPC::Message* reply_message);
   1330 
   1331   void DisconnectFromCellularNetwork(base::DictionaryValue* args,
   1332                                  IPC::Message* reply_message);
   1333 
   1334   void ConnectToWifiNetwork(base::DictionaryValue* args,
   1335                             IPC::Message* reply_message);
   1336 
   1337   void ConnectToHiddenWifiNetwork(base::DictionaryValue* args,
   1338                                   IPC::Message* reply_message);
   1339 
   1340   void DisconnectFromWifiNetwork(base::DictionaryValue* args,
   1341                                  IPC::Message* reply_message);
   1342 
   1343   void ForgetWifiNetwork(DictionaryValue* args, IPC::Message* reply_message);
   1344 
   1345   // VPN.
   1346   void AddPrivateNetwork(DictionaryValue* args, IPC::Message* reply_message);
   1347 
   1348   void GetPrivateNetworkInfo(base::DictionaryValue* args,
   1349                              IPC::Message* reply_message);
   1350 
   1351   void ConnectToPrivateNetwork(base::DictionaryValue* args,
   1352                                IPC::Message* reply_message);
   1353 
   1354   void DisconnectFromPrivateNetwork(base::DictionaryValue* args,
   1355                                     IPC::Message* reply_message);
   1356 
   1357   // Accessibility.
   1358   void EnableSpokenFeedback(DictionaryValue* args, IPC::Message* reply_message);
   1359 
   1360   void IsSpokenFeedbackEnabled(DictionaryValue* args,
   1361                                IPC::Message* reply_message);
   1362 
   1363   // Time.
   1364   void GetTimeInfo(Browser* browser, base::DictionaryValue* args,
   1365                    IPC::Message* reply_message);
   1366 
   1367   void GetTimeInfo(base::DictionaryValue* args, IPC::Message* reply_message);
   1368 
   1369   void SetTimezone(base::DictionaryValue* args, IPC::Message* reply_message);
   1370 
   1371   void UpdateCheck(base::DictionaryValue* args, IPC::Message* reply_message);
   1372 
   1373   // Volume.
   1374   void GetVolumeInfo(base::DictionaryValue* args, IPC::Message* reply_message);
   1375 
   1376   void SetVolume(base::DictionaryValue* args, IPC::Message* reply_message);
   1377 
   1378   void SetMute(base::DictionaryValue* args, IPC::Message* reply_message);
   1379 
   1380   void CaptureProfilePhoto(Browser* browser,
   1381                            DictionaryValue* args,
   1382                            IPC::Message* reply_message);
   1383 
   1384   // Html terminal.
   1385   void OpenCrosh(base::DictionaryValue* args, IPC::Message* reply_message);
   1386 
   1387   void AddChromeosObservers();
   1388   void RemoveChromeosObservers();
   1389 
   1390 #endif  // defined(OS_CHROMEOS)
   1391 
   1392   void WaitForTabCountToBecome(int browser_handle,
   1393                                int target_tab_count,
   1394                                IPC::Message* reply_message);
   1395 
   1396   void WaitForInfoBarCount(int tab_handle,
   1397                            size_t target_count,
   1398                            IPC::Message* reply_message);
   1399 
   1400   void WaitForProcessLauncherThreadToGoIdle(IPC::Message* reply_message);
   1401 
   1402   void OnRemoveProvider();  // Called via PostTask
   1403 
   1404   // Execute Javascript in the context of a specific render view.
   1405   void ExecuteJavascriptInRenderViewFrame(
   1406       const string16& frame_xpath, const string16& script,
   1407       IPC::Message* reply_message, content::RenderViewHost* render_view_host);
   1408 
   1409   // Selects the given |tab| if not selected already.
   1410   void EnsureTabSelected(Browser* browser, content::WebContents* tab);
   1411 
   1412 #if defined(OS_CHROMEOS)
   1413   power_manager::PowerSupplyProperties power_supply_properties_;
   1414 #endif  // defined(OS_CHROMEOS)
   1415 
   1416   std::map<std::string, JsonHandler> handler_map_;
   1417   std::map<std::string, BrowserJsonHandler> browser_handler_map_;
   1418 
   1419   content::NotificationRegistrar registrar_;
   1420 
   1421   // The automation event observer queue. It is lazily created when an observer
   1422   // is added to avoid overhead when not needed.
   1423   scoped_ptr<AutomationEventQueue> automation_event_queue_;
   1424 
   1425   // List of commands which just finish synchronously and don't require
   1426   // setting up an observer.
   1427   static const int kSynchronousCommands[];
   1428 
   1429   DISALLOW_COPY_AND_ASSIGN(TestingAutomationProvider);
   1430 };
   1431 
   1432 #endif  // CHROME_BROWSER_AUTOMATION_TESTING_AUTOMATION_PROVIDER_H_
   1433