diff options
author | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-26 08:46:30 +0000 |
---|---|---|
committer | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-26 08:46:30 +0000 |
commit | c7580b6cc34348be847fe5f82f4ddb14f2c40a66 (patch) | |
tree | ab71659b600ff2e5e9eb004abe9c9a29a155fa09 /chrome/common/extensions/docs/examples/api/debugger/pause-resume | |
parent | 488e14bf4ff59f70efc1d2ebf39cf9c8391387e5 (diff) | |
download | chromium_src-c7580b6cc34348be847fe5f82f4ddb14f2c40a66.zip chromium_src-c7580b6cc34348be847fe5f82f4ddb14f2c40a66.tar.gz chromium_src-c7580b6cc34348be847fe5f82f4ddb14f2c40a66.tar.bz2 |
DevTools: extend experimental.debugger API to potentially allow non-tab debuggees.
This change migrates from
attach(tabId, ...) syntax to the
attach({tabId:tabId}, ...) as suggested during the extension API review.
BUG=
TEST=
Review URL: http://codereview.chromium.org/8341017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107316 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/docs/examples/api/debugger/pause-resume')
-rw-r--r-- | chrome/common/extensions/docs/examples/api/debugger/pause-resume/background.html | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/chrome/common/extensions/docs/examples/api/debugger/pause-resume/background.html b/chrome/common/extensions/docs/examples/api/debugger/pause-resume/background.html index 2b26a76..51b684a 100644 --- a/chrome/common/extensions/docs/examples/api/debugger/pause-resume/background.html +++ b/chrome/common/extensions/docs/examples/api/debugger/pause-resume/background.html @@ -9,6 +9,7 @@ found in the LICENSE file. <script> var attachedTabs = {}; +var version = "0.1"; chrome.experimental.debugger.onEvent.addListener(onEvent); chrome.experimental.debugger.onDetach.addListener(onDetach); @@ -21,45 +22,50 @@ chrome.browserAction.onClicked.addListener(function() { function actionClicked(tab) { var tabId = tab.id; - if (attachedTabs[tabId] === "pausing") + var debuggeeId = {tabId:tabId}; + + if (attachedTabs[tabId] == "pausing") return; if (!attachedTabs[tabId]) - chrome.experimental.debugger.attach(tabId, onAttach.bind(null, tabId)); + chrome.experimental.debugger.attach(debuggeeId, version, onAttach.bind(null, debuggeeId)); else if (attachedTabs[tabId]) - chrome.experimental.debugger.detach(tabId, onDetach.bind(null, tabId)); + chrome.experimental.debugger.detach(debuggeeId, onDetach.bind(null, debuggeeId)); } -function onAttach(tabId) { +function onAttach(debuggeeId) { if (chrome.extension.lastError) { alert("Another debugger is already attached to this tab."); return; } + var tabId = debuggeeId.tabId; chrome.browserAction.setIcon({tabId: tabId, path:"debuggerPausing.png"}); chrome.browserAction.setTitle({tabId: tabId, title:"Pausing JavaScript"}); attachedTabs[tabId] = "pausing"; - chrome.experimental.debugger.sendRequest( - tabId, "Debugger.enable", {}, - onDebuggerEnabled.bind(null, tabId)); + chrome.experimental.debugger.sendCommand( + debuggeeId, "Debugger.enable", {}, + onDebuggerEnabled.bind(null, debuggeeId)); } -function onDebuggerEnabled(tabId) { - chrome.experimental.debugger.sendRequest(tabId, "Debugger.pause"); +function onDebuggerEnabled(debuggeeId) { + chrome.experimental.debugger.sendCommand(debuggeeId, "Debugger.pause"); } -function onEvent(tabId, method) { - if (method === "Debugger.paused") { +function onEvent(debuggeeId, method) { + var tabId = debuggeeId.tabId; + if (method == "Debugger.paused") { attachedTabs[tabId] = "paused"; - chrome.browserAction.setIcon({tabId: tabId, path:"debuggerContinue.png"}); - chrome.browserAction.setTitle({tabId: tabId, title:"Resume JavaScript"}); + chrome.browserAction.setIcon({tabId:tabId, path:"debuggerContinue.png"}); + chrome.browserAction.setTitle({tabId:tabId, title:"Resume JavaScript"}); } } -function onDetach(tabId) { +function onDetach(debuggeeId) { + var tabId = debuggeeId.tabId; delete attachedTabs[tabId]; - chrome.browserAction.setIcon({tabId: tabId, path:"debuggerPause.png"}); - chrome.browserAction.setTitle({tabId: tabId, title:"Pause JavaScript"}); + chrome.browserAction.setIcon({tabId:tabId, path:"debuggerPause.png"}); + chrome.browserAction.setTitle({tabId:tabId, title:"Pause JavaScript"}); } </script> |