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

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

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

Powered by Google App Engine
This is Rietveld 408576698