Home | History | Annotate | Download | only in front_end
      1 /*
      2  * Copyright (C) 2009 Google Inc. All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions are
      6  * met:
      7  *
      8  *     * Redistributions of source code must retain the above copyright
      9  * notice, this list of conditions and the following disclaimer.
     10  *     * Redistributions in binary form must reproduce the above
     11  * copyright notice, this list of conditions and the following disclaimer
     12  * in the documentation and/or other materials provided with the
     13  * distribution.
     14  *     * Neither the name of Google Inc. nor the names of its
     15  * contributors may be used to endorse or promote products derived from
     16  * this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 /**
     32  * @constructor
     33  * @implements {InspectorFrontendHostAPI}
     34  */
     35 WebInspector.InspectorFrontendHostStub = function()
     36 {
     37     this.isStub = true;
     38 }
     39 
     40 WebInspector.InspectorFrontendHostStub.prototype = {
     41     /**
     42      * @return {string}
     43      */
     44     getSelectionBackgroundColor: function()
     45     {
     46         return "#6e86ff";
     47     },
     48 
     49     /**
     50      * @return {string}
     51      */
     52     getSelectionForegroundColor: function()
     53     {
     54         return "#ffffff";
     55     },
     56 
     57     /**
     58      * @return {string}
     59      */
     60     platform: function()
     61     {
     62         var match = navigator.userAgent.match(/Windows NT/);
     63         if (match)
     64             return "windows";
     65         match = navigator.userAgent.match(/Mac OS X/);
     66         if (match)
     67             return "mac";
     68         return "linux";
     69     },
     70 
     71     /**
     72      * @return {string}
     73      */
     74     port: function()
     75     {
     76         return "unknown";
     77     },
     78 
     79     bringToFront: function()
     80     {
     81         this._windowVisible = true;
     82     },
     83 
     84     closeWindow: function()
     85     {
     86         this._windowVisible = false;
     87     },
     88 
     89     setIsDocked: function(isDocked, callback)
     90     {
     91     },
     92 
     93     /**
     94      * Requests inspected page to be placed atop of the inspector frontend with specified bounds.
     95      * @param {{x: number, y: number, width: number, height: number}} bounds
     96      */
     97     setInspectedPageBounds: function(bounds)
     98     {
     99     },
    100 
    101     /**
    102      * Requests inspected page to be placed atop of the inspector frontend
    103      * with passed insets from the frontend sides, respecting minimum size passed.
    104      * @param {{top: number, left: number, right: number, bottom: number}} insets
    105      * @param {{width: number, height: number}} minSize
    106      */
    107     setContentsResizingStrategy: function(insets, minSize)
    108     {
    109     },
    110 
    111     inspectElementCompleted: function()
    112     {
    113     },
    114 
    115     moveWindowBy: function(x, y)
    116     {
    117     },
    118 
    119     setInjectedScriptForOrigin: function(origin, script)
    120     {
    121     },
    122 
    123     inspectedURLChanged: function(url)
    124     {
    125         document.title = WebInspector.UIString("Developer Tools - %s", url);
    126     },
    127 
    128     copyText: function(text)
    129     {
    130         WebInspector.messageSink.addErrorMessage("Clipboard is not enabled in hosted mode. Please inspect using chrome://inspect", true);
    131     },
    132 
    133     openInNewTab: function(url)
    134     {
    135         window.open(url, "_blank");
    136     },
    137 
    138     save: function(url, content, forceSaveAs)
    139     {
    140         WebInspector.messageSink.addErrorMessage("Saving files is not enabled in hosted mode. Please inspect using chrome://inspect", true);
    141         WebInspector.fileManager.canceledSaveURL(url);
    142     },
    143 
    144     append: function(url, content)
    145     {
    146         WebInspector.messageSink.addErrorMessage("Saving files is not enabled in hosted mode. Please inspect using chrome://inspect", true);
    147     },
    148 
    149     sendMessageToBackend: function(message)
    150     {
    151     },
    152 
    153     sendMessageToEmbedder: function(message)
    154     {
    155     },
    156 
    157     recordActionTaken: function(actionCode)
    158     {
    159     },
    160 
    161     recordPanelShown: function(panelCode)
    162     {
    163     },
    164 
    165     requestFileSystems: function()
    166     {
    167     },
    168 
    169     addFileSystem: function()
    170     {
    171     },
    172 
    173     removeFileSystem: function(fileSystemPath)
    174     {
    175     },
    176 
    177     /**
    178      * @param {string} fileSystemId
    179      * @param {string} registeredName
    180      * @return {?WebInspector.IsolatedFileSystem}
    181      */
    182     isolatedFileSystem: function(fileSystemId, registeredName)
    183     {
    184         return null;
    185     },
    186 
    187     upgradeDraggedFileSystemPermissions: function(domFileSystem)
    188     {
    189     },
    190 
    191     indexPath: function(requestId, fileSystemPath)
    192     {
    193     },
    194 
    195     stopIndexing: function(requestId)
    196     {
    197     },
    198 
    199     searchInPath: function(requestId, fileSystemPath, query)
    200     {
    201     },
    202 
    203     setZoomFactor: function(zoom)
    204     {
    205     },
    206 
    207     /**
    208      * @return {number}
    209      */
    210     zoomFactor: function()
    211     {
    212         return 1;
    213     },
    214 
    215     zoomIn: function()
    216     {
    217     },
    218 
    219     zoomOut: function()
    220     {
    221     },
    222 
    223     resetZoom: function()
    224     {
    225     },
    226 
    227     setWhitelistedShortcuts: function(shortcuts)
    228     {
    229     },
    230 
    231     /**
    232      * @return {boolean}
    233      */
    234     isUnderTest: function()
    235     {
    236         return false;
    237     },
    238 
    239     /**
    240      * @param {string} browserId
    241      * @param {string} url
    242      */
    243     openUrlOnRemoteDeviceAndInspect: function(browserId, url)
    244     {
    245     },
    246 
    247     /**
    248      * @param {string} eventType
    249      */
    250     subscribe: function(eventType)
    251     {
    252     },
    253 
    254     /**
    255      * @param {string} eventType
    256      */
    257     unsubscribe: function(eventType)
    258     {
    259     }
    260 }
    261 
    262 if (!window.InspectorFrontendHost) {
    263     InspectorFrontendHost = new WebInspector.InspectorFrontendHostStub();
    264 } else {
    265     var proto = WebInspector.InspectorFrontendHostStub.prototype;
    266     for (var name in proto) {
    267         var value = proto[name];
    268         if (typeof value !== "function" || InspectorFrontendHost[name])
    269             continue;
    270         InspectorFrontendHost[name] = function(name) {
    271             var message = "Incompatible embedder: method InspectorFrontendHost." + name + " is missing. Using stub instead.";
    272             WebInspector.messageSink.addErrorMessage(message, true);
    273             var args = Array.prototype.slice.call(arguments, 1);
    274             return proto[name].apply(InspectorFrontendHost, args);
    275         }.bind(null, name);
    276     }
    277 }
    278