OSDN Git Service

Merge WebKit at r73109: Initial merge by git.
[android-x86/external-webkit.git] / WebKit / chromium / src / js / DevTools.js
index 851c934..5bb150c 100644 (file)
  * WebInspector functionality while it is getting upstreamed into WebCore.
  */
 
-/**
- * Dispatches raw message from the host.
- * @param {string} remoteName
- * @prama {string} methodName
- * @param {string} param1, param2, param3 Arguments to dispatch.
- */
-devtools$$dispatch = function(remoteName, methodName, param1, param2, param3)
-{
-    remoteName = "Remote" + remoteName.substring(0, remoteName.length - 8);
-    var agent = window[remoteName];
-    if (!agent) {
-        debugPrint("No remote agent '" + remoteName + "' found.");
-        return;
-    }
-    var method = agent[methodName];
-    if (!method) {
-        debugPrint("No method '" + remoteName + "." + methodName + "' found.");
-        return;
-    }
-    method.call(this, param1, param2, param3);
-};
-
-
-devtools.ToolsAgent = function()
-{
-    RemoteToolsAgent.didDispatchOn = WebInspector.Callback.processCallback;
-    RemoteToolsAgent.dispatchOnClient = this.dispatchOnClient_.bind(this);
-    this.debuggerAgent_ = new devtools.DebuggerAgent();
-    this.profilerAgent_ = new devtools.ProfilerAgent();
-};
-
-
-/**
- * Resets tools agent to its initial state.
- */
-devtools.ToolsAgent.prototype.reset = function()
-{
-    this.debuggerAgent_.reset();
-};
-
-
-/**
- * @param {string} script Script exression to be evaluated in the context of the
- *     inspected page.
- * @param {function(Object|string, boolean):undefined} opt_callback Function to
- *     call with the result.
- */
-devtools.ToolsAgent.prototype.evaluateJavaScript = function(script, opt_callback)
-{
-    InspectorBackend.evaluate(script, opt_callback || function() {});
-};
-
-
-/**
- * @return {devtools.DebuggerAgent} Debugger agent instance.
- */
-devtools.ToolsAgent.prototype.getDebuggerAgent = function()
-{
-    return this.debuggerAgent_;
-};
-
-
-/**
- * @return {devtools.ProfilerAgent} Profiler agent instance.
- */
-devtools.ToolsAgent.prototype.getProfilerAgent = function()
-{
-    return this.profilerAgent_;
-};
-
-
-(function () {
-var orig = WebInspector.reset;
-WebInspector.reset = function()
-{
-    devtools.tools.reset();
-    orig.call(this);
-};
-})();
-
-
-/**
- * @param {string} message Serialized call to be dispatched on WebInspector.
- * @private
- */
-devtools.ToolsAgent.prototype.dispatchOnClient_ = function(message)
-{
-    var args = JSON.parse(message);
-    var methodName = args[0];
-    var parameters = args.slice(1);
-    WebInspector[methodName].apply(WebInspector, parameters);
-};
-
-
-/**
- * Evaluates js expression.
- * @param {string} expr
- */
-devtools.ToolsAgent.prototype.evaluate = function(expr)
-{
-    RemoteToolsAgent.evaluate(expr);
-};
-
-
-/**
- * Prints string  to the inspector console or shows alert if the console doesn't
- * exist.
- * @param {string} text
- */
-function debugPrint(text) {
-    WebInspector.log(text);
-}
-
-
-/**
- * Global instance of the tools agent.
- * @type {devtools.ToolsAgent}
- */
-devtools.tools = null;
-
-
 var context = {};  // Used by WebCore's inspector routines.
 
-///////////////////////////////////////////////////////////////////////////////
-// Here and below are overrides to existing WebInspector methods only.
-// TODO(pfeldman): Patch WebCore and upstream changes.
-var oldLoaded = WebInspector.loaded;
-WebInspector.loaded = function()
-{
-    devtools.tools = new devtools.ToolsAgent();
-    devtools.tools.reset();
-
+(function () {
     Preferences.ignoreWhitespace = false;
     Preferences.samplingCPUProfiler = true;
     Preferences.heapProfilerPresent = true;
     Preferences.debuggerAlwaysEnabled = true;
     Preferences.profilerAlwaysEnabled = true;
     Preferences.canEditScriptSource = true;
+    Preferences.onlineDetectionEnabled = false;
+    Preferences.nativeInstrumentationEnabled = true;
+    Preferences.fileSystemEnabled = false;
+    Preferences.showTimingTab = true;
+    Preferences.showCookiesTab = true;
+})();
 
-    oldLoaded.call(this);
-
-    InspectorFrontendHost.loaded();
-};
+var devtools = devtools || {};
 
 devtools.domContentLoaded = function()
 {
-    var queryParams = window.location.search;
-    if (queryParams) {
-        var params = queryParams.substring(1).split("&");
-        var paramsObject = {};
-        for (var i = 0; i < params.length; ++i) {
-            var pair = params[i].split("=");
-            paramsObject[pair[0]] = pair[1];
-        }
-        WebInspector.setAttachedWindow(paramsObject.docked === "true");
-        if (paramsObject.toolbar_color && paramsObject.text_color)
-            WebInspector.setToolbarColors(paramsObject.toolbar_color, paramsObject.text_color);
-    }
+    WebInspector.setAttachedWindow(WebInspector.queryParamsObject.docked === "true");
+    if (WebInspector.queryParamsObject.toolbar_color && WebInspector.queryParamsObject.text_color)
+        WebInspector.setToolbarColors(WebInspector.queryParamsObject.toolbar_color, WebInspector.queryParamsObject.text_color);
 }
 document.addEventListener("DOMContentLoaded", devtools.domContentLoaded, false);
 
 
