| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 AutomationMsg_WaitForBrowserWindowCountToBecome, | 435 AutomationMsg_WaitForBrowserWindowCountToBecome, |
| 436 WaitForBrowserWindowCountToBecome) | 436 WaitForBrowserWindowCountToBecome) |
| 437 IPC_MESSAGE_HANDLER_DELAY_REPLY( | 437 IPC_MESSAGE_HANDLER_DELAY_REPLY( |
| 438 AutomationMsg_GoBackBlockUntilNavigationsComplete, | 438 AutomationMsg_GoBackBlockUntilNavigationsComplete, |
| 439 GoBackBlockUntilNavigationsComplete) | 439 GoBackBlockUntilNavigationsComplete) |
| 440 IPC_MESSAGE_HANDLER_DELAY_REPLY( | 440 IPC_MESSAGE_HANDLER_DELAY_REPLY( |
| 441 AutomationMsg_GoForwardBlockUntilNavigationsComplete, | 441 AutomationMsg_GoForwardBlockUntilNavigationsComplete, |
| 442 GoForwardBlockUntilNavigationsComplete) | 442 GoForwardBlockUntilNavigationsComplete) |
| 443 IPC_MESSAGE_HANDLER(AutomationMsg_SetShelfVisibility, SetShelfVisibility) | 443 IPC_MESSAGE_HANDLER(AutomationMsg_SetShelfVisibility, SetShelfVisibility) |
| 444 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_SendJSONRequest, | 444 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_SendJSONRequest, |
| 445 SendJSONRequest) | 445 SendJSONRequestWithBrowserIndex) |
| 446 IPC_MESSAGE_HANDLER_DELAY_REPLY( |
| 447 AutomationMsg_SendJSONRequestWithBrowserHandle, |
| 448 SendJSONRequestWithBrowserHandle) |
| 446 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForTabCountToBecome, | 449 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForTabCountToBecome, |
| 447 WaitForTabCountToBecome) | 450 WaitForTabCountToBecome) |
| 448 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForInfoBarCount, | 451 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForInfoBarCount, |
| 449 WaitForInfoBarCount) | 452 WaitForInfoBarCount) |
| 450 IPC_MESSAGE_HANDLER(AutomationMsg_ResetToDefaultTheme, ResetToDefaultTheme) | 453 IPC_MESSAGE_HANDLER(AutomationMsg_ResetToDefaultTheme, ResetToDefaultTheme) |
| 451 IPC_MESSAGE_HANDLER_DELAY_REPLY( | 454 IPC_MESSAGE_HANDLER_DELAY_REPLY( |
| 452 AutomationMsg_WaitForProcessLauncherThreadToGoIdle, | 455 AutomationMsg_WaitForProcessLauncherThreadToGoIdle, |
| 453 WaitForProcessLauncherThreadToGoIdle) | 456 WaitForProcessLauncherThreadToGoIdle) |
| 454 | 457 |
| 455 IPC_MESSAGE_UNHANDLED( | 458 IPC_MESSAGE_UNHANDLED( |
| (...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1658 Browser* browser = browser_tracker_->GetResource(handle); | 1661 Browser* browser = browser_tracker_->GetResource(handle); |
| 1659 if (browser) { | 1662 if (browser) { |
| 1660 if (visible) | 1663 if (visible) |
| 1661 browser->window()->GetDownloadShelf()->Show(); | 1664 browser->window()->GetDownloadShelf()->Show(); |
| 1662 else | 1665 else |
| 1663 browser->window()->GetDownloadShelf()->Close(); | 1666 browser->window()->GetDownloadShelf()->Close(); |
| 1664 } | 1667 } |
| 1665 } | 1668 } |
| 1666 } | 1669 } |
| 1667 | 1670 |
| 1668 void TestingAutomationProvider::SendJSONRequest(int handle, | 1671 void TestingAutomationProvider::BuildJSONHandlerMaps() { |
| 1672 // Map json commands to their handlers. |
| 1673 handler_map_["WaitForAllTabsToStopLoading"] = |
| 1674 &TestingAutomationProvider::WaitForAllViewsToStopLoading; |
| 1675 handler_map_["GetIndicesFromTab"] = |
| 1676 &TestingAutomationProvider::GetIndicesFromTab; |
| 1677 handler_map_["NavigateToURL"] = |
| 1678 &TestingAutomationProvider::NavigateToURL; |
| 1679 handler_map_["WaitUntilNavigationCompletes"] = |
| 1680 &TestingAutomationProvider::WaitUntilNavigationCompletes; |
| 1681 handler_map_["GetLocalStatePrefsInfo"] = |
| 1682 &TestingAutomationProvider::GetLocalStatePrefsInfo; |
| 1683 handler_map_["SetLocalStatePrefs"] = |
| 1684 &TestingAutomationProvider::SetLocalStatePrefs; |
| 1685 handler_map_["GetPrefsInfo"] = &TestingAutomationProvider::GetPrefsInfo; |
| 1686 handler_map_["SetPrefs"] = &TestingAutomationProvider::SetPrefs; |
| 1687 handler_map_["ExecuteJavascript"] = |
| 1688 &TestingAutomationProvider::ExecuteJavascriptJSON; |
| 1689 handler_map_["AddDomEventObserver"] = |
| 1690 &TestingAutomationProvider::AddDomEventObserver; |
| 1691 handler_map_["RemoveEventObserver"] = |
| 1692 &TestingAutomationProvider::RemoveEventObserver; |
| 1693 handler_map_["GetNextEvent"] = |
| 1694 &TestingAutomationProvider::GetNextEvent; |
| 1695 handler_map_["ClearEventQueue"] = |
| 1696 &TestingAutomationProvider::ClearEventQueue; |
| 1697 handler_map_["ExecuteJavascriptInRenderView"] = |
| 1698 &TestingAutomationProvider::ExecuteJavascriptInRenderView; |
| 1699 handler_map_["GoForward"] = |
| 1700 &TestingAutomationProvider::GoForward; |
| 1701 handler_map_["GoBack"] = |
| 1702 &TestingAutomationProvider::GoBack; |
| 1703 handler_map_["Reload"] = |
| 1704 &TestingAutomationProvider::ReloadJSON; |
| 1705 handler_map_["CaptureEntirePage"] = |
| 1706 &TestingAutomationProvider::CaptureEntirePageJSON; |
| 1707 handler_map_["GetCookies"] = |
| 1708 &TestingAutomationProvider::GetCookiesJSON; |
| 1709 handler_map_["DeleteCookie"] = |
| 1710 &TestingAutomationProvider::DeleteCookieJSON; |
| 1711 handler_map_["SetCookie"] = |
| 1712 &TestingAutomationProvider::SetCookieJSON; |
| 1713 handler_map_["GetTabIds"] = |
| 1714 &TestingAutomationProvider::GetTabIds; |
| 1715 handler_map_["GetViews"] = |
| 1716 &TestingAutomationProvider::GetViews; |
| 1717 handler_map_["IsTabIdValid"] = |
| 1718 &TestingAutomationProvider::IsTabIdValid; |
| 1719 handler_map_["DoesAutomationObjectExist"] = |
| 1720 &TestingAutomationProvider::DoesAutomationObjectExist; |
| 1721 handler_map_["CloseTab"] = |
| 1722 &TestingAutomationProvider::CloseTabJSON; |
| 1723 handler_map_["SetViewBounds"] = |
| 1724 &TestingAutomationProvider::SetViewBounds; |
| 1725 handler_map_["MaximizeView"] = |
| 1726 &TestingAutomationProvider::MaximizeView; |
| 1727 handler_map_["WebkitMouseMove"] = |
| 1728 &TestingAutomationProvider::WebkitMouseMove; |
| 1729 handler_map_["WebkitMouseClick"] = |
| 1730 &TestingAutomationProvider::WebkitMouseClick; |
| 1731 handler_map_["WebkitMouseDrag"] = |
| 1732 &TestingAutomationProvider::WebkitMouseDrag; |
| 1733 handler_map_["WebkitMouseButtonUp"] = |
| 1734 &TestingAutomationProvider::WebkitMouseButtonUp; |
| 1735 handler_map_["WebkitMouseButtonDown"] = |
| 1736 &TestingAutomationProvider::WebkitMouseButtonDown; |
| 1737 handler_map_["WebkitMouseDoubleClick"] = |
| 1738 &TestingAutomationProvider::WebkitMouseDoubleClick; |
| 1739 handler_map_["DragAndDropFilePaths"] = |
| 1740 &TestingAutomationProvider::DragAndDropFilePaths; |
| 1741 handler_map_["SendWebkitKeyEvent"] = |
| 1742 &TestingAutomationProvider::SendWebkitKeyEvent; |
| 1743 handler_map_["SendOSLevelKeyEventToTab"] = |
| 1744 &TestingAutomationProvider::SendOSLevelKeyEventToTab; |
| 1745 handler_map_["ProcessWebMouseEvent"] = |
| 1746 &TestingAutomationProvider::ProcessWebMouseEvent; |
| 1747 handler_map_["ActivateTab"] = |
| 1748 &TestingAutomationProvider::ActivateTabJSON; |
| 1749 handler_map_["GetAppModalDialogMessage"] = |
| 1750 &TestingAutomationProvider::GetAppModalDialogMessage; |
| 1751 handler_map_["AcceptOrDismissAppModalDialog"] = |
| 1752 &TestingAutomationProvider::AcceptOrDismissAppModalDialog; |
| 1753 handler_map_["GetChromeDriverAutomationVersion"] = |
| 1754 &TestingAutomationProvider::GetChromeDriverAutomationVersion; |
| 1755 handler_map_["IsPageActionVisible"] = |
| 1756 &TestingAutomationProvider::IsPageActionVisible; |
| 1757 handler_map_["CreateNewAutomationProvider"] = |
| 1758 &TestingAutomationProvider::CreateNewAutomationProvider; |
| 1759 handler_map_["GetBrowserInfo"] = |
| 1760 &TestingAutomationProvider::GetBrowserInfo; |
| 1761 handler_map_["OpenNewBrowserWindowWithNewProfile"] = |
| 1762 &TestingAutomationProvider::OpenNewBrowserWindowWithNewProfile; |
| 1763 handler_map_["GetMultiProfileInfo"] = |
| 1764 &TestingAutomationProvider::GetMultiProfileInfo; |
| 1765 handler_map_["OpenProfileWindow"] = |
| 1766 &TestingAutomationProvider::OpenProfileWindow; |
| 1767 handler_map_["GetProcessInfo"] = |
| 1768 &TestingAutomationProvider::GetProcessInfo; |
| 1769 handler_map_["GetPolicyDefinitionList"] = |
| 1770 &TestingAutomationProvider::GetPolicyDefinitionList; |
| 1771 handler_map_["RefreshPolicies"] = |
| 1772 &TestingAutomationProvider::RefreshPolicies; |
| 1773 handler_map_["InstallExtension"] = |
| 1774 &TestingAutomationProvider::InstallExtension; |
| 1775 handler_map_["GetExtensionsInfo"] = |
| 1776 &TestingAutomationProvider::GetExtensionsInfo; |
| 1777 handler_map_["UninstallExtensionById"] = |
| 1778 &TestingAutomationProvider::UninstallExtensionById; |
| 1779 handler_map_["SetExtensionStateById"] = |
| 1780 &TestingAutomationProvider::SetExtensionStateById; |
| 1781 handler_map_["TriggerPageActionById"] = |
| 1782 &TestingAutomationProvider::TriggerPageActionById; |
| 1783 handler_map_["TriggerBrowserActionById"] = |
| 1784 &TestingAutomationProvider::TriggerBrowserActionById; |
| 1785 handler_map_["UpdateExtensionsNow"] = |
| 1786 &TestingAutomationProvider::UpdateExtensionsNow; |
| 1787 #if !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS)) |
| 1788 handler_map_["HeapProfilerDump"] = |
| 1789 &TestingAutomationProvider::HeapProfilerDump; |
| 1790 #endif // !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS)) |
| 1791 handler_map_["OverrideGeoposition"] = |
| 1792 &TestingAutomationProvider::OverrideGeoposition; |
| 1793 handler_map_["AppendSwitchASCIIToCommandLine"] = |
| 1794 &TestingAutomationProvider::AppendSwitchASCIIToCommandLine; |
| 1795 handler_map_["SimulateAsanMemoryBug"] = |
| 1796 &TestingAutomationProvider::SimulateAsanMemoryBug; |
| 1797 |
| 1798 #if defined(OS_CHROMEOS) |
| 1799 handler_map_["AcceptOOBENetworkScreen"] = |
| 1800 &TestingAutomationProvider::AcceptOOBENetworkScreen; |
| 1801 handler_map_["AcceptOOBEEula"] = &TestingAutomationProvider::AcceptOOBEEula; |
| 1802 handler_map_["CancelOOBEUpdate"] = |
| 1803 &TestingAutomationProvider::CancelOOBEUpdate; |
| 1804 handler_map_["PickUserImage"] = &TestingAutomationProvider::PickUserImage; |
| 1805 handler_map_["SkipToLogin"] = &TestingAutomationProvider::SkipToLogin; |
| 1806 handler_map_["GetOOBEScreenInfo"] = |
| 1807 &TestingAutomationProvider::GetOOBEScreenInfo; |
| 1808 |
| 1809 handler_map_["GetLoginInfo"] = &TestingAutomationProvider::GetLoginInfo; |
| 1810 handler_map_["ShowCreateAccountUI"] = |
| 1811 &TestingAutomationProvider::ShowCreateAccountUI; |
| 1812 handler_map_["ExecuteJavascriptInOOBEWebUI"] = |
| 1813 &TestingAutomationProvider::ExecuteJavascriptInOOBEWebUI; |
| 1814 handler_map_["LoginAsGuest"] = &TestingAutomationProvider::LoginAsGuest; |
| 1815 handler_map_["SubmitLoginForm"] = |
| 1816 &TestingAutomationProvider::SubmitLoginForm; |
| 1817 handler_map_["AddLoginEventObserver"] = |
| 1818 &TestingAutomationProvider::AddLoginEventObserver; |
| 1819 handler_map_["SignOut"] = &TestingAutomationProvider::SignOut; |
| 1820 |
| 1821 handler_map_["LockScreen"] = &TestingAutomationProvider::LockScreen; |
| 1822 handler_map_["UnlockScreen"] = &TestingAutomationProvider::UnlockScreen; |
| 1823 handler_map_["SignoutInScreenLocker"] = |
| 1824 &TestingAutomationProvider::SignoutInScreenLocker; |
| 1825 |
| 1826 handler_map_["GetBatteryInfo"] = &TestingAutomationProvider::GetBatteryInfo; |
| 1827 |
| 1828 handler_map_["GetNetworkInfo"] = &TestingAutomationProvider::GetNetworkInfo; |
| 1829 handler_map_["NetworkScan"] = &TestingAutomationProvider::NetworkScan; |
| 1830 handler_map_["ToggleNetworkDevice"] = |
| 1831 &TestingAutomationProvider::ToggleNetworkDevice; |
| 1832 handler_map_["ConnectToCellularNetwork"] = |
| 1833 &TestingAutomationProvider::ConnectToCellularNetwork; |
| 1834 handler_map_["DisconnectFromCellularNetwork"] = |
| 1835 &TestingAutomationProvider::DisconnectFromCellularNetwork; |
| 1836 handler_map_["ConnectToWifiNetwork"] = |
| 1837 &TestingAutomationProvider::ConnectToWifiNetwork; |
| 1838 handler_map_["ConnectToHiddenWifiNetwork"] = |
| 1839 &TestingAutomationProvider::ConnectToHiddenWifiNetwork; |
| 1840 handler_map_["DisconnectFromWifiNetwork"] = |
| 1841 &TestingAutomationProvider::DisconnectFromWifiNetwork; |
| 1842 handler_map_["ForgetWifiNetwork"] = |
| 1843 &TestingAutomationProvider::ForgetWifiNetwork; |
| 1844 |
| 1845 handler_map_["AddPrivateNetwork"] = |
| 1846 &TestingAutomationProvider::AddPrivateNetwork; |
| 1847 handler_map_["GetPrivateNetworkInfo"] = |
| 1848 &TestingAutomationProvider::GetPrivateNetworkInfo; |
| 1849 handler_map_["ConnectToPrivateNetwork"] = |
| 1850 &TestingAutomationProvider::ConnectToPrivateNetwork; |
| 1851 handler_map_["DisconnectFromPrivateNetwork"] = |
| 1852 &TestingAutomationProvider::DisconnectFromPrivateNetwork; |
| 1853 |
| 1854 handler_map_["IsEnterpriseDevice"] = |
| 1855 &TestingAutomationProvider::IsEnterpriseDevice; |
| 1856 handler_map_["GetEnterprisePolicyInfo"] = |
| 1857 &TestingAutomationProvider::GetEnterprisePolicyInfo; |
| 1858 handler_map_["EnrollEnterpriseDevice"] = |
| 1859 &TestingAutomationProvider::EnrollEnterpriseDevice; |
| 1860 |
| 1861 handler_map_["EnableSpokenFeedback"] = |
| 1862 &TestingAutomationProvider::EnableSpokenFeedback; |
| 1863 handler_map_["IsSpokenFeedbackEnabled"] = |
| 1864 &TestingAutomationProvider::IsSpokenFeedbackEnabled; |
| 1865 |
| 1866 handler_map_["GetTimeInfo"] = &TestingAutomationProvider::GetTimeInfo; |
| 1867 handler_map_["SetTimezone"] = &TestingAutomationProvider::SetTimezone; |
| 1868 |
| 1869 handler_map_["GetUpdateInfo"] = &TestingAutomationProvider::GetUpdateInfo; |
| 1870 handler_map_["UpdateCheck"] = &TestingAutomationProvider::UpdateCheck; |
| 1871 handler_map_["SetReleaseTrack"] = |
| 1872 &TestingAutomationProvider::SetReleaseTrack; |
| 1873 |
| 1874 handler_map_["GetVolumeInfo"] = &TestingAutomationProvider::GetVolumeInfo; |
| 1875 handler_map_["SetVolume"] = &TestingAutomationProvider::SetVolume; |
| 1876 handler_map_["SetMute"] = &TestingAutomationProvider::SetMute; |
| 1877 |
| 1878 handler_map_["OpenCrosh"] = &TestingAutomationProvider::OpenCrosh; |
| 1879 |
| 1880 #endif // defined(OS_CHROMEOS) |
| 1881 |
| 1882 browser_handler_map_["DisablePlugin"] = |
| 1883 &TestingAutomationProvider::DisablePlugin; |
| 1884 browser_handler_map_["EnablePlugin"] = |
| 1885 &TestingAutomationProvider::EnablePlugin; |
| 1886 browser_handler_map_["GetPluginsInfo"] = |
| 1887 &TestingAutomationProvider::GetPluginsInfo; |
| 1888 |
| 1889 browser_handler_map_["GetNavigationInfo"] = |
| 1890 &TestingAutomationProvider::GetNavigationInfo; |
| 1891 |
| 1892 browser_handler_map_["PerformActionOnInfobar"] = |
| 1893 &TestingAutomationProvider::PerformActionOnInfobar; |
| 1894 |
| 1895 browser_handler_map_["GetHistoryInfo"] = |
| 1896 &TestingAutomationProvider::GetHistoryInfo; |
| 1897 browser_handler_map_["AddHistoryItem"] = |
| 1898 &TestingAutomationProvider::AddHistoryItem; |
| 1899 |
| 1900 browser_handler_map_["GetOmniboxInfo"] = |
| 1901 &TestingAutomationProvider::GetOmniboxInfo; |
| 1902 browser_handler_map_["SetOmniboxText"] = |
| 1903 &TestingAutomationProvider::SetOmniboxText; |
| 1904 browser_handler_map_["OmniboxAcceptInput"] = |
| 1905 &TestingAutomationProvider::OmniboxAcceptInput; |
| 1906 browser_handler_map_["OmniboxMovePopupSelection"] = |
| 1907 &TestingAutomationProvider::OmniboxMovePopupSelection; |
| 1908 |
| 1909 browser_handler_map_["GetInstantInfo"] = |
| 1910 &TestingAutomationProvider::GetInstantInfo; |
| 1911 |
| 1912 browser_handler_map_["LoadSearchEngineInfo"] = |
| 1913 &TestingAutomationProvider::LoadSearchEngineInfo; |
| 1914 browser_handler_map_["GetSearchEngineInfo"] = |
| 1915 &TestingAutomationProvider::GetSearchEngineInfo; |
| 1916 browser_handler_map_["AddOrEditSearchEngine"] = |
| 1917 &TestingAutomationProvider::AddOrEditSearchEngine; |
| 1918 browser_handler_map_["PerformActionOnSearchEngine"] = |
| 1919 &TestingAutomationProvider::PerformActionOnSearchEngine; |
| 1920 |
| 1921 #if defined(ENABLE_PROTECTOR_SERVICE) |
| 1922 browser_handler_map_["GetProtectorState"] = |
| 1923 &TestingAutomationProvider::GetProtectorState; |
| 1924 browser_handler_map_["PerformProtectorAction"] = |
| 1925 &TestingAutomationProvider::PerformProtectorAction; |
| 1926 #endif |
| 1927 |
| 1928 browser_handler_map_["SetWindowDimensions"] = |
| 1929 &TestingAutomationProvider::SetWindowDimensions; |
| 1930 |
| 1931 browser_handler_map_["GetDownloadsInfo"] = |
| 1932 &TestingAutomationProvider::GetDownloadsInfo; |
| 1933 browser_handler_map_["WaitForAllDownloadsToComplete"] = |
| 1934 &TestingAutomationProvider::WaitForAllDownloadsToComplete; |
| 1935 browser_handler_map_["PerformActionOnDownload"] = |
| 1936 &TestingAutomationProvider::PerformActionOnDownload; |
| 1937 |
| 1938 browser_handler_map_["GetInitialLoadTimes"] = |
| 1939 &TestingAutomationProvider::GetInitialLoadTimes; |
| 1940 |
| 1941 browser_handler_map_["SaveTabContents"] = |
| 1942 &TestingAutomationProvider::SaveTabContents; |
| 1943 |
| 1944 browser_handler_map_["ImportSettings"] = |
| 1945 &TestingAutomationProvider::ImportSettings; |
| 1946 |
| 1947 browser_handler_map_["AddSavedPassword"] = |
| 1948 &TestingAutomationProvider::AddSavedPassword; |
| 1949 browser_handler_map_["RemoveSavedPassword"] = |
| 1950 &TestingAutomationProvider::RemoveSavedPassword; |
| 1951 browser_handler_map_["GetSavedPasswords"] = |
| 1952 &TestingAutomationProvider::GetSavedPasswords; |
| 1953 |
| 1954 browser_handler_map_["ClearBrowsingData"] = |
| 1955 &TestingAutomationProvider::ClearBrowsingData; |
| 1956 |
| 1957 browser_handler_map_["GetBlockedPopupsInfo"] = |
| 1958 &TestingAutomationProvider::GetBlockedPopupsInfo; |
| 1959 browser_handler_map_["UnblockAndLaunchBlockedPopup"] = |
| 1960 &TestingAutomationProvider::UnblockAndLaunchBlockedPopup; |
| 1961 |
| 1962 // SetTheme() implemented using InstallExtension(). |
| 1963 browser_handler_map_["GetThemeInfo"] = |
| 1964 &TestingAutomationProvider::GetThemeInfo; |
| 1965 |
| 1966 browser_handler_map_["FindInPage"] = &TestingAutomationProvider::FindInPage; |
| 1967 |
| 1968 browser_handler_map_["SelectTranslateOption"] = |
| 1969 &TestingAutomationProvider::SelectTranslateOption; |
| 1970 browser_handler_map_["GetTranslateInfo"] = |
| 1971 &TestingAutomationProvider::GetTranslateInfo; |
| 1972 |
| 1973 browser_handler_map_["GetAutofillProfile"] = |
| 1974 &TestingAutomationProvider::GetAutofillProfile; |
| 1975 browser_handler_map_["FillAutofillProfile"] = |
| 1976 &TestingAutomationProvider::FillAutofillProfile; |
| 1977 browser_handler_map_["SubmitAutofillForm"] = |
| 1978 &TestingAutomationProvider::SubmitAutofillForm; |
| 1979 browser_handler_map_["AutofillTriggerSuggestions"] = |
| 1980 &TestingAutomationProvider::AutofillTriggerSuggestions; |
| 1981 browser_handler_map_["AutofillHighlightSuggestion"] = |
| 1982 &TestingAutomationProvider::AutofillHighlightSuggestion; |
| 1983 browser_handler_map_["AutofillAcceptSelection"] = |
| 1984 &TestingAutomationProvider::AutofillAcceptSelection; |
| 1985 |
| 1986 browser_handler_map_["GetAllNotifications"] = |
| 1987 &TestingAutomationProvider::GetAllNotifications; |
| 1988 browser_handler_map_["CloseNotification"] = |
| 1989 &TestingAutomationProvider::CloseNotification; |
| 1990 browser_handler_map_["WaitForNotificationCount"] = |
| 1991 &TestingAutomationProvider::WaitForNotificationCount; |
| 1992 |
| 1993 browser_handler_map_["SignInToSync"] = |
| 1994 &TestingAutomationProvider::SignInToSync; |
| 1995 browser_handler_map_["GetSyncInfo"] = |
| 1996 &TestingAutomationProvider::GetSyncInfo; |
| 1997 browser_handler_map_["AwaitFullSyncCompletion"] = |
| 1998 &TestingAutomationProvider::AwaitFullSyncCompletion; |
| 1999 browser_handler_map_["AwaitSyncRestart"] = |
| 2000 &TestingAutomationProvider::AwaitSyncRestart; |
| 2001 browser_handler_map_["EnableSyncForDatatypes"] = |
| 2002 &TestingAutomationProvider::EnableSyncForDatatypes; |
| 2003 browser_handler_map_["DisableSyncForDatatypes"] = |
| 2004 &TestingAutomationProvider::DisableSyncForDatatypes; |
| 2005 |
| 2006 browser_handler_map_["GetNTPInfo"] = |
| 2007 &TestingAutomationProvider::GetNTPInfo; |
| 2008 browser_handler_map_["RemoveNTPMostVisitedThumbnail"] = |
| 2009 &TestingAutomationProvider::RemoveNTPMostVisitedThumbnail; |
| 2010 browser_handler_map_["RestoreAllNTPMostVisitedThumbnails"] = |
| 2011 &TestingAutomationProvider::RestoreAllNTPMostVisitedThumbnails; |
| 2012 |
| 2013 browser_handler_map_["KillRendererProcess"] = |
| 2014 &TestingAutomationProvider::KillRendererProcess; |
| 2015 |
| 2016 browser_handler_map_["LaunchApp"] = &TestingAutomationProvider::LaunchApp; |
| 2017 browser_handler_map_["SetAppLaunchType"] = |
| 2018 &TestingAutomationProvider::SetAppLaunchType; |
| 2019 |
| 2020 browser_handler_map_["GetV8HeapStats"] = |
| 2021 &TestingAutomationProvider::GetV8HeapStats; |
| 2022 browser_handler_map_["GetFPS"] = |
| 2023 &TestingAutomationProvider::GetFPS; |
| 2024 |
| 2025 browser_handler_map_["IsFullscreenForBrowser"] = |
| 2026 &TestingAutomationProvider::IsFullscreenForBrowser; |
| 2027 browser_handler_map_["IsFullscreenForTab"] = |
| 2028 &TestingAutomationProvider::IsFullscreenForTab; |
| 2029 browser_handler_map_["IsMouseLocked"] = |
| 2030 &TestingAutomationProvider::IsMouseLocked; |
| 2031 browser_handler_map_["IsMouseLockPermissionRequested"] = |
| 2032 &TestingAutomationProvider::IsMouseLockPermissionRequested; |
| 2033 browser_handler_map_["IsFullscreenPermissionRequested"] = |
| 2034 &TestingAutomationProvider::IsFullscreenPermissionRequested; |
| 2035 browser_handler_map_["IsFullscreenBubbleDisplayed"] = |
| 2036 &TestingAutomationProvider::IsFullscreenBubbleDisplayed; |
| 2037 browser_handler_map_["IsFullscreenBubbleDisplayingButtons"] = |
| 2038 &TestingAutomationProvider::IsFullscreenBubbleDisplayingButtons; |
| 2039 browser_handler_map_["AcceptCurrentFullscreenOrMouseLockRequest"] = |
| 2040 &TestingAutomationProvider::AcceptCurrentFullscreenOrMouseLockRequest; |
| 2041 browser_handler_map_["DenyCurrentFullscreenOrMouseLockRequest"] = |
| 2042 &TestingAutomationProvider::DenyCurrentFullscreenOrMouseLockRequest; |
| 2043 |
| 2044 #if defined(OS_CHROMEOS) |
| 2045 browser_handler_map_["CaptureProfilePhoto"] = |
| 2046 &TestingAutomationProvider::CaptureProfilePhoto; |
| 2047 browser_handler_map_["GetTimeInfo"] = |
| 2048 &TestingAutomationProvider::GetTimeInfo; |
| 2049 browser_handler_map_["GetProxySettings"] = |
| 2050 &TestingAutomationProvider::GetProxySettings; |
| 2051 browser_handler_map_["SetProxySettings"] = |
| 2052 &TestingAutomationProvider::SetProxySettings; |
| 2053 #endif // defined(OS_CHROMEOS) |
| 2054 } |
| 2055 |
| 2056 scoped_ptr<DictionaryValue> TestingAutomationProvider::ParseJSONRequestCommand( |
| 2057 const std::string& json_request, |
| 2058 std::string* command, |
| 2059 std::string* error) { |
| 2060 scoped_ptr<DictionaryValue> dict_value; |
| 2061 scoped_ptr<Value> values(base::JSONReader::ReadAndReturnError(json_request, |
| 2062 base::JSON_ALLOW_TRAILING_COMMAS, NULL, error)); |
| 2063 if (values.get()) { |
| 2064 // Make sure input is a dict with a string command. |
| 2065 if (values->GetType() != Value::TYPE_DICTIONARY) { |
| 2066 *error = "Command dictionary is not a dictionary."; |
| 2067 } else { |
| 2068 dict_value.reset(static_cast<DictionaryValue*>(values.release())); |
| 2069 if (!dict_value->GetStringASCII("command", command)) { |
| 2070 *error = "Command key string missing from dictionary."; |
| 2071 dict_value.reset(NULL); |
| 2072 } |
| 2073 } |
| 2074 } |
| 2075 return dict_value.Pass(); |
| 2076 } |
| 2077 |
| 2078 void TestingAutomationProvider::SendJSONRequestWithBrowserHandle( |
| 2079 int handle, |
| 2080 const std::string& json_request, |
| 2081 IPC::Message* reply_message) { |
| 2082 Browser* browser = NULL; |
| 2083 if (browser_tracker_->ContainsHandle(handle)) |
| 2084 browser = browser_tracker_->GetResource(handle); |
| 2085 if (browser || handle < 0) { |
| 2086 SendJSONRequest(browser, json_request, reply_message); |
| 2087 } else { |
| 2088 AutomationJSONReply(this, reply_message).SendError( |
| 2089 "The browser window does not exist."); |
| 2090 } |
| 2091 } |
| 2092 |
| 2093 void TestingAutomationProvider::SendJSONRequestWithBrowserIndex( |
| 2094 int index, |
| 2095 const std::string& json_request, |
| 2096 IPC::Message* reply_message) { |
| 2097 Browser* browser = index < 0 ? NULL : automation_util::GetBrowserAt(index); |
| 2098 if (!browser && index >= 0) { |
| 2099 AutomationJSONReply(this, reply_message).SendError( |
| 2100 StringPrintf("Browser window with index=%d does not exist.", index)); |
| 2101 } else { |
| 2102 SendJSONRequest(browser, json_request, reply_message); |
| 2103 } |
| 2104 } |
| 2105 |
| 2106 void TestingAutomationProvider::SendJSONRequest(Browser* browser, |
| 1669 const std::string& json_request, | 2107 const std::string& json_request, |
| 1670 IPC::Message* reply_message) { | 2108 IPC::Message* reply_message) { |
| 1671 std::string error; | 2109 std::string command, error_string; |
| 1672 scoped_ptr<Value> values(base::JSONReader::ReadAndReturnError(json_request, | 2110 scoped_ptr<DictionaryValue> dict_value( |
| 1673 base::JSON_ALLOW_TRAILING_COMMAS, NULL, &error)); | 2111 ParseJSONRequestCommand(json_request, &command, &error_string)); |
| 1674 if (!error.empty()) { | 2112 if (!dict_value.get() || command.empty()) { |
| 1675 AutomationJSONReply(this, reply_message).SendError(error); | 2113 AutomationJSONReply(this, reply_message).SendError(error_string); |
| 1676 return; | 2114 return; |
| 1677 } | 2115 } |
| 1678 | 2116 |
| 1679 // Make sure input is a dict with a string command. | 2117 if (handler_map_.empty() || browser_handler_map_.empty()) |
| 1680 std::string command; | 2118 BuildJSONHandlerMaps(); |
| 1681 DictionaryValue* dict_value = NULL; | 2119 |
| 1682 if (values->GetType() != Value::TYPE_DICTIONARY) { | 2120 // Look for command in handlers that take a Browser. |
| 1683 AutomationJSONReply(this, reply_message).SendError("not a dict"); | 2121 if (browser_handler_map_.find(std::string(command)) != |
| 1684 return; | 2122 browser_handler_map_.end() && browser) { |
| 1685 } | 2123 (this->*browser_handler_map_[command])(browser, dict_value.get(), |
| 1686 // Ownership remains with "values" variable. | 2124 reply_message); |
| 1687 dict_value = static_cast<DictionaryValue*>(values.get()); | 2125 // Look for command in handlers that don't take a Browser. |
| 1688 if (!dict_value->GetStringASCII(std::string("command"), &command)) { | 2126 } else if (handler_map_.find(std::string(command)) != handler_map_.end()) { |
| 1689 AutomationJSONReply(this, reply_message) | 2127 (this->*handler_map_[command])(dict_value.get(), reply_message); |
| 1690 .SendError("no command key in dict or not a string command"); | 2128 // Command has no handler. |
| 1691 return; | |
| 1692 } | |
| 1693 | |
| 1694 // Map json commands to their handlers. | |
| 1695 std::map<std::string, JsonHandler> handler_map; | |
| 1696 handler_map["WaitForAllTabsToStopLoading"] = | |
| 1697 &TestingAutomationProvider::WaitForAllViewsToStopLoading; | |
| 1698 handler_map["GetIndicesFromTab"] = | |
| 1699 &TestingAutomationProvider::GetIndicesFromTab; | |
| 1700 handler_map["NavigateToURL"] = | |
| 1701 &TestingAutomationProvider::NavigateToURL; | |
| 1702 handler_map["WaitUntilNavigationCompletes"] = | |
| 1703 &TestingAutomationProvider::WaitUntilNavigationCompletes; | |
| 1704 handler_map["GetLocalStatePrefsInfo"] = | |
| 1705 &TestingAutomationProvider::GetLocalStatePrefsInfo; | |
| 1706 handler_map["SetLocalStatePrefs"] = | |
| 1707 &TestingAutomationProvider::SetLocalStatePrefs; | |
| 1708 handler_map["GetPrefsInfo"] = &TestingAutomationProvider::GetPrefsInfo; | |
| 1709 handler_map["SetPrefs"] = &TestingAutomationProvider::SetPrefs; | |
| 1710 handler_map["ExecuteJavascript"] = | |
| 1711 &TestingAutomationProvider::ExecuteJavascriptJSON; | |
| 1712 handler_map["AddDomEventObserver"] = | |
| 1713 &TestingAutomationProvider::AddDomEventObserver; | |
| 1714 handler_map["RemoveEventObserver"] = | |
| 1715 &TestingAutomationProvider::RemoveEventObserver; | |
| 1716 handler_map["GetNextEvent"] = | |
| 1717 &TestingAutomationProvider::GetNextEvent; | |
| 1718 handler_map["ClearEventQueue"] = | |
| 1719 &TestingAutomationProvider::ClearEventQueue; | |
| 1720 handler_map["ExecuteJavascriptInRenderView"] = | |
| 1721 &TestingAutomationProvider::ExecuteJavascriptInRenderView; | |
| 1722 handler_map["GoForward"] = | |
| 1723 &TestingAutomationProvider::GoForward; | |
| 1724 handler_map["GoBack"] = | |
| 1725 &TestingAutomationProvider::GoBack; | |
| 1726 handler_map["Reload"] = | |
| 1727 &TestingAutomationProvider::ReloadJSON; | |
| 1728 handler_map["CaptureEntirePage"] = | |
| 1729 &TestingAutomationProvider::CaptureEntirePageJSON; | |
| 1730 handler_map["GetCookies"] = | |
| 1731 &TestingAutomationProvider::GetCookiesJSON; | |
| 1732 handler_map["DeleteCookie"] = | |
| 1733 &TestingAutomationProvider::DeleteCookieJSON; | |
| 1734 handler_map["SetCookie"] = | |
| 1735 &TestingAutomationProvider::SetCookieJSON; | |
| 1736 handler_map["GetTabIds"] = | |
| 1737 &TestingAutomationProvider::GetTabIds; | |
| 1738 handler_map["GetViews"] = | |
| 1739 &TestingAutomationProvider::GetViews; | |
| 1740 handler_map["IsTabIdValid"] = | |
| 1741 &TestingAutomationProvider::IsTabIdValid; | |
| 1742 handler_map["DoesAutomationObjectExist"] = | |
| 1743 &TestingAutomationProvider::DoesAutomationObjectExist; | |
| 1744 handler_map["CloseTab"] = | |
| 1745 &TestingAutomationProvider::CloseTabJSON; | |
| 1746 handler_map["SetViewBounds"] = | |
| 1747 &TestingAutomationProvider::SetViewBounds; | |
| 1748 handler_map["MaximizeView"] = | |
| 1749 &TestingAutomationProvider::MaximizeView; | |
| 1750 handler_map["WebkitMouseMove"] = | |
| 1751 &TestingAutomationProvider::WebkitMouseMove; | |
| 1752 handler_map["WebkitMouseClick"] = | |
| 1753 &TestingAutomationProvider::WebkitMouseClick; | |
| 1754 handler_map["WebkitMouseDrag"] = | |
| 1755 &TestingAutomationProvider::WebkitMouseDrag; | |
| 1756 handler_map["WebkitMouseButtonUp"] = | |
| 1757 &TestingAutomationProvider::WebkitMouseButtonUp; | |
| 1758 handler_map["WebkitMouseButtonDown"] = | |
| 1759 &TestingAutomationProvider::WebkitMouseButtonDown; | |
| 1760 handler_map["WebkitMouseDoubleClick"] = | |
| 1761 &TestingAutomationProvider::WebkitMouseDoubleClick; | |
| 1762 handler_map["DragAndDropFilePaths"] = | |
| 1763 &TestingAutomationProvider::DragAndDropFilePaths; | |
| 1764 handler_map["SendWebkitKeyEvent"] = | |
| 1765 &TestingAutomationProvider::SendWebkitKeyEvent; | |
| 1766 handler_map["SendOSLevelKeyEventToTab"] = | |
| 1767 &TestingAutomationProvider::SendOSLevelKeyEventToTab; | |
| 1768 handler_map["ProcessWebMouseEvent"] = | |
| 1769 &TestingAutomationProvider::ProcessWebMouseEvent; | |
| 1770 handler_map["ActivateTab"] = | |
| 1771 &TestingAutomationProvider::ActivateTabJSON; | |
| 1772 handler_map["GetAppModalDialogMessage"] = | |
| 1773 &TestingAutomationProvider::GetAppModalDialogMessage; | |
| 1774 handler_map["AcceptOrDismissAppModalDialog"] = | |
| 1775 &TestingAutomationProvider::AcceptOrDismissAppModalDialog; | |
| 1776 handler_map["GetChromeDriverAutomationVersion"] = | |
| 1777 &TestingAutomationProvider::GetChromeDriverAutomationVersion; | |
| 1778 handler_map["IsPageActionVisible"] = | |
| 1779 &TestingAutomationProvider::IsPageActionVisible; | |
| 1780 handler_map["CreateNewAutomationProvider"] = | |
| 1781 &TestingAutomationProvider::CreateNewAutomationProvider; | |
| 1782 handler_map["GetBrowserInfo"] = | |
| 1783 &TestingAutomationProvider::GetBrowserInfo; | |
| 1784 handler_map["OpenNewBrowserWindowWithNewProfile"] = | |
| 1785 &TestingAutomationProvider::OpenNewBrowserWindowWithNewProfile; | |
| 1786 handler_map["GetMultiProfileInfo"] = | |
| 1787 &TestingAutomationProvider::GetMultiProfileInfo; | |
| 1788 handler_map["OpenProfileWindow"] = | |
| 1789 &TestingAutomationProvider::OpenProfileWindow; | |
| 1790 handler_map["GetProcessInfo"] = | |
| 1791 &TestingAutomationProvider::GetProcessInfo; | |
| 1792 handler_map["GetPolicyDefinitionList"] = | |
| 1793 &TestingAutomationProvider::GetPolicyDefinitionList; | |
| 1794 handler_map["RefreshPolicies"] = | |
| 1795 &TestingAutomationProvider::RefreshPolicies; | |
| 1796 handler_map["InstallExtension"] = | |
| 1797 &TestingAutomationProvider::InstallExtension; | |
| 1798 handler_map["GetExtensionsInfo"] = | |
| 1799 &TestingAutomationProvider::GetExtensionsInfo; | |
| 1800 handler_map["UninstallExtensionById"] = | |
| 1801 &TestingAutomationProvider::UninstallExtensionById; | |
| 1802 handler_map["SetExtensionStateById"] = | |
| 1803 &TestingAutomationProvider::SetExtensionStateById; | |
| 1804 handler_map["TriggerPageActionById"] = | |
| 1805 &TestingAutomationProvider::TriggerPageActionById; | |
| 1806 handler_map["TriggerBrowserActionById"] = | |
| 1807 &TestingAutomationProvider::TriggerBrowserActionById; | |
| 1808 handler_map["UpdateExtensionsNow"] = | |
| 1809 &TestingAutomationProvider::UpdateExtensionsNow; | |
| 1810 #if !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS)) | |
| 1811 handler_map["HeapProfilerDump"] = | |
| 1812 &TestingAutomationProvider::HeapProfilerDump; | |
| 1813 #endif // !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS)) | |
| 1814 handler_map["OverrideGeoposition"] = | |
| 1815 &TestingAutomationProvider::OverrideGeoposition; | |
| 1816 handler_map["AppendSwitchASCIIToCommandLine"] = | |
| 1817 &TestingAutomationProvider::AppendSwitchASCIIToCommandLine; | |
| 1818 handler_map["SimulateAsanMemoryBug"] = | |
| 1819 &TestingAutomationProvider::SimulateAsanMemoryBug; | |
| 1820 | |
| 1821 #if defined(OS_CHROMEOS) | |
| 1822 handler_map["AcceptOOBENetworkScreen"] = | |
| 1823 &TestingAutomationProvider::AcceptOOBENetworkScreen; | |
| 1824 handler_map["AcceptOOBEEula"] = &TestingAutomationProvider::AcceptOOBEEula; | |
| 1825 handler_map["CancelOOBEUpdate"] = | |
| 1826 &TestingAutomationProvider::CancelOOBEUpdate; | |
| 1827 handler_map["PickUserImage"] = &TestingAutomationProvider::PickUserImage; | |
| 1828 handler_map["SkipToLogin"] = &TestingAutomationProvider::SkipToLogin; | |
| 1829 handler_map["GetOOBEScreenInfo"] = | |
| 1830 &TestingAutomationProvider::GetOOBEScreenInfo; | |
| 1831 | |
| 1832 handler_map["GetLoginInfo"] = &TestingAutomationProvider::GetLoginInfo; | |
| 1833 handler_map["ShowCreateAccountUI"] = | |
| 1834 &TestingAutomationProvider::ShowCreateAccountUI; | |
| 1835 handler_map["ExecuteJavascriptInOOBEWebUI"] = | |
| 1836 &TestingAutomationProvider::ExecuteJavascriptInOOBEWebUI; | |
| 1837 handler_map["LoginAsGuest"] = &TestingAutomationProvider::LoginAsGuest; | |
| 1838 handler_map["SubmitLoginForm"] = &TestingAutomationProvider::SubmitLoginForm; | |
| 1839 handler_map["AddLoginEventObserver"] = | |
| 1840 &TestingAutomationProvider::AddLoginEventObserver; | |
| 1841 handler_map["SignOut"] = &TestingAutomationProvider::SignOut; | |
| 1842 | |
| 1843 handler_map["LockScreen"] = &TestingAutomationProvider::LockScreen; | |
| 1844 handler_map["UnlockScreen"] = &TestingAutomationProvider::UnlockScreen; | |
| 1845 handler_map["SignoutInScreenLocker"] = | |
| 1846 &TestingAutomationProvider::SignoutInScreenLocker; | |
| 1847 | |
| 1848 handler_map["GetBatteryInfo"] = &TestingAutomationProvider::GetBatteryInfo; | |
| 1849 | |
| 1850 handler_map["GetNetworkInfo"] = &TestingAutomationProvider::GetNetworkInfo; | |
| 1851 handler_map["NetworkScan"] = &TestingAutomationProvider::NetworkScan; | |
| 1852 handler_map["ToggleNetworkDevice"] = | |
| 1853 &TestingAutomationProvider::ToggleNetworkDevice; | |
| 1854 handler_map["ConnectToCellularNetwork"] = | |
| 1855 &TestingAutomationProvider::ConnectToCellularNetwork; | |
| 1856 handler_map["DisconnectFromCellularNetwork"] = | |
| 1857 &TestingAutomationProvider::DisconnectFromCellularNetwork; | |
| 1858 handler_map["ConnectToWifiNetwork"] = | |
| 1859 &TestingAutomationProvider::ConnectToWifiNetwork; | |
| 1860 handler_map["ConnectToHiddenWifiNetwork"] = | |
| 1861 &TestingAutomationProvider::ConnectToHiddenWifiNetwork; | |
| 1862 handler_map["DisconnectFromWifiNetwork"] = | |
| 1863 &TestingAutomationProvider::DisconnectFromWifiNetwork; | |
| 1864 handler_map["ForgetWifiNetwork"] = | |
| 1865 &TestingAutomationProvider::ForgetWifiNetwork; | |
| 1866 | |
| 1867 handler_map["AddPrivateNetwork"] = | |
| 1868 &TestingAutomationProvider::AddPrivateNetwork; | |
| 1869 handler_map["GetPrivateNetworkInfo"] = | |
| 1870 &TestingAutomationProvider::GetPrivateNetworkInfo; | |
| 1871 handler_map["ConnectToPrivateNetwork"] = | |
| 1872 &TestingAutomationProvider::ConnectToPrivateNetwork; | |
| 1873 handler_map["DisconnectFromPrivateNetwork"] = | |
| 1874 &TestingAutomationProvider::DisconnectFromPrivateNetwork; | |
| 1875 | |
| 1876 handler_map["IsEnterpriseDevice"] = | |
| 1877 &TestingAutomationProvider::IsEnterpriseDevice; | |
| 1878 handler_map["GetEnterprisePolicyInfo"] = | |
| 1879 &TestingAutomationProvider::GetEnterprisePolicyInfo; | |
| 1880 handler_map["EnrollEnterpriseDevice"] = | |
| 1881 &TestingAutomationProvider::EnrollEnterpriseDevice; | |
| 1882 | |
| 1883 handler_map["EnableSpokenFeedback"] = | |
| 1884 &TestingAutomationProvider::EnableSpokenFeedback; | |
| 1885 handler_map["IsSpokenFeedbackEnabled"] = | |
| 1886 &TestingAutomationProvider::IsSpokenFeedbackEnabled; | |
| 1887 | |
| 1888 handler_map["GetTimeInfo"] = &TestingAutomationProvider::GetTimeInfo; | |
| 1889 handler_map["SetTimezone"] = &TestingAutomationProvider::SetTimezone; | |
| 1890 | |
| 1891 handler_map["GetUpdateInfo"] = &TestingAutomationProvider::GetUpdateInfo; | |
| 1892 handler_map["UpdateCheck"] = &TestingAutomationProvider::UpdateCheck; | |
| 1893 handler_map["SetReleaseTrack"] = &TestingAutomationProvider::SetReleaseTrack; | |
| 1894 | |
| 1895 handler_map["GetVolumeInfo"] = &TestingAutomationProvider::GetVolumeInfo; | |
| 1896 handler_map["SetVolume"] = &TestingAutomationProvider::SetVolume; | |
| 1897 handler_map["SetMute"] = &TestingAutomationProvider::SetMute; | |
| 1898 | |
| 1899 handler_map["OpenCrosh"] = &TestingAutomationProvider::OpenCrosh; | |
| 1900 | |
| 1901 #endif // defined(OS_CHROMEOS) | |
| 1902 | |
| 1903 std::map<std::string, BrowserJsonHandler> browser_handler_map; | |
| 1904 browser_handler_map["DisablePlugin"] = | |
| 1905 &TestingAutomationProvider::DisablePlugin; | |
| 1906 browser_handler_map["EnablePlugin"] = | |
| 1907 &TestingAutomationProvider::EnablePlugin; | |
| 1908 browser_handler_map["GetPluginsInfo"] = | |
| 1909 &TestingAutomationProvider::GetPluginsInfo; | |
| 1910 | |
| 1911 browser_handler_map["GetNavigationInfo"] = | |
| 1912 &TestingAutomationProvider::GetNavigationInfo; | |
| 1913 | |
| 1914 browser_handler_map["PerformActionOnInfobar"] = | |
| 1915 &TestingAutomationProvider::PerformActionOnInfobar; | |
| 1916 | |
| 1917 browser_handler_map["GetHistoryInfo"] = | |
| 1918 &TestingAutomationProvider::GetHistoryInfo; | |
| 1919 browser_handler_map["AddHistoryItem"] = | |
| 1920 &TestingAutomationProvider::AddHistoryItem; | |
| 1921 | |
| 1922 browser_handler_map["GetOmniboxInfo"] = | |
| 1923 &TestingAutomationProvider::GetOmniboxInfo; | |
| 1924 browser_handler_map["SetOmniboxText"] = | |
| 1925 &TestingAutomationProvider::SetOmniboxText; | |
| 1926 browser_handler_map["OmniboxAcceptInput"] = | |
| 1927 &TestingAutomationProvider::OmniboxAcceptInput; | |
| 1928 browser_handler_map["OmniboxMovePopupSelection"] = | |
| 1929 &TestingAutomationProvider::OmniboxMovePopupSelection; | |
| 1930 | |
| 1931 browser_handler_map["GetInstantInfo"] = | |
| 1932 &TestingAutomationProvider::GetInstantInfo; | |
| 1933 | |
| 1934 browser_handler_map["LoadSearchEngineInfo"] = | |
| 1935 &TestingAutomationProvider::LoadSearchEngineInfo; | |
| 1936 browser_handler_map["GetSearchEngineInfo"] = | |
| 1937 &TestingAutomationProvider::GetSearchEngineInfo; | |
| 1938 browser_handler_map["AddOrEditSearchEngine"] = | |
| 1939 &TestingAutomationProvider::AddOrEditSearchEngine; | |
| 1940 browser_handler_map["PerformActionOnSearchEngine"] = | |
| 1941 &TestingAutomationProvider::PerformActionOnSearchEngine; | |
| 1942 | |
| 1943 #if defined(ENABLE_PROTECTOR_SERVICE) | |
| 1944 browser_handler_map["GetProtectorState"] = | |
| 1945 &TestingAutomationProvider::GetProtectorState; | |
| 1946 browser_handler_map["PerformProtectorAction"] = | |
| 1947 &TestingAutomationProvider::PerformProtectorAction; | |
| 1948 #endif | |
| 1949 | |
| 1950 browser_handler_map["SetWindowDimensions"] = | |
| 1951 &TestingAutomationProvider::SetWindowDimensions; | |
| 1952 | |
| 1953 browser_handler_map["GetDownloadsInfo"] = | |
| 1954 &TestingAutomationProvider::GetDownloadsInfo; | |
| 1955 browser_handler_map["WaitForAllDownloadsToComplete"] = | |
| 1956 &TestingAutomationProvider::WaitForAllDownloadsToComplete; | |
| 1957 browser_handler_map["PerformActionOnDownload"] = | |
| 1958 &TestingAutomationProvider::PerformActionOnDownload; | |
| 1959 | |
| 1960 browser_handler_map["GetInitialLoadTimes"] = | |
| 1961 &TestingAutomationProvider::GetInitialLoadTimes; | |
| 1962 | |
| 1963 browser_handler_map["SaveTabContents"] = | |
| 1964 &TestingAutomationProvider::SaveTabContents; | |
| 1965 | |
| 1966 browser_handler_map["ImportSettings"] = | |
| 1967 &TestingAutomationProvider::ImportSettings; | |
| 1968 | |
| 1969 browser_handler_map["AddSavedPassword"] = | |
| 1970 &TestingAutomationProvider::AddSavedPassword; | |
| 1971 browser_handler_map["RemoveSavedPassword"] = | |
| 1972 &TestingAutomationProvider::RemoveSavedPassword; | |
| 1973 browser_handler_map["GetSavedPasswords"] = | |
| 1974 &TestingAutomationProvider::GetSavedPasswords; | |
| 1975 | |
| 1976 browser_handler_map["ClearBrowsingData"] = | |
| 1977 &TestingAutomationProvider::ClearBrowsingData; | |
| 1978 | |
| 1979 browser_handler_map["GetBlockedPopupsInfo"] = | |
| 1980 &TestingAutomationProvider::GetBlockedPopupsInfo; | |
| 1981 browser_handler_map["UnblockAndLaunchBlockedPopup"] = | |
| 1982 &TestingAutomationProvider::UnblockAndLaunchBlockedPopup; | |
| 1983 | |
| 1984 // SetTheme() implemented using InstallExtension(). | |
| 1985 browser_handler_map["GetThemeInfo"] = | |
| 1986 &TestingAutomationProvider::GetThemeInfo; | |
| 1987 | |
| 1988 browser_handler_map["FindInPage"] = &TestingAutomationProvider::FindInPage; | |
| 1989 | |
| 1990 browser_handler_map["SelectTranslateOption"] = | |
| 1991 &TestingAutomationProvider::SelectTranslateOption; | |
| 1992 browser_handler_map["GetTranslateInfo"] = | |
| 1993 &TestingAutomationProvider::GetTranslateInfo; | |
| 1994 | |
| 1995 browser_handler_map["GetAutofillProfile"] = | |
| 1996 &TestingAutomationProvider::GetAutofillProfile; | |
| 1997 browser_handler_map["FillAutofillProfile"] = | |
| 1998 &TestingAutomationProvider::FillAutofillProfile; | |
| 1999 browser_handler_map["SubmitAutofillForm"] = | |
| 2000 &TestingAutomationProvider::SubmitAutofillForm; | |
| 2001 browser_handler_map["AutofillTriggerSuggestions"] = | |
| 2002 &TestingAutomationProvider::AutofillTriggerSuggestions; | |
| 2003 browser_handler_map["AutofillHighlightSuggestion"] = | |
| 2004 &TestingAutomationProvider::AutofillHighlightSuggestion; | |
| 2005 browser_handler_map["AutofillAcceptSelection"] = | |
| 2006 &TestingAutomationProvider::AutofillAcceptSelection; | |
| 2007 | |
| 2008 browser_handler_map["GetAllNotifications"] = | |
| 2009 &TestingAutomationProvider::GetAllNotifications; | |
| 2010 browser_handler_map["CloseNotification"] = | |
| 2011 &TestingAutomationProvider::CloseNotification; | |
| 2012 browser_handler_map["WaitForNotificationCount"] = | |
| 2013 &TestingAutomationProvider::WaitForNotificationCount; | |
| 2014 | |
| 2015 browser_handler_map["SignInToSync"] = | |
| 2016 &TestingAutomationProvider::SignInToSync; | |
| 2017 browser_handler_map["GetSyncInfo"] = &TestingAutomationProvider::GetSyncInfo; | |
| 2018 browser_handler_map["AwaitFullSyncCompletion"] = | |
| 2019 &TestingAutomationProvider::AwaitFullSyncCompletion; | |
| 2020 browser_handler_map["AwaitSyncRestart"] = | |
| 2021 &TestingAutomationProvider::AwaitSyncRestart; | |
| 2022 browser_handler_map["EnableSyncForDatatypes"] = | |
| 2023 &TestingAutomationProvider::EnableSyncForDatatypes; | |
| 2024 browser_handler_map["DisableSyncForDatatypes"] = | |
| 2025 &TestingAutomationProvider::DisableSyncForDatatypes; | |
| 2026 | |
| 2027 browser_handler_map["GetNTPInfo"] = | |
| 2028 &TestingAutomationProvider::GetNTPInfo; | |
| 2029 browser_handler_map["RemoveNTPMostVisitedThumbnail"] = | |
| 2030 &TestingAutomationProvider::RemoveNTPMostVisitedThumbnail; | |
| 2031 browser_handler_map["RestoreAllNTPMostVisitedThumbnails"] = | |
| 2032 &TestingAutomationProvider::RestoreAllNTPMostVisitedThumbnails; | |
| 2033 | |
| 2034 browser_handler_map["KillRendererProcess"] = | |
| 2035 &TestingAutomationProvider::KillRendererProcess; | |
| 2036 | |
| 2037 browser_handler_map["LaunchApp"] = &TestingAutomationProvider::LaunchApp; | |
| 2038 browser_handler_map["SetAppLaunchType"] = | |
| 2039 &TestingAutomationProvider::SetAppLaunchType; | |
| 2040 | |
| 2041 browser_handler_map["GetV8HeapStats"] = | |
| 2042 &TestingAutomationProvider::GetV8HeapStats; | |
| 2043 browser_handler_map["GetFPS"] = | |
| 2044 &TestingAutomationProvider::GetFPS; | |
| 2045 | |
| 2046 browser_handler_map["IsFullscreenForBrowser"] = | |
| 2047 &TestingAutomationProvider::IsFullscreenForBrowser; | |
| 2048 browser_handler_map["IsFullscreenForTab"] = | |
| 2049 &TestingAutomationProvider::IsFullscreenForTab; | |
| 2050 browser_handler_map["IsMouseLocked"] = | |
| 2051 &TestingAutomationProvider::IsMouseLocked; | |
| 2052 browser_handler_map["IsMouseLockPermissionRequested"] = | |
| 2053 &TestingAutomationProvider::IsMouseLockPermissionRequested; | |
| 2054 browser_handler_map["IsFullscreenPermissionRequested"] = | |
| 2055 &TestingAutomationProvider::IsFullscreenPermissionRequested; | |
| 2056 browser_handler_map["IsFullscreenBubbleDisplayed"] = | |
| 2057 &TestingAutomationProvider::IsFullscreenBubbleDisplayed; | |
| 2058 browser_handler_map["IsFullscreenBubbleDisplayingButtons"] = | |
| 2059 &TestingAutomationProvider::IsFullscreenBubbleDisplayingButtons; | |
| 2060 browser_handler_map["AcceptCurrentFullscreenOrMouseLockRequest"] = | |
| 2061 &TestingAutomationProvider::AcceptCurrentFullscreenOrMouseLockRequest; | |
| 2062 browser_handler_map["DenyCurrentFullscreenOrMouseLockRequest"] = | |
| 2063 &TestingAutomationProvider::DenyCurrentFullscreenOrMouseLockRequest; | |
| 2064 | |
| 2065 #if defined(OS_CHROMEOS) | |
| 2066 browser_handler_map["CaptureProfilePhoto"] = | |
| 2067 &TestingAutomationProvider::CaptureProfilePhoto; | |
| 2068 browser_handler_map["GetTimeInfo"] = &TestingAutomationProvider::GetTimeInfo; | |
| 2069 browser_handler_map["GetProxySettings"] = | |
| 2070 &TestingAutomationProvider::GetProxySettings; | |
| 2071 browser_handler_map["SetProxySettings"] = | |
| 2072 &TestingAutomationProvider::SetProxySettings; | |
| 2073 #endif // defined(OS_CHROMEOS) | |
| 2074 | |
| 2075 // Look for command in handlers that take a Browser handle. | |
| 2076 if (browser_handler_map.find(std::string(command)) != | |
| 2077 browser_handler_map.end()) { | |
| 2078 Browser* browser = NULL; | |
| 2079 // Get Browser object associated with handle. | |
| 2080 if (!browser_tracker_->ContainsHandle(handle) || | |
| 2081 !(browser = browser_tracker_->GetResource(handle))) { | |
| 2082 // Browser not found; attempt to fallback to non-Browser handlers. | |
| 2083 if (handler_map.find(std::string(command)) != handler_map.end()) | |
| 2084 (this->*handler_map[command])(dict_value, reply_message); | |
| 2085 else | |
| 2086 AutomationJSONReply(this, reply_message).SendError( | |
| 2087 "No browser object."); | |
| 2088 } else { | |
| 2089 (this->*browser_handler_map[command])(browser, dict_value, reply_message); | |
| 2090 } | |
| 2091 // Look for command in handlers that don't take a Browser handle. | |
| 2092 } else if (handler_map.find(std::string(command)) != handler_map.end()) { | |
| 2093 (this->*handler_map[command])(dict_value, reply_message); | |
| 2094 // Command has no handlers for it. | |
| 2095 } else { | 2129 } else { |
| 2096 std::string error_string = "Unknown command. Options: "; | 2130 error_string = "Unknown command. Options: "; |
| 2097 for (std::map<std::string, JsonHandler>::const_iterator it = | 2131 for (std::map<std::string, JsonHandler>::const_iterator it = |
| 2098 handler_map.begin(); it != handler_map.end(); ++it) { | 2132 handler_map_.begin(); it != handler_map_.end(); ++it) { |
| 2099 error_string += it->first + ", "; | 2133 error_string += it->first + ", "; |
| 2100 } | 2134 } |
| 2101 for (std::map<std::string, BrowserJsonHandler>::const_iterator it = | 2135 for (std::map<std::string, BrowserJsonHandler>::const_iterator it = |
| 2102 browser_handler_map.begin(); it != browser_handler_map.end(); ++it) { | 2136 browser_handler_map_.begin(); it != browser_handler_map_.end(); ++it) { |
| 2103 error_string += it->first + ", "; | 2137 error_string += it->first + ", "; |
| 2104 } | 2138 } |
| 2105 AutomationJSONReply(this, reply_message).SendError(error_string); | 2139 AutomationJSONReply(this, reply_message).SendError(error_string); |
| 2106 } | 2140 } |
| 2107 } | 2141 } |
| 2108 | 2142 |
| 2109 // Sample json input: { "command": "SetWindowDimensions", | 2143 // Sample json input: { "command": "SetWindowDimensions", |
| 2110 // "x": 20, # optional | 2144 // "x": 20, # optional |
| 2111 // "y": 20, # optional | 2145 // "y": 20, # optional |
| 2112 // "width": 800, # optional | 2146 // "width": 800, # optional |
| (...skipping 4622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6735 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6769 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
| 6736 } | 6770 } |
| 6737 | 6771 |
| 6738 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 6772 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
| 6739 WebContents* tab) { | 6773 WebContents* tab) { |
| 6740 if (browser->GetActiveWebContents() != tab) { | 6774 if (browser->GetActiveWebContents() != tab) { |
| 6741 browser->ActivateTabAt(browser->GetIndexOfController( | 6775 browser->ActivateTabAt(browser->GetIndexOfController( |
| 6742 &tab->GetController()), true); | 6776 &tab->GetController()), true); |
| 6743 } | 6777 } |
| 6744 } | 6778 } |
| OLD | NEW |