Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Side by Side Diff: chrome/browser/automation/testing_automation_provider.cc

Issue 10534163: First pass at refactoring pyautolib in preparation for removing proxy dependencies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Applied Nirnimesh's suggestions. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/automation/testing_automation_provider.h" 5 #include "chrome/browser/automation/testing_automation_provider.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 AutomationMsg_WaitForBrowserWindowCountToBecome, 432 AutomationMsg_WaitForBrowserWindowCountToBecome,
433 WaitForBrowserWindowCountToBecome) 433 WaitForBrowserWindowCountToBecome)
434 IPC_MESSAGE_HANDLER_DELAY_REPLY( 434 IPC_MESSAGE_HANDLER_DELAY_REPLY(
435 AutomationMsg_GoBackBlockUntilNavigationsComplete, 435 AutomationMsg_GoBackBlockUntilNavigationsComplete,
436 GoBackBlockUntilNavigationsComplete) 436 GoBackBlockUntilNavigationsComplete)
437 IPC_MESSAGE_HANDLER_DELAY_REPLY( 437 IPC_MESSAGE_HANDLER_DELAY_REPLY(
438 AutomationMsg_GoForwardBlockUntilNavigationsComplete, 438 AutomationMsg_GoForwardBlockUntilNavigationsComplete,
439 GoForwardBlockUntilNavigationsComplete) 439 GoForwardBlockUntilNavigationsComplete)
440 IPC_MESSAGE_HANDLER(AutomationMsg_SetShelfVisibility, SetShelfVisibility) 440 IPC_MESSAGE_HANDLER(AutomationMsg_SetShelfVisibility, SetShelfVisibility)
441 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_SendJSONRequest, 441 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_SendJSONRequest,
442 SendJSONRequest) 442 SendJSONRequestWithBrowserHandle)
443 IPC_MESSAGE_HANDLER_DELAY_REPLY(
444 AutomationMsg_SendJSONRequestWithBrowserIndex,
445 SendJSONRequestWithBrowserIndex)
443 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForTabCountToBecome, 446 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForTabCountToBecome,
444 WaitForTabCountToBecome) 447 WaitForTabCountToBecome)
445 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForInfoBarCount, 448 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForInfoBarCount,
446 WaitForInfoBarCount) 449 WaitForInfoBarCount)
447 IPC_MESSAGE_HANDLER(AutomationMsg_ResetToDefaultTheme, ResetToDefaultTheme) 450 IPC_MESSAGE_HANDLER(AutomationMsg_ResetToDefaultTheme, ResetToDefaultTheme)
448 IPC_MESSAGE_HANDLER_DELAY_REPLY( 451 IPC_MESSAGE_HANDLER_DELAY_REPLY(
449 AutomationMsg_WaitForProcessLauncherThreadToGoIdle, 452 AutomationMsg_WaitForProcessLauncherThreadToGoIdle,
450 WaitForProcessLauncherThreadToGoIdle) 453 WaitForProcessLauncherThreadToGoIdle)
451 454
452 IPC_MESSAGE_UNHANDLED( 455 IPC_MESSAGE_UNHANDLED(
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1623 Browser* browser = browser_tracker_->GetResource(handle); 1626 Browser* browser = browser_tracker_->GetResource(handle);
1624 if (browser) { 1627 if (browser) {
1625 if (visible) 1628 if (visible)
1626 browser->window()->GetDownloadShelf()->Show(); 1629 browser->window()->GetDownloadShelf()->Show();
1627 else 1630 else
1628 browser->window()->GetDownloadShelf()->Close(); 1631 browser->window()->GetDownloadShelf()->Close();
1629 } 1632 }
1630 } 1633 }
1631 } 1634 }
1632 1635
1633 void TestingAutomationProvider::SendJSONRequest(int handle, 1636 void TestingAutomationProvider::BuildJSONHandlerMaps() {
1637 // Map json commands to their handlers.
1638 handler_map_["WaitForAllTabsToStopLoading"] =
1639 &TestingAutomationProvider::WaitForAllViewsToStopLoading;
1640 handler_map_["GetIndicesFromTab"] =
1641 &TestingAutomationProvider::GetIndicesFromTab;
1642 handler_map_["NavigateToURL"] =
1643 &TestingAutomationProvider::NavigateToURL;
1644 handler_map_["WaitUntilNavigationCompletes"] =
1645 &TestingAutomationProvider::WaitUntilNavigationCompletes;
1646 handler_map_["GetLocalStatePrefsInfo"] =
1647 &TestingAutomationProvider::GetLocalStatePrefsInfo;
1648 handler_map_["SetLocalStatePrefs"] =
1649 &TestingAutomationProvider::SetLocalStatePrefs;
1650 handler_map_["GetPrefsInfo"] = &TestingAutomationProvider::GetPrefsInfo;
1651 handler_map_["SetPrefs"] = &TestingAutomationProvider::SetPrefs;
1652 handler_map_["ExecuteJavascript"] =
1653 &TestingAutomationProvider::ExecuteJavascriptJSON;
1654 handler_map_["AddDomEventObserver"] =
1655 &TestingAutomationProvider::AddDomEventObserver;
1656 handler_map_["RemoveEventObserver"] =
1657 &TestingAutomationProvider::RemoveEventObserver;
1658 handler_map_["GetNextEvent"] =
1659 &TestingAutomationProvider::GetNextEvent;
1660 handler_map_["ClearEventQueue"] =
1661 &TestingAutomationProvider::ClearEventQueue;
1662 handler_map_["ExecuteJavascriptInRenderView"] =
1663 &TestingAutomationProvider::ExecuteJavascriptInRenderView;
1664 handler_map_["GoForward"] =
1665 &TestingAutomationProvider::GoForward;
1666 handler_map_["GoBack"] =
1667 &TestingAutomationProvider::GoBack;
1668 handler_map_["Reload"] =
1669 &TestingAutomationProvider::ReloadJSON;
1670 handler_map_["CaptureEntirePage"] =
1671 &TestingAutomationProvider::CaptureEntirePageJSON;
1672 handler_map_["GetCookies"] =
1673 &TestingAutomationProvider::GetCookiesJSON;
1674 handler_map_["DeleteCookie"] =
1675 &TestingAutomationProvider::DeleteCookieJSON;
1676 handler_map_["SetCookie"] =
1677 &TestingAutomationProvider::SetCookieJSON;
1678 handler_map_["GetTabIds"] =
1679 &TestingAutomationProvider::GetTabIds;
1680 handler_map_["GetViews"] =
1681 &TestingAutomationProvider::GetViews;
1682 handler_map_["IsTabIdValid"] =
1683 &TestingAutomationProvider::IsTabIdValid;
1684 handler_map_["DoesAutomationObjectExist"] =
1685 &TestingAutomationProvider::DoesAutomationObjectExist;
1686 handler_map_["CloseTab"] =
1687 &TestingAutomationProvider::CloseTabJSON;
1688 handler_map_["SetViewBounds"] =
1689 &TestingAutomationProvider::SetViewBounds;
1690 handler_map_["WebkitMouseMove"] =
1691 &TestingAutomationProvider::WebkitMouseMove;
1692 handler_map_["WebkitMouseClick"] =
1693 &TestingAutomationProvider::WebkitMouseClick;
1694 handler_map_["WebkitMouseDrag"] =
1695 &TestingAutomationProvider::WebkitMouseDrag;
1696 handler_map_["WebkitMouseButtonUp"] =
1697 &TestingAutomationProvider::WebkitMouseButtonUp;
1698 handler_map_["WebkitMouseButtonDown"] =
1699 &TestingAutomationProvider::WebkitMouseButtonDown;
1700 handler_map_["WebkitMouseDoubleClick"] =
1701 &TestingAutomationProvider::WebkitMouseDoubleClick;
1702 handler_map_["DragAndDropFilePaths"] =
1703 &TestingAutomationProvider::DragAndDropFilePaths;
1704 handler_map_["SendWebkitKeyEvent"] =
1705 &TestingAutomationProvider::SendWebkitKeyEvent;
1706 handler_map_["SendOSLevelKeyEventToTab"] =
1707 &TestingAutomationProvider::SendOSLevelKeyEventToTab;
1708 handler_map_["ProcessWebMouseEvent"] =
1709 &TestingAutomationProvider::ProcessWebMouseEvent;
1710 handler_map_["ActivateTab"] =
1711 &TestingAutomationProvider::ActivateTabJSON;
1712 handler_map_["GetAppModalDialogMessage"] =
1713 &TestingAutomationProvider::GetAppModalDialogMessage;
1714 handler_map_["AcceptOrDismissAppModalDialog"] =
1715 &TestingAutomationProvider::AcceptOrDismissAppModalDialog;
1716 handler_map_["GetChromeDriverAutomationVersion"] =
1717 &TestingAutomationProvider::GetChromeDriverAutomationVersion;
1718 handler_map_["IsPageActionVisible"] =
1719 &TestingAutomationProvider::IsPageActionVisible;
1720 handler_map_["CreateNewAutomationProvider"] =
1721 &TestingAutomationProvider::CreateNewAutomationProvider;
1722 handler_map_["GetBrowserInfo"] =
1723 &TestingAutomationProvider::GetBrowserInfo;
1724 handler_map_["OpenNewBrowserWindowWithNewProfile"] =
1725 &TestingAutomationProvider::OpenNewBrowserWindowWithNewProfile;
1726 handler_map_["GetMultiProfileInfo"] =
1727 &TestingAutomationProvider::GetMultiProfileInfo;
1728 handler_map_["GetProcessInfo"] =
1729 &TestingAutomationProvider::GetProcessInfo;
1730 handler_map_["GetPolicyDefinitionList"] =
1731 &TestingAutomationProvider::GetPolicyDefinitionList;
1732 handler_map_["RefreshPolicies"] =
1733 &TestingAutomationProvider::RefreshPolicies;
1734 handler_map_["InstallExtension"] =
1735 &TestingAutomationProvider::InstallExtension;
1736 handler_map_["GetExtensionsInfo"] =
1737 &TestingAutomationProvider::GetExtensionsInfo;
1738 handler_map_["UninstallExtensionById"] =
1739 &TestingAutomationProvider::UninstallExtensionById;
1740 handler_map_["SetExtensionStateById"] =
1741 &TestingAutomationProvider::SetExtensionStateById;
1742 handler_map_["TriggerPageActionById"] =
1743 &TestingAutomationProvider::TriggerPageActionById;
1744 handler_map_["TriggerBrowserActionById"] =
1745 &TestingAutomationProvider::TriggerBrowserActionById;
1746 handler_map_["UpdateExtensionsNow"] =
1747 &TestingAutomationProvider::UpdateExtensionsNow;
1748 #if !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS))
1749 handler_map_["HeapProfilerDump"] =
1750 &TestingAutomationProvider::HeapProfilerDump;
1751 #endif // !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS))
1752 handler_map_["OverrideGeoposition"] =
1753 &TestingAutomationProvider::OverrideGeoposition;
1754 handler_map_["AppendSwitchASCIIToCommandLine"] =
1755 &TestingAutomationProvider::AppendSwitchASCIIToCommandLine;
1756 handler_map_["SimulateAsanMemoryBug"] =
1757 &TestingAutomationProvider::SimulateAsanMemoryBug;
1758
1759 #if defined(OS_CHROMEOS)
1760 handler_map_["AcceptOOBENetworkScreen"] =
1761 &TestingAutomationProvider::AcceptOOBENetworkScreen;
1762 handler_map_["AcceptOOBEEula"] = &TestingAutomationProvider::AcceptOOBEEula;
1763 handler_map_["CancelOOBEUpdate"] =
1764 &TestingAutomationProvider::CancelOOBEUpdate;
1765 handler_map_["PickUserImage"] = &TestingAutomationProvider::PickUserImage;
1766 handler_map_["SkipToLogin"] = &TestingAutomationProvider::SkipToLogin;
1767 handler_map_["GetOOBEScreenInfo"] =
1768 &TestingAutomationProvider::GetOOBEScreenInfo;
1769
1770 handler_map_["GetLoginInfo"] = &TestingAutomationProvider::GetLoginInfo;
1771 handler_map_["ShowCreateAccountUI"] =
1772 &TestingAutomationProvider::ShowCreateAccountUI;
1773 handler_map_["ExecuteJavascriptInOOBEWebUI"] =
1774 &TestingAutomationProvider::ExecuteJavascriptInOOBEWebUI;
1775 handler_map_["LoginAsGuest"] = &TestingAutomationProvider::LoginAsGuest;
1776 handler_map_["SubmitLoginForm"] =
1777 &TestingAutomationProvider::SubmitLoginForm;
1778 handler_map_["AddLoginEventObserver"] =
1779 &TestingAutomationProvider::AddLoginEventObserver;
1780 handler_map_["SignOut"] = &TestingAutomationProvider::SignOut;
1781
1782 handler_map_["LockScreen"] = &TestingAutomationProvider::LockScreen;
1783 handler_map_["UnlockScreen"] = &TestingAutomationProvider::UnlockScreen;
1784 handler_map_["SignoutInScreenLocker"] =
1785 &TestingAutomationProvider::SignoutInScreenLocker;
1786
1787 handler_map_["GetBatteryInfo"] = &TestingAutomationProvider::GetBatteryInfo;
1788
1789 handler_map_["GetNetworkInfo"] = &TestingAutomationProvider::GetNetworkInfo;
1790 handler_map_["NetworkScan"] = &TestingAutomationProvider::NetworkScan;
1791 handler_map_["ToggleNetworkDevice"] =
1792 &TestingAutomationProvider::ToggleNetworkDevice;
1793 handler_map_["ConnectToCellularNetwork"] =
1794 &TestingAutomationProvider::ConnectToCellularNetwork;
1795 handler_map_["DisconnectFromCellularNetwork"] =
1796 &TestingAutomationProvider::DisconnectFromCellularNetwork;
1797 handler_map_["ConnectToWifiNetwork"] =
1798 &TestingAutomationProvider::ConnectToWifiNetwork;
1799 handler_map_["ConnectToHiddenWifiNetwork"] =
1800 &TestingAutomationProvider::ConnectToHiddenWifiNetwork;
1801 handler_map_["DisconnectFromWifiNetwork"] =
1802 &TestingAutomationProvider::DisconnectFromWifiNetwork;
1803 handler_map_["ForgetWifiNetwork"] =
1804 &TestingAutomationProvider::ForgetWifiNetwork;
1805
1806 handler_map_["AddPrivateNetwork"] =
1807 &TestingAutomationProvider::AddPrivateNetwork;
1808 handler_map_["GetPrivateNetworkInfo"] =
1809 &TestingAutomationProvider::GetPrivateNetworkInfo;
1810 handler_map_["ConnectToPrivateNetwork"] =
1811 &TestingAutomationProvider::ConnectToPrivateNetwork;
1812 handler_map_["DisconnectFromPrivateNetwork"] =
1813 &TestingAutomationProvider::DisconnectFromPrivateNetwork;
1814
1815 handler_map_["IsEnterpriseDevice"] =
1816 &TestingAutomationProvider::IsEnterpriseDevice;
1817 handler_map_["GetEnterprisePolicyInfo"] =
1818 &TestingAutomationProvider::GetEnterprisePolicyInfo;
1819 handler_map_["EnrollEnterpriseDevice"] =
1820 &TestingAutomationProvider::EnrollEnterpriseDevice;
1821
1822 handler_map_["EnableSpokenFeedback"] =
1823 &TestingAutomationProvider::EnableSpokenFeedback;
1824 handler_map_["IsSpokenFeedbackEnabled"] =
1825 &TestingAutomationProvider::IsSpokenFeedbackEnabled;
1826
1827 handler_map_["GetTimeInfo"] = &TestingAutomationProvider::GetTimeInfo;
1828 handler_map_["SetTimezone"] = &TestingAutomationProvider::SetTimezone;
1829
1830 handler_map_["GetUpdateInfo"] = &TestingAutomationProvider::GetUpdateInfo;
1831 handler_map_["UpdateCheck"] = &TestingAutomationProvider::UpdateCheck;
1832 handler_map_["SetReleaseTrack"] =
1833 &TestingAutomationProvider::SetReleaseTrack;
1834
1835 handler_map_["GetVolumeInfo"] = &TestingAutomationProvider::GetVolumeInfo;
1836 handler_map_["SetVolume"] = &TestingAutomationProvider::SetVolume;
1837 handler_map_["SetMute"] = &TestingAutomationProvider::SetMute;
1838
1839 handler_map_["OpenCrosh"] = &TestingAutomationProvider::OpenCrosh;
1840
1841 #endif // defined(OS_CHROMEOS)
1842
1843 browser_handler_map_["DisablePlugin"] =
1844 &TestingAutomationProvider::DisablePlugin;
1845 browser_handler_map_["EnablePlugin"] =
1846 &TestingAutomationProvider::EnablePlugin;
1847 browser_handler_map_["GetPluginsInfo"] =
1848 &TestingAutomationProvider::GetPluginsInfo;
1849
1850 browser_handler_map_["GetNavigationInfo"] =
1851 &TestingAutomationProvider::GetNavigationInfo;
1852
1853 browser_handler_map_["PerformActionOnInfobar"] =
1854 &TestingAutomationProvider::PerformActionOnInfobar;
1855
1856 browser_handler_map_["GetHistoryInfo"] =
1857 &TestingAutomationProvider::GetHistoryInfo;
1858 browser_handler_map_["AddHistoryItem"] =
1859 &TestingAutomationProvider::AddHistoryItem;
1860
1861 browser_handler_map_["GetOmniboxInfo"] =
1862 &TestingAutomationProvider::GetOmniboxInfo;
1863 browser_handler_map_["SetOmniboxText"] =
1864 &TestingAutomationProvider::SetOmniboxText;
1865 browser_handler_map_["OmniboxAcceptInput"] =
1866 &TestingAutomationProvider::OmniboxAcceptInput;
1867 browser_handler_map_["OmniboxMovePopupSelection"] =
1868 &TestingAutomationProvider::OmniboxMovePopupSelection;
1869
1870 browser_handler_map_["GetInstantInfo"] =
1871 &TestingAutomationProvider::GetInstantInfo;
1872
1873 browser_handler_map_["LoadSearchEngineInfo"] =
1874 &TestingAutomationProvider::LoadSearchEngineInfo;
1875 browser_handler_map_["GetSearchEngineInfo"] =
1876 &TestingAutomationProvider::GetSearchEngineInfo;
1877 browser_handler_map_["AddOrEditSearchEngine"] =
1878 &TestingAutomationProvider::AddOrEditSearchEngine;
1879 browser_handler_map_["PerformActionOnSearchEngine"] =
1880 &TestingAutomationProvider::PerformActionOnSearchEngine;
1881
1882 #if defined(ENABLE_PROTECTOR_SERVICE)
1883 browser_handler_map_["GetProtectorState"] =
1884 &TestingAutomationProvider::GetProtectorState;
1885 browser_handler_map_["PerformProtectorAction"] =
1886 &TestingAutomationProvider::PerformProtectorAction;
1887 #endif
1888
1889 browser_handler_map_["SetWindowDimensions"] =
1890 &TestingAutomationProvider::SetWindowDimensions;
1891
1892 browser_handler_map_["GetDownloadsInfo"] =
1893 &TestingAutomationProvider::GetDownloadsInfo;
1894 browser_handler_map_["WaitForAllDownloadsToComplete"] =
1895 &TestingAutomationProvider::WaitForAllDownloadsToComplete;
1896 browser_handler_map_["PerformActionOnDownload"] =
1897 &TestingAutomationProvider::PerformActionOnDownload;
1898
1899 browser_handler_map_["GetInitialLoadTimes"] =
1900 &TestingAutomationProvider::GetInitialLoadTimes;
1901
1902 browser_handler_map_["SaveTabContents"] =
1903 &TestingAutomationProvider::SaveTabContents;
1904
1905 browser_handler_map_["ImportSettings"] =
1906 &TestingAutomationProvider::ImportSettings;
1907
1908 browser_handler_map_["AddSavedPassword"] =
1909 &TestingAutomationProvider::AddSavedPassword;
1910 browser_handler_map_["RemoveSavedPassword"] =
1911 &TestingAutomationProvider::RemoveSavedPassword;
1912 browser_handler_map_["GetSavedPasswords"] =
1913 &TestingAutomationProvider::GetSavedPasswords;
1914
1915 browser_handler_map_["ClearBrowsingData"] =
1916 &TestingAutomationProvider::ClearBrowsingData;
1917
1918 browser_handler_map_["GetBlockedPopupsInfo"] =
1919 &TestingAutomationProvider::GetBlockedPopupsInfo;
1920 browser_handler_map_["UnblockAndLaunchBlockedPopup"] =
1921 &TestingAutomationProvider::UnblockAndLaunchBlockedPopup;
1922
1923 // SetTheme() implemented using InstallExtension().
1924 browser_handler_map_["GetThemeInfo"] =
1925 &TestingAutomationProvider::GetThemeInfo;
1926
1927 browser_handler_map_["FindInPage"] = &TestingAutomationProvider::FindInPage;
1928
1929 browser_handler_map_["SelectTranslateOption"] =
1930 &TestingAutomationProvider::SelectTranslateOption;
1931 browser_handler_map_["GetTranslateInfo"] =
1932 &TestingAutomationProvider::GetTranslateInfo;
1933
1934 browser_handler_map_["GetAutofillProfile"] =
1935 &TestingAutomationProvider::GetAutofillProfile;
1936 browser_handler_map_["FillAutofillProfile"] =
1937 &TestingAutomationProvider::FillAutofillProfile;
1938 browser_handler_map_["SubmitAutofillForm"] =
1939 &TestingAutomationProvider::SubmitAutofillForm;
1940 browser_handler_map_["AutofillTriggerSuggestions"] =
1941 &TestingAutomationProvider::AutofillTriggerSuggestions;
1942 browser_handler_map_["AutofillHighlightSuggestion"] =
1943 &TestingAutomationProvider::AutofillHighlightSuggestion;
1944 browser_handler_map_["AutofillAcceptSelection"] =
1945 &TestingAutomationProvider::AutofillAcceptSelection;
1946
1947 browser_handler_map_["GetAllNotifications"] =
1948 &TestingAutomationProvider::GetAllNotifications;
1949 browser_handler_map_["CloseNotification"] =
1950 &TestingAutomationProvider::CloseNotification;
1951 browser_handler_map_["WaitForNotificationCount"] =
1952 &TestingAutomationProvider::WaitForNotificationCount;
1953
1954 browser_handler_map_["SignInToSync"] =
1955 &TestingAutomationProvider::SignInToSync;
1956 browser_handler_map_["GetSyncInfo"] =
1957 &TestingAutomationProvider::GetSyncInfo;
1958 browser_handler_map_["AwaitFullSyncCompletion"] =
1959 &TestingAutomationProvider::AwaitFullSyncCompletion;
1960 browser_handler_map_["AwaitSyncRestart"] =
1961 &TestingAutomationProvider::AwaitSyncRestart;
1962 browser_handler_map_["EnableSyncForDatatypes"] =
1963 &TestingAutomationProvider::EnableSyncForDatatypes;
1964 browser_handler_map_["DisableSyncForDatatypes"] =
1965 &TestingAutomationProvider::DisableSyncForDatatypes;
1966
1967 browser_handler_map_["GetNTPInfo"] =
1968 &TestingAutomationProvider::GetNTPInfo;
1969 browser_handler_map_["RemoveNTPMostVisitedThumbnail"] =
1970 &TestingAutomationProvider::RemoveNTPMostVisitedThumbnail;
1971 browser_handler_map_["RestoreAllNTPMostVisitedThumbnails"] =
1972 &TestingAutomationProvider::RestoreAllNTPMostVisitedThumbnails;
1973
1974 browser_handler_map_["KillRendererProcess"] =
1975 &TestingAutomationProvider::KillRendererProcess;
1976
1977 browser_handler_map_["LaunchApp"] = &TestingAutomationProvider::LaunchApp;
1978 browser_handler_map_["SetAppLaunchType"] =
1979 &TestingAutomationProvider::SetAppLaunchType;
1980
1981 browser_handler_map_["GetV8HeapStats"] =
1982 &TestingAutomationProvider::GetV8HeapStats;
1983 browser_handler_map_["GetFPS"] =
1984 &TestingAutomationProvider::GetFPS;
1985
1986 browser_handler_map_["IsFullscreenForBrowser"] =
1987 &TestingAutomationProvider::IsFullscreenForBrowser;
1988 browser_handler_map_["IsFullscreenForTab"] =
1989 &TestingAutomationProvider::IsFullscreenForTab;
1990 browser_handler_map_["IsMouseLocked"] =
1991 &TestingAutomationProvider::IsMouseLocked;
1992 browser_handler_map_["IsMouseLockPermissionRequested"] =
1993 &TestingAutomationProvider::IsMouseLockPermissionRequested;
1994 browser_handler_map_["IsFullscreenPermissionRequested"] =
1995 &TestingAutomationProvider::IsFullscreenPermissionRequested;
1996 browser_handler_map_["IsFullscreenBubbleDisplayed"] =
1997 &TestingAutomationProvider::IsFullscreenBubbleDisplayed;
1998 browser_handler_map_["IsFullscreenBubbleDisplayingButtons"] =
1999 &TestingAutomationProvider::IsFullscreenBubbleDisplayingButtons;
2000 browser_handler_map_["AcceptCurrentFullscreenOrMouseLockRequest"] =
2001 &TestingAutomationProvider::AcceptCurrentFullscreenOrMouseLockRequest;
2002 browser_handler_map_["DenyCurrentFullscreenOrMouseLockRequest"] =
2003 &TestingAutomationProvider::DenyCurrentFullscreenOrMouseLockRequest;
2004
2005 #if defined(OS_CHROMEOS)
2006 browser_handler_map_["CaptureProfilePhoto"] =
2007 &TestingAutomationProvider::CaptureProfilePhoto;
2008 browser_handler_map_["GetTimeInfo"] =
2009 &TestingAutomationProvider::GetTimeInfo;
2010 browser_handler_map_["GetProxySettings"] =
2011 &TestingAutomationProvider::GetProxySettings;
2012 browser_handler_map_["SetProxySettings"] =
2013 &TestingAutomationProvider::SetProxySettings;
2014 #endif // defined(OS_CHROMEOS)
2015 }
2016
2017 DictionaryValue* TestingAutomationProvider::ParseJSONRequestCommand(
kkania 2012/06/18 16:30:33 i think it would be preferable to return scoped_pt
craigdh 2012/06/19 00:19:35 Done.
2018 const std::string& json_request,
2019 std::string* command,
2020 std::string* error) {
2021 scoped_ptr<Value> values(base::JSONReader::ReadAndReturnError(json_request,
2022 base::JSON_ALLOW_TRAILING_COMMAS, NULL, error));
2023 if (!error->empty())
kkania 2012/06/18 16:30:33 I think it would be better to check values.get() h
craigdh 2012/06/19 00:19:35 Done.
2024 return NULL;
2025
2026 // Make sure input is a dict with a string command.
2027 if (values->GetType() != Value::TYPE_DICTIONARY) {
2028 *error = "Command dictionary is not a dictionary.";
2029 return NULL;
2030 }
2031 scoped_ptr<DictionaryValue> dict_value(
2032 static_cast<DictionaryValue*>(values.release()));
2033 if (!dict_value->GetStringASCII(std::string("command"), command)) {
kkania 2012/06/18 16:30:33 you don't need the explicit call to the std::strin
craigdh 2012/06/19 00:19:35 Done.
2034 *error = "Command key string missing from dictionary.";
2035 return NULL;
2036 }
2037 return dict_value.release();
2038 }
2039
2040 void TestingAutomationProvider::SendJSONRequestWithBrowserHandle(
2041 int handle,
2042 const std::string& json_request,
2043 IPC::Message* reply_message) {
2044 Browser* browser = NULL;
2045 if (browser_tracker_->ContainsHandle(handle))
2046 browser = browser_tracker_->GetResource(handle);
kkania 2012/06/18 16:30:33 indent
craigdh 2012/06/19 00:19:35 Done.
2047 if (!browser && handle >= 0) {
Nirnimesh 2012/06/15 19:52:49 Why handle >= 0?
craigdh 2012/06/19 00:19:35 That means the user tried to pass a valid handle.
2048 AutomationJSONReply(this, reply_message).SendError(
2049 "The browser window does not exist.");
2050 } else {
2051 SendJSONRequest(browser, json_request, reply_message);
2052 }
2053 }
2054
2055 void TestingAutomationProvider::SendJSONRequestWithBrowserIndex(
2056 int index,
2057 const std::string& json_request,
2058 IPC::Message* reply_message) {
2059 Browser* browser = index < 0 ? NULL : automation_util::GetBrowserAt(index);
2060 if (!browser && index >= 0) {
2061 AutomationJSONReply(this, reply_message).SendError(
2062 StringPrintf("Browser window with index=%d does not exist.", index));
2063 } else {
2064 SendJSONRequest(browser, json_request, reply_message);
2065 }
2066 }
2067
2068 void TestingAutomationProvider::SendJSONRequest(Browser* browser,
1634 const std::string& json_request, 2069 const std::string& json_request,
1635 IPC::Message* reply_message) { 2070 IPC::Message* reply_message) {
1636 std::string error; 2071 std::string command, error_string;
1637 scoped_ptr<Value> values(base::JSONReader::ReadAndReturnError(json_request, 2072 scoped_ptr<DictionaryValue> dict_value(
1638 base::JSON_ALLOW_TRAILING_COMMAS, NULL, &error)); 2073 ParseJSONRequestCommand(json_request, &command, &error_string));
1639 if (!error.empty()) { 2074 if (!dict_value.get()) {
1640 AutomationJSONReply(this, reply_message).SendError(error); 2075 AutomationJSONReply(this, reply_message).SendError(error_string);
1641 return; 2076 return;
1642 } 2077 }
1643 2078
1644 // Make sure input is a dict with a string command. 2079 if (handler_map_.empty() || browser_handler_map_.empty())
1645 std::string command; 2080 BuildJSONHandlerMaps();
1646 DictionaryValue* dict_value = NULL; 2081
1647 if (values->GetType() != Value::TYPE_DICTIONARY) { 2082 // Look for command in handlers that take a Browser.
1648 AutomationJSONReply(this, reply_message).SendError("not a dict"); 2083 if (browser_handler_map_.find(std::string(command)) !=
1649 return; 2084 browser_handler_map_.end() && browser) {
1650 } 2085 (this->*browser_handler_map_[command])(browser, dict_value.get(),
1651 // Ownership remains with "values" variable. 2086 reply_message);
1652 dict_value = static_cast<DictionaryValue*>(values.get()); 2087 // Look for command in handlers that don't take a Browser.
1653 if (!dict_value->GetStringASCII(std::string("command"), &command)) { 2088 } else if (handler_map_.find(std::string(command)) != handler_map_.end()) {
1654 AutomationJSONReply(this, reply_message) 2089 (this->*handler_map_[command])(dict_value.get(), reply_message);
1655 .SendError("no command key in dict or not a string command"); 2090 // Command has no handler.
1656 return;
1657 }
1658
1659 // Map json commands to their handlers.
1660 std::map<std::string, JsonHandler> handler_map;
1661 handler_map["WaitForAllTabsToStopLoading"] =
1662 &TestingAutomationProvider::WaitForAllViewsToStopLoading;
1663 handler_map["GetIndicesFromTab"] =
1664 &TestingAutomationProvider::GetIndicesFromTab;
1665 handler_map["NavigateToURL"] =
1666 &TestingAutomationProvider::NavigateToURL;
1667 handler_map["WaitUntilNavigationCompletes"] =
1668 &TestingAutomationProvider::WaitUntilNavigationCompletes;
1669 handler_map["GetLocalStatePrefsInfo"] =
1670 &TestingAutomationProvider::GetLocalStatePrefsInfo;
1671 handler_map["SetLocalStatePrefs"] =
1672 &TestingAutomationProvider::SetLocalStatePrefs;
1673 handler_map["GetPrefsInfo"] = &TestingAutomationProvider::GetPrefsInfo;
1674 handler_map["SetPrefs"] = &TestingAutomationProvider::SetPrefs;
1675 handler_map["ExecuteJavascript"] =
1676 &TestingAutomationProvider::ExecuteJavascriptJSON;
1677 handler_map["AddDomEventObserver"] =
1678 &TestingAutomationProvider::AddDomEventObserver;
1679 handler_map["RemoveEventObserver"] =
1680 &TestingAutomationProvider::RemoveEventObserver;
1681 handler_map["GetNextEvent"] =
1682 &TestingAutomationProvider::GetNextEvent;
1683 handler_map["ClearEventQueue"] =
1684 &TestingAutomationProvider::ClearEventQueue;
1685 handler_map["ExecuteJavascriptInRenderView"] =
1686 &TestingAutomationProvider::ExecuteJavascriptInRenderView;
1687 handler_map["GoForward"] =
1688 &TestingAutomationProvider::GoForward;
1689 handler_map["GoBack"] =
1690 &TestingAutomationProvider::GoBack;
1691 handler_map["Reload"] =
1692 &TestingAutomationProvider::ReloadJSON;
1693 handler_map["CaptureEntirePage"] =
1694 &TestingAutomationProvider::CaptureEntirePageJSON;
1695 handler_map["GetCookies"] =
1696 &TestingAutomationProvider::GetCookiesJSON;
1697 handler_map["DeleteCookie"] =
1698 &TestingAutomationProvider::DeleteCookieJSON;
1699 handler_map["SetCookie"] =
1700 &TestingAutomationProvider::SetCookieJSON;
1701 handler_map["GetTabIds"] =
1702 &TestingAutomationProvider::GetTabIds;
1703 handler_map["GetViews"] =
1704 &TestingAutomationProvider::GetViews;
1705 handler_map["IsTabIdValid"] =
1706 &TestingAutomationProvider::IsTabIdValid;
1707 handler_map["DoesAutomationObjectExist"] =
1708 &TestingAutomationProvider::DoesAutomationObjectExist;
1709 handler_map["CloseTab"] =
1710 &TestingAutomationProvider::CloseTabJSON;
1711 handler_map["SetViewBounds"] =
1712 &TestingAutomationProvider::SetViewBounds;
1713 handler_map["WebkitMouseMove"] =
1714 &TestingAutomationProvider::WebkitMouseMove;
1715 handler_map["WebkitMouseClick"] =
1716 &TestingAutomationProvider::WebkitMouseClick;
1717 handler_map["WebkitMouseDrag"] =
1718 &TestingAutomationProvider::WebkitMouseDrag;
1719 handler_map["WebkitMouseButtonUp"] =
1720 &TestingAutomationProvider::WebkitMouseButtonUp;
1721 handler_map["WebkitMouseButtonDown"] =
1722 &TestingAutomationProvider::WebkitMouseButtonDown;
1723 handler_map["WebkitMouseDoubleClick"] =
1724 &TestingAutomationProvider::WebkitMouseDoubleClick;
1725 handler_map["DragAndDropFilePaths"] =
1726 &TestingAutomationProvider::DragAndDropFilePaths;
1727 handler_map["SendWebkitKeyEvent"] =
1728 &TestingAutomationProvider::SendWebkitKeyEvent;
1729 handler_map["SendOSLevelKeyEventToTab"] =
1730 &TestingAutomationProvider::SendOSLevelKeyEventToTab;
1731 handler_map["ProcessWebMouseEvent"] =
1732 &TestingAutomationProvider::ProcessWebMouseEvent;
1733 handler_map["ActivateTab"] =
1734 &TestingAutomationProvider::ActivateTabJSON;
1735 handler_map["GetAppModalDialogMessage"] =
1736 &TestingAutomationProvider::GetAppModalDialogMessage;
1737 handler_map["AcceptOrDismissAppModalDialog"] =
1738 &TestingAutomationProvider::AcceptOrDismissAppModalDialog;
1739 handler_map["GetChromeDriverAutomationVersion"] =
1740 &TestingAutomationProvider::GetChromeDriverAutomationVersion;
1741 handler_map["IsPageActionVisible"] =
1742 &TestingAutomationProvider::IsPageActionVisible;
1743 handler_map["CreateNewAutomationProvider"] =
1744 &TestingAutomationProvider::CreateNewAutomationProvider;
1745 handler_map["GetBrowserInfo"] =
1746 &TestingAutomationProvider::GetBrowserInfo;
1747 handler_map["OpenNewBrowserWindowWithNewProfile"] =
1748 &TestingAutomationProvider::OpenNewBrowserWindowWithNewProfile;
1749 handler_map["GetMultiProfileInfo"] =
1750 &TestingAutomationProvider::GetMultiProfileInfo;
1751 handler_map["GetProcessInfo"] =
1752 &TestingAutomationProvider::GetProcessInfo;
1753 handler_map["GetPolicyDefinitionList"] =
1754 &TestingAutomationProvider::GetPolicyDefinitionList;
1755 handler_map["RefreshPolicies"] =
1756 &TestingAutomationProvider::RefreshPolicies;
1757 handler_map["InstallExtension"] =
1758 &TestingAutomationProvider::InstallExtension;
1759 handler_map["GetExtensionsInfo"] =
1760 &TestingAutomationProvider::GetExtensionsInfo;
1761 handler_map["UninstallExtensionById"] =
1762 &TestingAutomationProvider::UninstallExtensionById;
1763 handler_map["SetExtensionStateById"] =
1764 &TestingAutomationProvider::SetExtensionStateById;
1765 handler_map["TriggerPageActionById"] =
1766 &TestingAutomationProvider::TriggerPageActionById;
1767 handler_map["TriggerBrowserActionById"] =
1768 &TestingAutomationProvider::TriggerBrowserActionById;
1769 handler_map["UpdateExtensionsNow"] =
1770 &TestingAutomationProvider::UpdateExtensionsNow;
1771 #if !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS))
1772 handler_map["HeapProfilerDump"] =
1773 &TestingAutomationProvider::HeapProfilerDump;
1774 #endif // !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS))
1775 handler_map["OverrideGeoposition"] =
1776 &TestingAutomationProvider::OverrideGeoposition;
1777 handler_map["AppendSwitchASCIIToCommandLine"] =
1778 &TestingAutomationProvider::AppendSwitchASCIIToCommandLine;
1779 handler_map["SimulateAsanMemoryBug"] =
1780 &TestingAutomationProvider::SimulateAsanMemoryBug;
1781
1782 #if defined(OS_CHROMEOS)
1783 handler_map["AcceptOOBENetworkScreen"] =
1784 &TestingAutomationProvider::AcceptOOBENetworkScreen;
1785 handler_map["AcceptOOBEEula"] = &TestingAutomationProvider::AcceptOOBEEula;
1786 handler_map["CancelOOBEUpdate"] =
1787 &TestingAutomationProvider::CancelOOBEUpdate;
1788 handler_map["PickUserImage"] = &TestingAutomationProvider::PickUserImage;
1789 handler_map["SkipToLogin"] = &TestingAutomationProvider::SkipToLogin;
1790 handler_map["GetOOBEScreenInfo"] =
1791 &TestingAutomationProvider::GetOOBEScreenInfo;
1792
1793 handler_map["GetLoginInfo"] = &TestingAutomationProvider::GetLoginInfo;
1794 handler_map["ShowCreateAccountUI"] =
1795 &TestingAutomationProvider::ShowCreateAccountUI;
1796 handler_map["ExecuteJavascriptInOOBEWebUI"] =
1797 &TestingAutomationProvider::ExecuteJavascriptInOOBEWebUI;
1798 handler_map["LoginAsGuest"] = &TestingAutomationProvider::LoginAsGuest;
1799 handler_map["SubmitLoginForm"] = &TestingAutomationProvider::SubmitLoginForm;
1800 handler_map["AddLoginEventObserver"] =
1801 &TestingAutomationProvider::AddLoginEventObserver;
1802 handler_map["SignOut"] = &TestingAutomationProvider::SignOut;
1803
1804 handler_map["LockScreen"] = &TestingAutomationProvider::LockScreen;
1805 handler_map["UnlockScreen"] = &TestingAutomationProvider::UnlockScreen;
1806 handler_map["SignoutInScreenLocker"] =
1807 &TestingAutomationProvider::SignoutInScreenLocker;
1808
1809 handler_map["GetBatteryInfo"] = &TestingAutomationProvider::GetBatteryInfo;
1810
1811 handler_map["GetNetworkInfo"] = &TestingAutomationProvider::GetNetworkInfo;
1812 handler_map["NetworkScan"] = &TestingAutomationProvider::NetworkScan;
1813 handler_map["ToggleNetworkDevice"] =
1814 &TestingAutomationProvider::ToggleNetworkDevice;
1815 handler_map["ConnectToCellularNetwork"] =
1816 &TestingAutomationProvider::ConnectToCellularNetwork;
1817 handler_map["DisconnectFromCellularNetwork"] =
1818 &TestingAutomationProvider::DisconnectFromCellularNetwork;
1819 handler_map["ConnectToWifiNetwork"] =
1820 &TestingAutomationProvider::ConnectToWifiNetwork;
1821 handler_map["ConnectToHiddenWifiNetwork"] =
1822 &TestingAutomationProvider::ConnectToHiddenWifiNetwork;
1823 handler_map["DisconnectFromWifiNetwork"] =
1824 &TestingAutomationProvider::DisconnectFromWifiNetwork;
1825 handler_map["ForgetWifiNetwork"] =
1826 &TestingAutomationProvider::ForgetWifiNetwork;
1827
1828 handler_map["AddPrivateNetwork"] =
1829 &TestingAutomationProvider::AddPrivateNetwork;
1830 handler_map["GetPrivateNetworkInfo"] =
1831 &TestingAutomationProvider::GetPrivateNetworkInfo;
1832 handler_map["ConnectToPrivateNetwork"] =
1833 &TestingAutomationProvider::ConnectToPrivateNetwork;
1834 handler_map["DisconnectFromPrivateNetwork"] =
1835 &TestingAutomationProvider::DisconnectFromPrivateNetwork;
1836
1837 handler_map["IsEnterpriseDevice"] =
1838 &TestingAutomationProvider::IsEnterpriseDevice;
1839 handler_map["GetEnterprisePolicyInfo"] =
1840 &TestingAutomationProvider::GetEnterprisePolicyInfo;
1841 handler_map["EnrollEnterpriseDevice"] =
1842 &TestingAutomationProvider::EnrollEnterpriseDevice;
1843
1844 handler_map["EnableSpokenFeedback"] =
1845 &TestingAutomationProvider::EnableSpokenFeedback;
1846 handler_map["IsSpokenFeedbackEnabled"] =
1847 &TestingAutomationProvider::IsSpokenFeedbackEnabled;
1848
1849 handler_map["GetTimeInfo"] = &TestingAutomationProvider::GetTimeInfo;
1850 handler_map["SetTimezone"] = &TestingAutomationProvider::SetTimezone;
1851
1852 handler_map["GetUpdateInfo"] = &TestingAutomationProvider::GetUpdateInfo;
1853 handler_map["UpdateCheck"] = &TestingAutomationProvider::UpdateCheck;
1854 handler_map["SetReleaseTrack"] = &TestingAutomationProvider::SetReleaseTrack;
1855
1856 handler_map["GetVolumeInfo"] = &TestingAutomationProvider::GetVolumeInfo;
1857 handler_map["SetVolume"] = &TestingAutomationProvider::SetVolume;
1858 handler_map["SetMute"] = &TestingAutomationProvider::SetMute;
1859
1860 handler_map["OpenCrosh"] = &TestingAutomationProvider::OpenCrosh;
1861
1862 #endif // defined(OS_CHROMEOS)
1863
1864 std::map<std::string, BrowserJsonHandler> browser_handler_map;
1865 browser_handler_map["DisablePlugin"] =
1866 &TestingAutomationProvider::DisablePlugin;
1867 browser_handler_map["EnablePlugin"] =
1868 &TestingAutomationProvider::EnablePlugin;
1869 browser_handler_map["GetPluginsInfo"] =
1870 &TestingAutomationProvider::GetPluginsInfo;
1871
1872 browser_handler_map["GetNavigationInfo"] =
1873 &TestingAutomationProvider::GetNavigationInfo;
1874
1875 browser_handler_map["PerformActionOnInfobar"] =
1876 &TestingAutomationProvider::PerformActionOnInfobar;
1877
1878 browser_handler_map["GetHistoryInfo"] =
1879 &TestingAutomationProvider::GetHistoryInfo;
1880 browser_handler_map["AddHistoryItem"] =
1881 &TestingAutomationProvider::AddHistoryItem;
1882
1883 browser_handler_map["GetOmniboxInfo"] =
1884 &TestingAutomationProvider::GetOmniboxInfo;
1885 browser_handler_map["SetOmniboxText"] =
1886 &TestingAutomationProvider::SetOmniboxText;
1887 browser_handler_map["OmniboxAcceptInput"] =
1888 &TestingAutomationProvider::OmniboxAcceptInput;
1889 browser_handler_map["OmniboxMovePopupSelection"] =
1890 &TestingAutomationProvider::OmniboxMovePopupSelection;
1891
1892 browser_handler_map["GetInstantInfo"] =
1893 &TestingAutomationProvider::GetInstantInfo;
1894
1895 browser_handler_map["LoadSearchEngineInfo"] =
1896 &TestingAutomationProvider::LoadSearchEngineInfo;
1897 browser_handler_map["GetSearchEngineInfo"] =
1898 &TestingAutomationProvider::GetSearchEngineInfo;
1899 browser_handler_map["AddOrEditSearchEngine"] =
1900 &TestingAutomationProvider::AddOrEditSearchEngine;
1901 browser_handler_map["PerformActionOnSearchEngine"] =
1902 &TestingAutomationProvider::PerformActionOnSearchEngine;
1903
1904 #if defined(ENABLE_PROTECTOR_SERVICE)
1905 browser_handler_map["GetProtectorState"] =
1906 &TestingAutomationProvider::GetProtectorState;
1907 browser_handler_map["PerformProtectorAction"] =
1908 &TestingAutomationProvider::PerformProtectorAction;
1909 #endif
1910
1911 browser_handler_map["SetWindowDimensions"] =
1912 &TestingAutomationProvider::SetWindowDimensions;
1913
1914 browser_handler_map["GetDownloadsInfo"] =
1915 &TestingAutomationProvider::GetDownloadsInfo;
1916 browser_handler_map["WaitForAllDownloadsToComplete"] =
1917 &TestingAutomationProvider::WaitForAllDownloadsToComplete;
1918 browser_handler_map["PerformActionOnDownload"] =
1919 &TestingAutomationProvider::PerformActionOnDownload;
1920
1921 browser_handler_map["GetInitialLoadTimes"] =
1922 &TestingAutomationProvider::GetInitialLoadTimes;
1923
1924 browser_handler_map["SaveTabContents"] =
1925 &TestingAutomationProvider::SaveTabContents;
1926
1927 browser_handler_map["ImportSettings"] =
1928 &TestingAutomationProvider::ImportSettings;
1929
1930 browser_handler_map["AddSavedPassword"] =
1931 &TestingAutomationProvider::AddSavedPassword;
1932 browser_handler_map["RemoveSavedPassword"] =
1933 &TestingAutomationProvider::RemoveSavedPassword;
1934 browser_handler_map["GetSavedPasswords"] =
1935 &TestingAutomationProvider::GetSavedPasswords;
1936
1937 browser_handler_map["ClearBrowsingData"] =
1938 &TestingAutomationProvider::ClearBrowsingData;
1939
1940 browser_handler_map["GetBlockedPopupsInfo"] =
1941 &TestingAutomationProvider::GetBlockedPopupsInfo;
1942 browser_handler_map["UnblockAndLaunchBlockedPopup"] =
1943 &TestingAutomationProvider::UnblockAndLaunchBlockedPopup;
1944
1945 // SetTheme() implemented using InstallExtension().
1946 browser_handler_map["GetThemeInfo"] =
1947 &TestingAutomationProvider::GetThemeInfo;
1948
1949 browser_handler_map["FindInPage"] = &TestingAutomationProvider::FindInPage;
1950
1951 browser_handler_map["SelectTranslateOption"] =
1952 &TestingAutomationProvider::SelectTranslateOption;
1953 browser_handler_map["GetTranslateInfo"] =
1954 &TestingAutomationProvider::GetTranslateInfo;
1955
1956 browser_handler_map["GetAutofillProfile"] =
1957 &TestingAutomationProvider::GetAutofillProfile;
1958 browser_handler_map["FillAutofillProfile"] =
1959 &TestingAutomationProvider::FillAutofillProfile;
1960 browser_handler_map["SubmitAutofillForm"] =
1961 &TestingAutomationProvider::SubmitAutofillForm;
1962 browser_handler_map["AutofillTriggerSuggestions"] =
1963 &TestingAutomationProvider::AutofillTriggerSuggestions;
1964 browser_handler_map["AutofillHighlightSuggestion"] =
1965 &TestingAutomationProvider::AutofillHighlightSuggestion;
1966 browser_handler_map["AutofillAcceptSelection"] =
1967 &TestingAutomationProvider::AutofillAcceptSelection;
1968
1969 browser_handler_map["GetAllNotifications"] =
1970 &TestingAutomationProvider::GetAllNotifications;
1971 browser_handler_map["CloseNotification"] =
1972 &TestingAutomationProvider::CloseNotification;
1973 browser_handler_map["WaitForNotificationCount"] =
1974 &TestingAutomationProvider::WaitForNotificationCount;
1975
1976 browser_handler_map["SignInToSync"] =
1977 &TestingAutomationProvider::SignInToSync;
1978 browser_handler_map["GetSyncInfo"] = &TestingAutomationProvider::GetSyncInfo;
1979 browser_handler_map["AwaitFullSyncCompletion"] =
1980 &TestingAutomationProvider::AwaitFullSyncCompletion;
1981 browser_handler_map["AwaitSyncRestart"] =
1982 &TestingAutomationProvider::AwaitSyncRestart;
1983 browser_handler_map["EnableSyncForDatatypes"] =
1984 &TestingAutomationProvider::EnableSyncForDatatypes;
1985 browser_handler_map["DisableSyncForDatatypes"] =
1986 &TestingAutomationProvider::DisableSyncForDatatypes;
1987
1988 browser_handler_map["GetNTPInfo"] =
1989 &TestingAutomationProvider::GetNTPInfo;
1990 browser_handler_map["RemoveNTPMostVisitedThumbnail"] =
1991 &TestingAutomationProvider::RemoveNTPMostVisitedThumbnail;
1992 browser_handler_map["RestoreAllNTPMostVisitedThumbnails"] =
1993 &TestingAutomationProvider::RestoreAllNTPMostVisitedThumbnails;
1994
1995 browser_handler_map["KillRendererProcess"] =
1996 &TestingAutomationProvider::KillRendererProcess;
1997
1998 browser_handler_map["LaunchApp"] = &TestingAutomationProvider::LaunchApp;
1999 browser_handler_map["SetAppLaunchType"] =
2000 &TestingAutomationProvider::SetAppLaunchType;
2001
2002 browser_handler_map["GetV8HeapStats"] =
2003 &TestingAutomationProvider::GetV8HeapStats;
2004 browser_handler_map["GetFPS"] =
2005 &TestingAutomationProvider::GetFPS;
2006
2007 browser_handler_map["IsFullscreenForBrowser"] =
2008 &TestingAutomationProvider::IsFullscreenForBrowser;
2009 browser_handler_map["IsFullscreenForTab"] =
2010 &TestingAutomationProvider::IsFullscreenForTab;
2011 browser_handler_map["IsMouseLocked"] =
2012 &TestingAutomationProvider::IsMouseLocked;
2013 browser_handler_map["IsMouseLockPermissionRequested"] =
2014 &TestingAutomationProvider::IsMouseLockPermissionRequested;
2015 browser_handler_map["IsFullscreenPermissionRequested"] =
2016 &TestingAutomationProvider::IsFullscreenPermissionRequested;
2017 browser_handler_map["IsFullscreenBubbleDisplayed"] =
2018 &TestingAutomationProvider::IsFullscreenBubbleDisplayed;
2019 browser_handler_map["IsFullscreenBubbleDisplayingButtons"] =
2020 &TestingAutomationProvider::IsFullscreenBubbleDisplayingButtons;
2021 browser_handler_map["AcceptCurrentFullscreenOrMouseLockRequest"] =
2022 &TestingAutomationProvider::AcceptCurrentFullscreenOrMouseLockRequest;
2023 browser_handler_map["DenyCurrentFullscreenOrMouseLockRequest"] =
2024 &TestingAutomationProvider::DenyCurrentFullscreenOrMouseLockRequest;
2025
2026 #if defined(OS_CHROMEOS)
2027 browser_handler_map["CaptureProfilePhoto"] =
2028 &TestingAutomationProvider::CaptureProfilePhoto;
2029 browser_handler_map["GetTimeInfo"] = &TestingAutomationProvider::GetTimeInfo;
2030 browser_handler_map["GetProxySettings"] =
2031 &TestingAutomationProvider::GetProxySettings;
2032 browser_handler_map["SetProxySettings"] =
2033 &TestingAutomationProvider::SetProxySettings;
2034 #endif // defined(OS_CHROMEOS)
2035
2036 // Look for command in handlers that take a Browser handle.
2037 if (browser_handler_map.find(std::string(command)) !=
2038 browser_handler_map.end()) {
2039 Browser* browser = NULL;
2040 // Get Browser object associated with handle.
2041 if (!browser_tracker_->ContainsHandle(handle) ||
2042 !(browser = browser_tracker_->GetResource(handle))) {
2043 // Browser not found; attempt to fallback to non-Browser handlers.
2044 if (handler_map.find(std::string(command)) != handler_map.end())
2045 (this->*handler_map[command])(dict_value, reply_message);
2046 else
2047 AutomationJSONReply(this, reply_message).SendError(
2048 "No browser object.");
2049 } else {
2050 (this->*browser_handler_map[command])(browser, dict_value, reply_message);
2051 }
2052 // Look for command in handlers that don't take a Browser handle.
2053 } else if (handler_map.find(std::string(command)) != handler_map.end()) {
2054 (this->*handler_map[command])(dict_value, reply_message);
2055 // Command has no handlers for it.
2056 } else { 2091 } else {
2057 std::string error_string = "Unknown command. Options: "; 2092 error_string = "Unknown command. Options: ";
2058 for (std::map<std::string, JsonHandler>::const_iterator it = 2093 for (std::map<std::string, JsonHandler>::const_iterator it =
2059 handler_map.begin(); it != handler_map.end(); ++it) { 2094 handler_map_.begin(); it != handler_map_.end(); ++it) {
2060 error_string += it->first + ", "; 2095 error_string += it->first + ", ";
2061 } 2096 }
2062 for (std::map<std::string, BrowserJsonHandler>::const_iterator it = 2097 for (std::map<std::string, BrowserJsonHandler>::const_iterator it =
2063 browser_handler_map.begin(); it != browser_handler_map.end(); ++it) { 2098 browser_handler_map_.begin(); it != browser_handler_map_.end(); ++it) {
2064 error_string += it->first + ", "; 2099 error_string += it->first + ", ";
2065 } 2100 }
2066 AutomationJSONReply(this, reply_message).SendError(error_string); 2101 AutomationJSONReply(this, reply_message).SendError(error_string);
2067 } 2102 }
2068 } 2103 }
2069 2104
2070 // Sample json input: { "command": "SetWindowDimensions", 2105 // Sample json input: { "command": "SetWindowDimensions",
2071 // "x": 20, # optional 2106 // "x": 20, # optional
2072 // "y": 20, # optional 2107 // "y": 20, # optional
2073 // "width": 800, # optional 2108 // "width": 800, # optional
(...skipping 4593 matching lines...) Expand 10 before | Expand all | Expand 10 after
6667 } 6702 }
6668 6703
6669 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, 6704 void TestingAutomationProvider::EnsureTabSelected(Browser* browser,
6670 WebContents* tab) { 6705 WebContents* tab) {
6671 if (browser->GetActiveWebContents() != tab || 6706 if (browser->GetActiveWebContents() != tab ||
6672 browser != BrowserList::GetLastActive()) { 6707 browser != BrowserList::GetLastActive()) {
6673 browser->ActivateTabAt(browser->GetIndexOfController(&tab->GetController()), 6708 browser->ActivateTabAt(browser->GetIndexOfController(&tab->GetController()),
6674 true /* user_gesture */); 6709 true /* user_gesture */);
6675 } 6710 }
6676 } 6711 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698