-if (!window.v8ScriptDebugServerEnabled) {
-
-(function()
-{
-    var oldShow = WebInspector.ScriptsPanel.prototype.show;
-    WebInspector.ScriptsPanel.prototype.show =  function()
-    {
-        devtools.tools.getDebuggerAgent().initUI();
-        this.enableToggleButton.visible = false;
-        oldShow.call(this);
-    };
-})();
-
-
-(function () {
-var orig = InjectedScriptAccess.prototype.getProperties;
-InjectedScriptAccess.prototype.getProperties = function(objectProxy, ignoreHasOwnProperty, abbreviate, callback)
-{
-    if (objectProxy.isScope)
-        devtools.tools.getDebuggerAgent().resolveScope(objectProxy.objectId, callback);
-    else if (objectProxy.isV8Ref)
-        devtools.tools.getDebuggerAgent().resolveChildren(objectProxy.objectId, callback, false);
-    else
-        orig.apply(this, arguments);
-};
-})();
-
-
-(function()
-{
-InjectedScriptAccess.prototype.evaluateInCallFrame = function(callFrameId, code, objectGroup, callback)
-{
-    //TODO(pfeldman): remove once 49084 is rolled.
-    if (!callback)
-        callback = objectGroup;
-    devtools.tools.getDebuggerAgent().evaluateInCallFrame(callFrameId, code, callback);
-};
-})();
-
-
-(function()
-{
-var orig = InjectedScriptAccess.prototype.getCompletions;
-InjectedScriptAccess.prototype.getCompletions = function(expressionString, includeInspectorCommandLineAPI, callFrameId, reportCompletions)
-{
-    if (typeof callFrameId === "number")
-        devtools.tools.getDebuggerAgent().resolveCompletionsOnFrame(expressionString, callFrameId, reportCompletions);
-    else
-        return orig.apply(this, arguments);
-};
-})();
-
-// Highlight extension content scripts in the scripts list.
-(function () {
-    var original = WebInspector.ScriptsPanel.prototype._addScriptToFilesMenu;
-    WebInspector.ScriptsPanel.prototype._addScriptToFilesMenu = function(script)
-    {
-        var result = original.apply(this, arguments);
-        var debuggerAgent = devtools.tools.getDebuggerAgent();
-        var type = debuggerAgent.getScriptContextType(script.sourceID);
-        var option = script.filesSelectOption;
-        if (type === "injected" && option)
-            option.addStyleClass("injected");
-        return result;
-    };
-})();
-
-}
-
-
+// FIXME: This needs to be upstreamed.
 (function InterceptProfilesPanelEvents()
 {
     var oldShow = WebInspector.ProfilesPanel.prototype.show;
     WebInspector.ProfilesPanel.prototype.show = function()
     {
-        devtools.tools.getProfilerAgent().initializeProfiling();
         this.enableToggleButton.visible = false;
         oldShow.call(this);
         // Show is called on every show event of a panel, so
@@ -369,3 +164,26 @@ WebInspector.resetToolbarColors = function()
         WebInspector._themeStyleElement.textContent = "";
 
 }
+
+////////////////////////////////////////////////////////
+// Platform-specific WebInspector extensions support. //
+////////////////////////////////////////////////////////
+
+WebInspector.platformExtensionAPI = function(tabId)
+{
+    function getTabId()
+    {
+        return tabId;
+    }
+    webInspector.inspectedWindow.__proto__.__defineGetter__("tabId", getTabId);
+}
+
+WebInspector.buildPlatformExtensionAPI = function()
+{
+    return "(" + WebInspector.platformExtensionAPI + ")(" + WebInspector._inspectedTabId + ");";
+}
+
+WebInspector.setInspectedTabId = function(tabId)
+{
+    WebInspector._inspectedTabId = tabId;
+}