OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 var attachedTabs = {}; | 5 var attachedTabs = {}; |
6 var version = "1.0"; | 6 var version = "1.0"; |
7 | 7 |
8 chrome.debugger.onEvent.addListener(onEvent); | 8 chrome.debugger.onEvent.addListener(onEvent); |
9 chrome.debugger.onDetach.addListener(onDetach); | 9 chrome.debugger.onDetach.addListener(onDetach); |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 if (attachedTabs[tabId] == "pausing") | 21 if (attachedTabs[tabId] == "pausing") |
22 return; | 22 return; |
23 | 23 |
24 if (!attachedTabs[tabId]) | 24 if (!attachedTabs[tabId]) |
25 chrome.debugger.attach(debuggeeId, version, onAttach.bind(null, debuggeeId))
; | 25 chrome.debugger.attach(debuggeeId, version, onAttach.bind(null, debuggeeId))
; |
26 else if (attachedTabs[tabId]) | 26 else if (attachedTabs[tabId]) |
27 chrome.debugger.detach(debuggeeId, onDetach.bind(null, debuggeeId)); | 27 chrome.debugger.detach(debuggeeId, onDetach.bind(null, debuggeeId)); |
28 } | 28 } |
29 | 29 |
30 function onAttach(debuggeeId) { | 30 function onAttach(debuggeeId) { |
31 if (chrome.extension.lastError) { | 31 if (chrome.runtime.lastError) { |
32 alert(chrome.extension.lastError.message); | 32 alert(chrome.runtime.lastError.message); |
33 return; | 33 return; |
34 } | 34 } |
35 | 35 |
36 var tabId = debuggeeId.tabId; | 36 var tabId = debuggeeId.tabId; |
37 chrome.browserAction.setIcon({tabId: tabId, path:"debuggerPausing.png"}); | 37 chrome.browserAction.setIcon({tabId: tabId, path:"debuggerPausing.png"}); |
38 chrome.browserAction.setTitle({tabId: tabId, title:"Pausing JavaScript"}); | 38 chrome.browserAction.setTitle({tabId: tabId, title:"Pausing JavaScript"}); |
39 attachedTabs[tabId] = "pausing"; | 39 attachedTabs[tabId] = "pausing"; |
40 chrome.debugger.sendCommand( | 40 chrome.debugger.sendCommand( |
41 debuggeeId, "Debugger.enable", {}, | 41 debuggeeId, "Debugger.enable", {}, |
42 onDebuggerEnabled.bind(null, debuggeeId)); | 42 onDebuggerEnabled.bind(null, debuggeeId)); |
(...skipping 11 matching lines...) Expand all Loading... |
54 chrome.browserAction.setTitle({tabId:tabId, title:"Resume JavaScript"}); | 54 chrome.browserAction.setTitle({tabId:tabId, title:"Resume JavaScript"}); |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
58 function onDetach(debuggeeId) { | 58 function onDetach(debuggeeId) { |
59 var tabId = debuggeeId.tabId; | 59 var tabId = debuggeeId.tabId; |
60 delete attachedTabs[tabId]; | 60 delete attachedTabs[tabId]; |
61 chrome.browserAction.setIcon({tabId:tabId, path:"debuggerPause.png"}); | 61 chrome.browserAction.setIcon({tabId:tabId, path:"debuggerPause.png"}); |
62 chrome.browserAction.setTitle({tabId:tabId, title:"Pause JavaScript"}); | 62 chrome.browserAction.setTitle({tabId:tabId, title:"Pause JavaScript"}); |
63 } | 63 } |
OLD | NEW |