| 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 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 */ | 939 */ |
| 940 setChecked: function(value) | 940 setChecked: function(value) |
| 941 { | 941 { |
| 942 this.inputElement.checked = value; | 942 this.inputElement.checked = value; |
| 943 }, | 943 }, |
| 944 | 944 |
| 945 __proto__: WebInspector.ToolbarItem.prototype | 945 __proto__: WebInspector.ToolbarItem.prototype |
| 946 } | 946 } |
| 947 | 947 |
| 948 /** | 948 /** |
| 949 * @constructor | 949 * @param {!WebInspector.Toolbar} toolbar |
| 950 * @extends {WebInspector.Toolbar} | |
| 951 * @param {string} location | 950 * @param {string} location |
| 952 * @param {!Element=} parentElement | |
| 953 */ | 951 */ |
| 954 WebInspector.ExtensibleToolbar = function(location, parentElement) | 952 WebInspector.Toolbar.appendLocationItems = function(toolbar, location) |
| 955 { | 953 { |
| 956 WebInspector.Toolbar.call(this, "", parentElement); | 954 var extensions = self.runtime.extensions(WebInspector.ToolbarItem.Provider); |
| 957 this._loadItems(location); | 955 var promises = []; |
| 958 } | 956 for (var i = 0; i < extensions.length; ++i) { |
| 957 if (extensions[i].descriptor()["location"] === location) |
| 958 promises.push(resolveItem(extensions[i])); |
| 959 } |
| 960 Promise.all(promises).then(appendItemsInOrder); |
| 959 | 961 |
| 960 WebInspector.ExtensibleToolbar.prototype = { | |
| 961 /** | 962 /** |
| 962 * @param {string} location | 963 * @param {!Runtime.Extension} extension |
| 964 * @return {!Promise.<?WebInspector.ToolbarItem>} |
| 963 */ | 965 */ |
| 964 _loadItems: function(location) | 966 function resolveItem(extension) |
| 965 { | 967 { |
| 966 var extensions = self.runtime.extensions(WebInspector.ToolbarItem.Provid
er); | 968 var descriptor = extension.descriptor(); |
| 967 var promises = []; | 969 if (descriptor["separator"]) |
| 968 for (var i = 0; i < extensions.length; ++i) { | 970 return Promise.resolve(/** @type {?WebInspector.ToolbarItem} */(new
WebInspector.ToolbarSeparator())); |
| 969 if (extensions[i].descriptor()["location"] === location) | 971 if (descriptor["actionId"]) |
| 970 promises.push(resolveItem(extensions[i])); | 972 return Promise.resolve(WebInspector.Toolbar.createActionButtonForId(
descriptor["actionId"])); |
| 971 } | 973 return extension.instance().then(fetchItemFromProvider); |
| 972 Promise.all(promises).then(appendItemsInOrder.bind(this)); | |
| 973 | 974 |
| 974 /** | 975 /** |
| 975 * @param {!Runtime.Extension} extension | 976 * @param {!Object} provider |
| 976 * @return {!Promise.<?WebInspector.ToolbarItem>} | |
| 977 */ | 977 */ |
| 978 function resolveItem(extension) | 978 function fetchItemFromProvider(provider) |
| 979 { | 979 { |
| 980 var descriptor = extension.descriptor(); | 980 return /** @type {!WebInspector.ToolbarItem.Provider} */ (provider).
item(); |
| 981 if (descriptor["separator"]) | 981 } |
| 982 return Promise.resolve(/** @type {?WebInspector.ToolbarItem} */(
new WebInspector.ToolbarSeparator())); | 982 } |
| 983 if (descriptor["actionId"]) | |
| 984 return Promise.resolve(WebInspector.Toolbar.createActionButtonFo
rId(descriptor["actionId"])); | |
| 985 return extension.instance().then(fetchItemFromProvider); | |
| 986 | 983 |
| 987 /** | 984 /** |
| 988 * @param {!Object} provider | 985 * @param {!Array.<?WebInspector.ToolbarItem>} items |
| 989 */ | 986 */ |
| 990 function fetchItemFromProvider(provider) | 987 function appendItemsInOrder(items) |
| 991 { | 988 { |
| 992 return /** @type {!WebInspector.ToolbarItem.Provider} */ (provid
er).item(); | 989 for (var i = 0; i < items.length; ++i) { |
| 993 } | 990 var item = items[i]; |
| 991 if (item) |
| 992 toolbar.appendToolbarItem(item); |
| 994 } | 993 } |
| 995 | 994 } |
| 996 /** | |
| 997 * @param {!Array.<?WebInspector.ToolbarItem>} items | |
| 998 * @this {WebInspector.ExtensibleToolbar} | |
| 999 */ | |
| 1000 function appendItemsInOrder(items) | |
| 1001 { | |
| 1002 for (var i = 0; i < items.length; ++i) { | |
| 1003 var item = items[i]; | |
| 1004 if (item) | |
| 1005 this.appendToolbarItem(item); | |
| 1006 } | |
| 1007 } | |
| 1008 }, | |
| 1009 | |
| 1010 __proto__: WebInspector.Toolbar.prototype | |
| 1011 } | 995 } |
| OLD | NEW |