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

Side by Side Diff: inspector/front-end/InjectedScriptAccess.js

Issue 542055: DevTools: injected script per context(WebCore part) (Closed) Base URL: http://svn.webkit.org/repository/webkit/trunk/WebCore/
Patch Set: '' Created 10 years, 11 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
« no previous file with comments | « inspector/front-end/InjectedScript.js ('k') | inspector/front-end/MetricsSidebarPane.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2009 Joseph Pecoraro 3 * Copyright (C) 2009 Joseph Pecoraro
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 11 matching lines...) Expand all
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32 var InjectedScriptAccess = {}; 32 function InjectedScriptAccess(injectedScriptId) {
33 this._injectedScriptId = injectedScriptId;
34 }
35
36 InjectedScriptAccess.get = function(injectedScriptId)
37 {
38 return new InjectedScriptAccess(injectedScriptId);
39 }
40
41 InjectedScriptAccess.getDefault = function()
42 {
43 return InjectedScriptAccess.get(0);
44 }
45
46 InjectedScriptAccess.prototype = {};
33 47
34 InjectedScriptAccess._installHandler = function(methodName, async) 48 InjectedScriptAccess._installHandler = function(methodName, async)
35 { 49 {
36 InjectedScriptAccess[methodName] = function() 50 InjectedScriptAccess.prototype[methodName] = function()
37 { 51 {
38 var allArgs = Array.prototype.slice.call(arguments); 52 var allArgs = Array.prototype.slice.call(arguments);
39 var callback = allArgs[allArgs.length - 1]; 53 var callback = allArgs[allArgs.length - 1];
40 var argsString = JSON.stringify(Array.prototype.slice.call(allArgs, 0, a llArgs.length - 1)); 54 var argsString = JSON.stringify(Array.prototype.slice.call(allArgs, 0, a llArgs.length - 1));
41 55
42 function myCallback(result, isException) 56 function myCallback(result, isException)
43 { 57 {
44 if (!isException) 58 if (!isException)
45 callback(JSON.parse(result)); 59 callback(JSON.parse(result));
46 else 60 else
47 WebInspector.console.addMessage(new WebInspector.ConsoleTextMess age("Error dispatching: " + methodName)); 61 WebInspector.console.addMessage(new WebInspector.ConsoleTextMess age("Error dispatching: " + methodName));
48 } 62 }
49 var callId = WebInspector.Callback.wrap(myCallback); 63 var callId = WebInspector.Callback.wrap(myCallback);
50 InspectorBackend.dispatchOnInjectedScript(callId, methodName, argsString , !!async); 64
65 InspectorBackend.dispatchOnInjectedScript(callId, this._injectedScriptId , methodName, argsString, !!async);
51 }; 66 };
52 } 67 }
53 68
54 // InjectedScriptAccess message forwarding puts some constraints on the way meth ods are implemented and called: 69 // InjectedScriptAccess message forwarding puts some constraints on the way meth ods are implemented and called:
55 // - Make sure corresponding methods in InjectedScript return non-null and non-u ndefined values, 70 // - Make sure corresponding methods in InjectedScript return non-null and non-u ndefined values,
56 // - Make sure last parameter of all the InjectedSriptAccess.* calls is a callba ck function. 71 // - Make sure last parameter of all the InjectedSriptAccess.* calls is a callba ck function.
57 // We keep these sorted. 72 // We keep these sorted.
58 InjectedScriptAccess._installHandler("addInspectedNode"); 73 InjectedScriptAccess._installHandler("addInspectedNode");
59 InjectedScriptAccess._installHandler("addStyleSelector"); 74 InjectedScriptAccess._installHandler("addStyleSelector");
60 InjectedScriptAccess._installHandler("applyStyleRuleText"); 75 InjectedScriptAccess._installHandler("applyStyleRuleText");
(...skipping 18 matching lines...) Expand all
79 InjectedScriptAccess._installHandler("setStyleProperty"); 94 InjectedScriptAccess._installHandler("setStyleProperty");
80 InjectedScriptAccess._installHandler("setStyleText"); 95 InjectedScriptAccess._installHandler("setStyleText");
81 InjectedScriptAccess._installHandler("toggleStyleEnabled"); 96 InjectedScriptAccess._installHandler("toggleStyleEnabled");
82 InjectedScriptAccess._installHandler("evaluateOnSelf"); 97 InjectedScriptAccess._installHandler("evaluateOnSelf");
83 98
84 // Some methods can't run synchronously even on the injected script side (such a s DB transactions). 99 // Some methods can't run synchronously even on the injected script side (such a s DB transactions).
85 // Mark them as asynchronous here. 100 // Mark them as asynchronous here.
86 InjectedScriptAccess._installHandler("executeSql", true); 101 InjectedScriptAccess._installHandler("executeSql", true);
87 102
88 WebInspector.didDispatchOnInjectedScript = WebInspector.Callback.processCallback ; 103 WebInspector.didDispatchOnInjectedScript = WebInspector.Callback.processCallback ;
OLDNEW
« no previous file with comments | « inspector/front-end/InjectedScript.js ('k') | inspector/front-end/MetricsSidebarPane.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698