OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 } | 63 } |
64 | 64 |
65 InspectorFrontendHostAPI.EventDescriptors = [ | 65 InspectorFrontendHostAPI.EventDescriptors = [ |
66 [InspectorFrontendHostAPI.Events.AppendedToURL, ["url"]], | 66 [InspectorFrontendHostAPI.Events.AppendedToURL, ["url"]], |
67 [InspectorFrontendHostAPI.Events.CanceledSaveURL, ["url"]], | 67 [InspectorFrontendHostAPI.Events.CanceledSaveURL, ["url"]], |
68 [InspectorFrontendHostAPI.Events.ContextMenuCleared, []], | 68 [InspectorFrontendHostAPI.Events.ContextMenuCleared, []], |
69 [InspectorFrontendHostAPI.Events.ContextMenuItemSelected, ["id"]], | 69 [InspectorFrontendHostAPI.Events.ContextMenuItemSelected, ["id"]], |
70 [InspectorFrontendHostAPI.Events.DeviceCountUpdated, ["count"]], | 70 [InspectorFrontendHostAPI.Events.DeviceCountUpdated, ["count"]], |
71 [InspectorFrontendHostAPI.Events.DevicesUpdated, ["devices"]], | 71 [InspectorFrontendHostAPI.Events.DevicesUpdated, ["devices"]], |
72 [InspectorFrontendHostAPI.Events.DispatchMessage, ["messageObject"]], | 72 [InspectorFrontendHostAPI.Events.DispatchMessage, ["messageObject"]], |
73 [InspectorFrontendHostAPI.Events.EnterInspectElementMode, [], true], | 73 [InspectorFrontendHostAPI.Events.EnterInspectElementMode, []], |
74 [InspectorFrontendHostAPI.Events.FileSystemsLoaded, ["fileSystems"]], | 74 [InspectorFrontendHostAPI.Events.FileSystemsLoaded, ["fileSystems"]], |
75 [InspectorFrontendHostAPI.Events.FileSystemRemoved, ["fileSystemPath"]], | 75 [InspectorFrontendHostAPI.Events.FileSystemRemoved, ["fileSystemPath"]], |
76 [InspectorFrontendHostAPI.Events.FileSystemAdded, ["errorMessage", "fileSyst em"]], | 76 [InspectorFrontendHostAPI.Events.FileSystemAdded, ["errorMessage", "fileSyst em"]], |
77 [InspectorFrontendHostAPI.Events.IndexingTotalWorkCalculated, ["requestId", "fileSystemPath", "totalWork"]], | 77 [InspectorFrontendHostAPI.Events.IndexingTotalWorkCalculated, ["requestId", "fileSystemPath", "totalWork"]], |
78 [InspectorFrontendHostAPI.Events.IndexingWorked, ["requestId", "fileSystemPa th", "worked"]], | 78 [InspectorFrontendHostAPI.Events.IndexingWorked, ["requestId", "fileSystemPa th", "worked"]], |
79 [InspectorFrontendHostAPI.Events.IndexingDone, ["requestId", "fileSystemPath "]], | 79 [InspectorFrontendHostAPI.Events.IndexingDone, ["requestId", "fileSystemPath "]], |
80 [InspectorFrontendHostAPI.Events.KeyEventUnhandled, ["event"], true], | 80 [InspectorFrontendHostAPI.Events.KeyEventUnhandled, ["event"]], |
81 [InspectorFrontendHostAPI.Events.RevealSourceLine, ["url", "lineNumber", "co lumnNumber"], true], | 81 [InspectorFrontendHostAPI.Events.RevealSourceLine, ["url", "lineNumber", "co lumnNumber"]], |
82 [InspectorFrontendHostAPI.Events.SavedURL, ["url"]], | 82 [InspectorFrontendHostAPI.Events.SavedURL, ["url"]], |
83 [InspectorFrontendHostAPI.Events.SearchCompleted, ["requestId", "fileSystemP ath", "files"]], | 83 [InspectorFrontendHostAPI.Events.SearchCompleted, ["requestId", "fileSystemP ath", "files"]], |
84 [InspectorFrontendHostAPI.Events.SetToolbarColors, ["backgroundColor", "colo r"]], | 84 [InspectorFrontendHostAPI.Events.SetToolbarColors, ["backgroundColor", "colo r"]], |
85 [InspectorFrontendHostAPI.Events.SetUseSoftMenu, ["useSoftMenu"]], | 85 [InspectorFrontendHostAPI.Events.SetUseSoftMenu, ["useSoftMenu"]], |
86 [InspectorFrontendHostAPI.Events.ShowConsole, [], true] | 86 [InspectorFrontendHostAPI.Events.ShowConsole, []] |
87 ]; | 87 ]; |
88 | 88 |
89 InspectorFrontendHostAPI.prototype = { | 89 InspectorFrontendHostAPI.prototype = { |
90 addFileSystem: function() { }, | 90 addFileSystem: function() { }, |
91 | 91 |
92 /** | 92 /** |
93 * @param {string} url | 93 * @param {string} url |
94 * @param {string} content | 94 * @param {string} content |
95 */ | 95 */ |
96 append: function(url, content) { }, | 96 append: function(url, content) { }, |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 setDevicesUpdatesEnabled: function(enabled) { }, | 241 setDevicesUpdatesEnabled: function(enabled) { }, |
242 | 242 |
243 /** | 243 /** |
244 * @param {string} origin | 244 * @param {string} origin |
245 * @param {string} script | 245 * @param {string} script |
246 */ | 246 */ |
247 setInjectedScriptForOrigin: function(origin, script) { }, | 247 setInjectedScriptForOrigin: function(origin, script) { }, |
248 | 248 |
249 /** | 249 /** |
250 * @param {boolean} isDocked | 250 * @param {boolean} isDocked |
251 * @param {!function()} callback | 251 * @param {function()} callback |
252 */ | 252 */ |
253 setIsDocked: function(isDocked, callback) { }, | 253 setIsDocked: function(isDocked, callback) { }, |
254 | 254 |
255 /** | 255 /** |
256 * @param {number} zoom | 256 * @param {number} zoom |
257 */ | 257 */ |
258 setZoomFactor: function(zoom) { }, | 258 setZoomFactor: function(zoom) { }, |
259 | 259 |
260 /** | 260 /** |
261 * @return {number} | 261 * @return {number} |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 this._windowVisible = true; | 342 this._windowVisible = true; |
343 }, | 343 }, |
344 | 344 |
345 closeWindow: function() | 345 closeWindow: function() |
346 { | 346 { |
347 this._windowVisible = false; | 347 this._windowVisible = false; |
348 }, | 348 }, |
349 | 349 |
350 /** | 350 /** |
351 * @param {boolean} isDocked | 351 * @param {boolean} isDocked |
352 * @param {!function()} callback | 352 * @param {function()} callback |
353 */ | 353 */ |
354 setIsDocked: function(isDocked, callback) | 354 setIsDocked: function(isDocked, callback) |
355 { | 355 { |
356 }, | 356 }, |
357 | 357 |
358 /** | 358 /** |
359 * Requests inspected page to be placed atop of the inspector frontend with specified bounds. | 359 * Requests inspected page to be placed atop of the inspector frontend with specified bounds. |
360 * @param {{x: number, y: number, width: number, height: number}} bounds | 360 * @param {{x: number, y: number, width: number, height: number}} bounds |
361 */ | 361 */ |
362 setInspectedPageBounds: function(bounds) | 362 setInspectedPageBounds: function(bounds) |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
634 | 634 |
635 // Attach the events object. | 635 // Attach the events object. |
636 InspectorFrontendHost.events = new WebInspector.Object(); | 636 InspectorFrontendHost.events = new WebInspector.Object(); |
637 })(); | 637 })(); |
638 | 638 |
639 /** | 639 /** |
640 * @constructor | 640 * @constructor |
641 */ | 641 */ |
642 function InspectorFrontendAPIImpl() | 642 function InspectorFrontendAPIImpl() |
643 { | 643 { |
644 this._isLoaded = false; | |
645 this._pendingCommands = []; | |
646 this._debugFrontend = !!Runtime.queryParam("debugFrontend"); | 644 this._debugFrontend = !!Runtime.queryParam("debugFrontend"); |
647 | 645 |
648 var descriptors = InspectorFrontendHostAPI.EventDescriptors; | 646 var descriptors = InspectorFrontendHostAPI.EventDescriptors; |
649 for (var i = 0; i < descriptors.length; ++i) | 647 for (var i = 0; i < descriptors.length; ++i) |
650 this[descriptors[i][0]] = this._dispatch.bind(this, descriptors[i][0], d escriptors[i][1], descriptors[i][2]); | 648 this[descriptors[i][0]] = this._dispatch.bind(this, descriptors[i][0], d escriptors[i][1], descriptors[i][2]); |
651 } | 649 } |
652 | 650 |
653 InspectorFrontendAPIImpl.prototype = { | 651 InspectorFrontendAPIImpl.prototype = { |
654 loadCompleted: function() | |
655 { | |
656 this._isLoaded = true; | |
657 for (var i = 0; i < this._pendingCommands.length; ++i) | |
658 this._pendingCommands[i](); | |
659 this._pendingCommands = []; | |
660 if (window.opener) | |
661 window.opener.postMessage(["loadCompleted"], "*"); | |
apavlov
2014/10/09 12:28:07
What does this do? I've got no clue...
| |
662 }, | |
663 | |
664 /** | 652 /** |
665 * @param {string} name | 653 * @param {string} name |
666 * @param {!Array.<string>} signature | 654 * @param {!Array.<string>} signature |
667 * @param {boolean} runOnceLoaded | 655 * @param {boolean} runOnceLoaded |
668 */ | 656 */ |
669 _dispatch: function(name, signature, runOnceLoaded) | 657 _dispatch: function(name, signature, runOnceLoaded) |
670 { | 658 { |
671 var params = Array.prototype.slice.call(arguments, 3); | 659 var params = Array.prototype.slice.call(arguments, 3); |
672 | 660 |
673 if (this._debugFrontend) | 661 if (this._debugFrontend) |
674 setImmediate(innerDispatch.bind(this)); | 662 setImmediate(innerDispatch); |
675 else | 663 else |
676 innerDispatch.call(this); | 664 innerDispatch(); |
677 | 665 |
678 /** | |
679 * @this {!InspectorFrontendAPIImpl} | |
680 */ | |
681 function innerDispatch() | 666 function innerDispatch() |
682 { | 667 { |
683 if (runOnceLoaded) | 668 // Single argument methods get dispatched with the param. |
684 this._runOnceLoaded(dispatchAfterLoad); | 669 if (signature.length < 2) { |
685 else | 670 InspectorFrontendHost.events.dispatchEventToListeners(name, para ms[0]); |
686 dispatchAfterLoad(); | 671 return; |
687 | |
688 function dispatchAfterLoad() | |
689 { | |
690 // Single argument methods get dispatched with the param. | |
691 if (signature.length < 2) { | |
692 InspectorFrontendHost.events.dispatchEventToListeners(name, params[0]); | |
693 return; | |
694 } | |
695 var data = {}; | |
696 for (var i = 0; i < signature.length; ++i) | |
697 data[signature[i]] = params[i]; | |
698 InspectorFrontendHost.events.dispatchEventToListeners(name, data ); | |
699 } | 672 } |
673 var data = {}; | |
674 for (var i = 0; i < signature.length; ++i) | |
675 data[signature[i]] = params[i]; | |
676 InspectorFrontendHost.events.dispatchEventToListeners(name, data); | |
700 } | 677 } |
701 }, | 678 }, |
702 | 679 |
703 /** | 680 /** |
704 * @param {function()} command | |
705 */ | |
706 _runOnceLoaded: function(command) | |
707 { | |
708 if (this._isLoaded) { | |
709 command(); | |
710 return; | |
711 } | |
712 this._pendingCommands.push(command); | |
713 }, | |
714 | |
715 /** | |
716 * @param {number} id | 681 * @param {number} id |
717 * @param {?string} error | 682 * @param {?string} error |
718 */ | 683 */ |
719 embedderMessageAck: function(id, error) | 684 embedderMessageAck: function(id, error) |
720 { | 685 { |
721 InspectorFrontendHost["embedderMessageAck"](id, error); | 686 InspectorFrontendHost["embedderMessageAck"](id, error); |
722 } | 687 } |
723 } | 688 } |
724 | 689 |
725 var InspectorFrontendAPI = new InspectorFrontendAPIImpl(); | 690 var InspectorFrontendAPI = new InspectorFrontendAPIImpl(); |
OLD | NEW |