/*
 * Copyright (C) 2011 Google, Inc. All Rights Reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */
 
module core {
    interface [Conditional=INSPECTOR] Inspector {
        [event] void frontendReused();
        [event] void bringToFront();
        [event] void disconnectFromBackend();
        [event] void reset();
        [event] void showPanel(out String panel);
        [event] void startUserInitiatedDebugging();
        [event] void evaluateForTestInFrontend(out int testCallId, out String script);
        [event] void inspect(out Object object, out Object hints);
        [event] void didCreateWorker(out int id, out String url, out boolean isShared);
        [event] void didDestroyWorker(out int id);
    };
    interface [Conditional=INSPECTOR] Page {
        void addScriptToEvaluateOnLoad(in String scriptSource);
        void removeAllScriptsToEvaluateOnLoad();
        void reload(in [optional] boolean ignoreCache);
        void open(in String url, in [optional] boolean newWindow);
        void getCookies(out Array cookies, out String cookiesString);
        void deleteCookie(in String cookieName, in String domain);
        void getResourceTree(out Object frameTree);
        void getResourceContent(in String frameId, in String url, in [optional] boolean base64Encode, out String content);
        [event] void domContentEventFired(out double timestamp);
        [event] void loadEventFired(out double timestamp);
        [event] void frameNavigated(out Object frame, out String loaderId);
        [event] void frameDetached(out String frameId);
    };
    interface [Conditional=INSPECTOR] Runtime {
        void evaluate(in String expression, in [optional] String objectGroup, in [optional] boolean includeCommandLineAPI, out Object result, out [optional] boolean wasThrown);
        void evaluateOn(in String objectId, in String expression, out Object result, out [optional] boolean wasThrown);
        void getProperties(in String objectId, in boolean ignoreHasOwnProperty, out Array result);
        void setPropertyValue(in String objectId, in String propertyName, in String expression);
        void releaseObject(in String objectId);
        void releaseObjectGroup(in String objectGroup);
    };
    interface [Conditional=INSPECTOR] Console {
        void enable(out int expiredMessagesCount);
        void disable();
        void clearConsoleMessages();
        void setMonitoringXHREnabled(in boolean enabled);
        void addInspectedNode(in int nodeId);
        [event] void messageAdded(out Object messageObj);
        [event] void messageRepeatCountUpdated(out int count);
        [event] void messagesCleared();
    };
    interface [Conditional=INSPECTOR] Network {
        void enable();
        void disable();
        void setUserAgentOverride(in String userAgent);
        void setExtraHeaders(in Object headers);
        [event] void requestWillBeSent(out int identifier, out String frameId, out String loaderId, out String documentURL, out Object request, out double timestamp, out Array stackTrace, out [optional] Object redirectResponse);
        [event] void resourceMarkedAsCached(out int identifier);
        [event] void responseReceived(out int identifier, out double timestamp, out String type, out Object response);
        [event] void dataReceived(out int identifier, out double timestamp, out int dataLength, out int encodedDataLength);
        [event] void loadingFinished(out int identifier, out double timestamp);
        [event] void loadingFailed(out int identifier, out double timestamp, out String errorText, out [optional] boolean canceled);
        [event] void resourceLoadedFromMemoryCache(out String frameId, out String loaderId, out String documentURL, out double timestamp, out Object resource);
        [event] void initialContentSet(out int identifier, out String content, out String type);
        [event] void webSocketWillSendHandshakeRequest(out int identifier, out double timestamp, out Object request);
        [event] void webSocketHandshakeResponseReceived(out int identifier, out double timestamp, out Object response);
        [event] void webSocketCreated(out int identifier, out String url);
        [event] void webSocketClosed(out int identifier, out double timestamp);
    };
#if defined(ENABLE_DATABASE) && ENABLE_DATABASE
    interface [Conditional=INSPECTOR] Database {
        void enable();
        void disable();
        void getDatabaseTableNames(in int databaseId, out Array tableNames);
        void executeSQL(in int databaseId, in String query, out boolean success, out int transactionId);
        [event] void addDatabase(out Object database);
        [event] void sqlTransactionSucceeded(out int transactionId, out Array columnNames, out Array values);
        [event] void sqlTransactionFailed(out int transactionId, out Object sqlError);
    };
#endif // ENABLE_DATABASE
#if defined(ENABLE_DOM_STORAGE) && ENABLE_DOM_STORAGE
    interface [Conditional=INSPECTOR] DOMStorage {
        void enable();
        void disable();
        void getDOMStorageEntries(in int storageId, out Array entries);
        void setDOMStorageItem(in int storageId, in String key, in String value, out boolean success);
        void removeDOMStorageItem(in int storageId, in String key, out boolean success);
        [event] void addDOMStorage(out Object storage);
        [event] void updateDOMStorage(out int storageId);
    };
#endif // ENABLE_DOM_STORAGE
#if defined(ENABLE_OFFLINE_WEB_APPLICATIONS) && ENABLE_OFFLINE_WEB_APPLICATIONS
    interface [Conditional=INSPECTOR] ApplicationCache {
        void getApplicationCaches(out Object applicationCaches);
        [event] void updateApplicationCacheStatus(out int status);
        [event] void updateNetworkState(out boolean isNowOnline);
    };
#endif // ENABLE_OFFLINE_WEB_APPLICATIONS
    interface [Conditional=INSPECTOR] DOM {
        void getDocument(out Object root);
        void getChildNodes(in int nodeId);
        void querySelector(in int nodeId, in String selectors, out int nodeId);
        void querySelectorAll(in int nodeId, in String selectors, out Array nodeIds);
        void setNodeName(in int nodeId, in String name, out int outNodeId);
        void setNodeValue(in int nodeId, in String value);
        void removeNode(in int nodeId);
        void setAttribute(in int nodeId, in String name, in String value);
        void removeAttribute(in int nodeId, in String name);
        void getEventListenersForNode(in int nodeId, out Array listeners);
        void copyNode(in int nodeId);
        void getOuterHTML(in int nodeId, out String outerHTML);
        void setOuterHTML(in int nodeId, in String outerHTML, out int newNodeId);
        void performSearch(in String query, in [optional] boolean runSynchronously);
        void cancelSearch();
        void pushNodeToFrontend(in String objectId, out int nodeId);
        void setInspectModeEnabled(in boolean enabled);
        void highlightNode(in int nodeId, in [optional] String mode);
        void hideNodeHighlight();
        void highlightFrame(in String frameId);
        void hideFrameHighlight();
        void pushNodeByPathToFrontend(in String path, out int nodeId);
        void resolveNode(in int nodeId, out Object object);
        [event] void documentUpdated();
        [event] void setChildNodes(out int parentId, out Array nodes);
        [event] void attributesUpdated(out int id, out Array attributes);
        [event] void characterDataModified(out int id, out String newValue);
        [event] void childNodeCountUpdated(out int id, out int newValue);
        [event] void childNodeInserted(out int parentId, out int prevId, out Object node);
        [event] void childNodeRemoved(out int parentId, out int id);
        [event] void searchResults(out Array nodeIds);
        [event] void shadowRootUpdated(out int hostId, out Object shadowRoot);
    };
    interface [Conditional=INSPECTOR] CSS {
        void getStylesForNode(in int nodeId, out Object styles);
        void getComputedStyleForNode(in int nodeId, out Object style);
        void getInlineStyleForNode(in int nodeId, out Object style);
        void getAllStyleSheets(out Array headers);
        void getStyleSheet(in String styleSheetId, out Object styleSheet);
        void getStyleSheetText(in String styleSheetId, out String text);
        void setStyleSheetText(in String styleSheetId, in String text);
        void setPropertyText(in Object styleId, in int propertyIndex, in String text, in boolean overwrite, out Object style);
        void toggleProperty(in Object styleId, in int propertyIndex, in boolean disable, out Object style);
        void setRuleSelector(in Object ruleId, in String selector, out Object rule);
        void addRule(in int contextNodeId, in String selector, out Object rule);
        void getSupportedCSSProperties(out Array cssProperties);
    };
    interface [Conditional=INSPECTOR] Timeline {
        void start();
        void stop();
        [event] void started();
        [event] void stopped();
        [event] void eventRecorded(out Object record);
    };
#if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER
    interface [Conditional=INSPECTOR] Debugger {
        void enable();
        void disable();
        void setBreakpointsActive(in boolean active);
        void setBreakpointByUrl(in String url, in int lineNumber, in [optional] int columnNumber, in [optional] String condition, out String breakpointId, out [optional] Array locations);
        void setBreakpoint(in Object location, in [optional] String condition, out String breakpointId, out Object actualLocation);
        void removeBreakpoint(in String breakpointId);
        void continueToLocation(in Object location);
        void stepOver();
        void stepInto();
        void stepOut();
        void pause();
        void resume();
        void editScriptSource(in String sourceID, in String scriptSource, out [optional] Array callFrames);
        void getScriptSource(in String sourceID, out String scriptSource);
        void setPauseOnExceptions(in String state);
        void evaluateOnCallFrame(in String callFrameId, in String expression, in [optional] String objectGroup, in [optional] boolean includeCommandLineAPI, out Object result, out [optional] boolean wasThrown);
        [event] void debuggerWasEnabled();
        [event] void debuggerWasDisabled();
        [event] void scriptParsed(out String sourceID, out String url, out int startLine, out int startColumn, out int endLine, out int endColumn, out [optional] boolean isContentScript);
        [event] void scriptFailedToParse(out String url, out String data, out int firstLine, out int errorLine, out String errorMessage);
        [event] void breakpointResolved(out String breakpointId, out Object location);
        [event] void paused(out Object details);
        [event] void resumed();
    };
#endif // ENABLE_JAVASCRIPT_DEBUGGER
#if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER
    interface [Conditional=INSPECTOR] DOMDebugger {
        void setDOMBreakpoint(in int nodeId, in int type);
        void removeDOMBreakpoint(in int nodeId, in int type);
        void setEventListenerBreakpoint(in String eventName);
        void removeEventListenerBreakpoint(in String eventName);
        void setXHRBreakpoint(in String url);
        void removeXHRBreakpoint(in String url);
    };
#endif // ENABLE_JAVASCRIPT_DEBUGGER
#if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER
    interface [Conditional=INSPECTOR] Profiler {
        void enable();
        void disable();
        void isEnabled(out boolean state);
        void start();
        void stop();
        void getProfileHeaders(out Array headers);
        void getProfile(in String type, in int uid, out Object profile);
        void removeProfile(in String type, in int uid);
        void clearProfiles();
        void takeHeapSnapshot(in boolean detailed);
        void collectGarbage();
        [event] void profilerWasEnabled();
        [event] void profilerWasDisabled();
        [event] void addProfileHeader(out Object header);
        [event] void addHeapSnapshotChunk(out int uid, out String chunk);
        [event] void finishHeapSnapshot(out int uid);
        [event] void setRecordingProfile(out boolean isProfiling);
        [event] void resetProfiles();
        [event] void reportHeapSnapshotProgress(out int done, out int total);
    };
#endif // ENABLE_JAVASCRIPT_DEBUGGER
#if defined(ENABLE_WORKERS) && ENABLE_WORKERS
    interface [Conditional=INSPECTOR] Worker {
        void sendMessageToWorker(in int workerId, in Object message);
        [event] void workerCreated(out int workerId);
        [event] void dispatchMessageFromWorker(out int workerId, out Object message);
    };
#endif // ENABLE_WORKERS
}
