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

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

Powered by Google App Engine
This is Rietveld 408576698