OSDN Git Service

Merge WebKit at r71558: Initial merge by git.
[android-x86/external-webkit.git] / WebKit / chromium / src / js / DevTools.js
index 895c68b..8b3aea0 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(message)
-{
-    var args = typeof message === "string" ? JSON.parse(message) : message;
-    var methodName = args[0];
-    var parameters = args.slice(1);
-    WebInspector[methodName].apply(WebInspector, parameters);
-};
-
-
-devtools.ToolsAgent = function()
-{
-    this.profilerAgent_ = new devtools.ProfilerAgent();
-};
-
-
-/**
- * @return {devtools.ProfilerAgent} Profiler agent instance.
- */
-devtools.ToolsAgent.prototype.getProfilerAgent = function()
-{
-    return this.profilerAgent_;
-};
-
-
-
-/**
- * Global instance of the tools agent.
- * @type {devtools.ToolsAgent}
- */
-devtools.tools = null;
-
-
 var context = {};  // Used by WebCore's inspector routines.
 
-(function() {
-    WebInspector._paramsObject = {};
-
-    var queryParams = window.location.search;
-    if (queryParams) {
-        var params = queryParams.substring(1).split("&");
-        for (var i = 0; i < params.length; ++i) {
-            var pair = params[i].split("=");
-            WebInspector._paramsObject[pair[0]] = pair[1];
-        }
-    }
-    if ("page" in WebInspector._paramsObject) {
-        WebInspector.socket = new WebSocket("ws://" + window.location.host + "/devtools/page/" + WebInspector._paramsObject.page);
-        WebInspector.socket.onmessage = function(message) { devtools$$dispatch(message.data); }
-        WebInspector.socket.onerror = function(error) { console.err(error); }
-        WebInspector.socket.onopen = function() {
-            WebInspector.socketOpened = true;
-            if (WebInspector.loadedDone)
-                WebInspector.doLoadedDone();
-        };
-        InspectorFrontendHost.sendMessageToBackend = WebInspector.socket.send.bind(WebInspector.socket);
-        InspectorFrontendHost.loaded = WebInspector.socket.send.bind(WebInspector.socket, "loaded");
-    }
-})();
-///////////////////////////////////////////////////////////////////////////////
-// 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();
-
+(function () {
     Preferences.ignoreWhitespace = false;
     Preferences.samplingCPUProfiler = true;
     Preferences.heapProfilerPresent = true;
@@ -114,34 +45,27 @@ WebInspector.loaded = function()
     Preferences.profilerAlwaysEnabled = true;
     Preferences.canEditScriptSource = true;
     Preferences.onlineDetectionEnabled = false;
-    if ("page" in WebInspector._paramsObject) {
-        WebInspector.loadedDone = true;
-        if (WebInspector.socketOpened)
-            WebInspector.doLoadedDone();
-        return;
-    }
-    WebInspector.doLoadedDone();
-}
+    Preferences.nativeInstrumentationEnabled = true;
+    Preferences.fileSystemEnabled = false;
+})();
 
-WebInspector.doLoadedDone = function() {
-    oldLoaded.call(this);
-}
+var devtools = devtools || {};
 
 devtools.domContentLoaded = function()
 {
-    WebInspector.setAttachedWindow(WebInspector._paramsObject.docked === "true");
-    if (WebInspector._paramsObject.toolbar_color && WebInspector._paramsObject.text_color)
-        WebInspector.setToolbarColors(WebInspector._paramsObject.toolbar_color, WebInspector._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);
 
 
+// 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
@@ -239,14 +163,25 @@ WebInspector.resetToolbarColors = function()
 
 }
 
-// TODO(yurys): should be removed when eclipse debugger stops using it.
-if (window.RemoteDebuggerAgent) {
-    RemoteDebuggerAgent.setContextId = function() {};
+////////////////////////////////////////////////////////
+// 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 + ");";
+}
 
-// Support for pause while renderer is busy (is dispatched on IO thread).
-InspectorBackend.pause = function()
+WebInspector.setInspectedTabId = function(tabId)
 {
-    RemoteDebuggerCommandExecutor.DebuggerPauseScript();
-};
+    WebInspector._inspectedTabId = tabId;
+}