/* * weinre is available under *either* the terms of the modified BSD license *or* the * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text. * * Copyright (c) 2010, 2011 IBM Corporation */ requireClass ../common/Ex requireClass ../common/IDLTools requireClass ../common/MessageDispatcher requireClass ../common/Weinre //----------------------------------------------------------------------------- class InspectorBackendImpl this.registeredDomainDispatchers = {} MessageDispatcher.setInspectorBackend(this) //----------------------------------------------------------------------------- static method setupProxies var intfNames = [ "ApplicationCache", "BrowserDebugger", "CSS", "Console", "DOM", "DOMStorage", "Database", "Debugger", "InjectedScript", "Inspector", "Network", "Profiler", "Runtime" ] intfNames.forEach(function(intfName) { var proxy = Weinre.messageDispatcher.createProxy(intfName) if (window[intfName]) { throw new Ex(arguments, "backend interface '" + intfName + "' already created") } var intf = IDLTools.getIDL(intfName) if (!intf) { throw new Ex(arguments, "interface not registered: '" + intfName + "'") } window[intfName] = {} intf.methods.forEach(function(method) { var proxyMethod = InspectorBackendImpl.getProxyMethod(proxy, method) InspectorBackendImpl.prototype[method.name] = proxyMethod window[intfName][method.name] = proxyMethod }) }) //----------------------------------------------------------------------------- static method getProxyMethod(proxy, method) return function() { return proxy[method.name].apply(proxy, arguments) } //----------------------------------------------------------------------------- method registerDomainDispatcher(name, intf) this.registeredDomainDispatchers[name] = intf //----------------------------------------------------------------------------- method getRegisteredDomainDispatcher(name) if (!this.registeredDomainDispatchers.hasOwnProperty(name)) return null return this.registeredDomainDispatchers[name]