OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 this._registerHandler(commands.OpenResource, this._onOpenResource.bind(this)
); | 80 this._registerHandler(commands.OpenResource, this._onOpenResource.bind(this)
); |
81 this._registerHandler(commands.Unsubscribe, this._onUnsubscribe.bind(this)); | 81 this._registerHandler(commands.Unsubscribe, this._onUnsubscribe.bind(this)); |
82 this._registerHandler(commands.UpdateButton, this._onUpdateButton.bind(this)
); | 82 this._registerHandler(commands.UpdateButton, this._onUpdateButton.bind(this)
); |
83 this._registerHandler(commands.UpdateAuditProgress, this._onUpdateAuditProgr
ess.bind(this)); | 83 this._registerHandler(commands.UpdateAuditProgress, this._onUpdateAuditProgr
ess.bind(this)); |
84 window.addEventListener("message", this._onWindowMessage.bind(this), false);
// Only for main window. | 84 window.addEventListener("message", this._onWindowMessage.bind(this), false);
// Only for main window. |
85 | 85 |
86 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.AddExtensions, this._addExtensions, this); | 86 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.AddExtensions, this._addExtensions, this); |
87 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.SetInspectedTabId, this._setInspectedTabId, this); | 87 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.SetInspectedTabId, this._setInspectedTabId, this); |
88 | 88 |
89 this._initExtensions(); | 89 this._initExtensions(); |
90 } | 90 }; |
91 | 91 |
92 /** @enum {symbol} */ | 92 /** @enum {symbol} */ |
93 WebInspector.ExtensionServer.Events = { | 93 WebInspector.ExtensionServer.Events = { |
94 SidebarPaneAdded: Symbol("SidebarPaneAdded"), | 94 SidebarPaneAdded: Symbol("SidebarPaneAdded"), |
95 AuditCategoryAdded: Symbol("AuditCategoryAdded") | 95 AuditCategoryAdded: Symbol("AuditCategoryAdded") |
96 } | 96 }; |
97 | 97 |
98 WebInspector.ExtensionServer.prototype = { | 98 WebInspector.ExtensionServer.prototype = { |
99 initializeExtensions: function() | 99 initializeExtensions: function() |
100 { | 100 { |
101 this._initializeCommandIssued = true; | 101 this._initializeCommandIssued = true; |
102 if (this._pendingExtensionInfos) { | 102 if (this._pendingExtensionInfos) { |
103 this._pendingExtensionInfos.forEach(this._addExtension, this); | 103 this._pendingExtensionInfos.forEach(this._addExtension, this); |
104 delete this._pendingExtensionInfos; | 104 delete this._pendingExtensionInfos; |
105 } | 105 } |
106 }, | 106 }, |
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 var context; | 1006 var context; |
1007 var executionContexts = frame.target().runtimeModel.executionContext
s(); | 1007 var executionContexts = frame.target().runtimeModel.executionContext
s(); |
1008 if (contextSecurityOrigin) { | 1008 if (contextSecurityOrigin) { |
1009 for (var i = 0; i < executionContexts.length; ++i) { | 1009 for (var i = 0; i < executionContexts.length; ++i) { |
1010 var executionContext = executionContexts[i]; | 1010 var executionContext = executionContexts[i]; |
1011 if (executionContext.frameId === frame.id && executionContex
t.origin === contextSecurityOrigin && !executionContext.isDefault) | 1011 if (executionContext.frameId === frame.id && executionContex
t.origin === contextSecurityOrigin && !executionContext.isDefault) |
1012 context = executionContext; | 1012 context = executionContext; |
1013 | 1013 |
1014 } | 1014 } |
1015 if (!context) { | 1015 if (!context) { |
1016 console.warn("The JavaScript context " + contextSecurityOrig
in + " was not found in the frame " + frame.url) | 1016 console.warn("The JavaScript context " + contextSecurityOrig
in + " was not found in the frame " + frame.url); |
1017 return this._status.E_NOTFOUND(contextSecurityOrigin) | 1017 return this._status.E_NOTFOUND(contextSecurityOrigin); |
1018 } | 1018 } |
1019 } else { | 1019 } else { |
1020 for (var i = 0; i < executionContexts.length; ++i) { | 1020 for (var i = 0; i < executionContexts.length; ++i) { |
1021 var executionContext = executionContexts[i]; | 1021 var executionContext = executionContexts[i]; |
1022 if (executionContext.frameId === frame.id && executionContex
t.isDefault) | 1022 if (executionContext.frameId === frame.id && executionContex
t.isDefault) |
1023 context = executionContext; | 1023 context = executionContext; |
1024 | 1024 |
1025 } | 1025 } |
1026 if (!context) | 1026 if (!context) |
1027 return this._status.E_FAILED(frame.url + " has no execution
context"); | 1027 return this._status.E_FAILED(frame.url + " has no execution
context"); |
(...skipping 16 matching lines...) Expand all Loading... |
1044 { | 1044 { |
1045 if (error) { | 1045 if (error) { |
1046 callback(error, null, !!exceptionDetails); | 1046 callback(error, null, !!exceptionDetails); |
1047 return; | 1047 return; |
1048 } | 1048 } |
1049 callback(error, target.runtimeModel.createRemoteObject(result), !!ex
ceptionDetails); | 1049 callback(error, target.runtimeModel.createRemoteObject(result), !!ex
ceptionDetails); |
1050 } | 1050 } |
1051 }, | 1051 }, |
1052 | 1052 |
1053 __proto__: WebInspector.Object.prototype | 1053 __proto__: WebInspector.Object.prototype |
1054 } | 1054 }; |
1055 | 1055 |
1056 /** | 1056 /** |
1057 * @constructor | 1057 * @constructor |
1058 * @param {string} name | 1058 * @param {string} name |
1059 * @param {string} title | 1059 * @param {string} title |
1060 * @param {!WebInspector.Panel} panel | 1060 * @param {!WebInspector.Panel} panel |
1061 * @extends {WebInspector.SimpleView} | 1061 * @extends {WebInspector.SimpleView} |
1062 */ | 1062 */ |
1063 WebInspector.ExtensionServerPanelView = function(name, title, panel) | 1063 WebInspector.ExtensionServerPanelView = function(name, title, panel) |
1064 { | 1064 { |
1065 WebInspector.SimpleView.call(this, title); | 1065 WebInspector.SimpleView.call(this, title); |
1066 this._name = name; | 1066 this._name = name; |
1067 this._panel = panel; | 1067 this._panel = panel; |
1068 } | 1068 }; |
1069 | 1069 |
1070 WebInspector.ExtensionServerPanelView.prototype = { | 1070 WebInspector.ExtensionServerPanelView.prototype = { |
1071 /** | 1071 /** |
1072 * @override | 1072 * @override |
1073 * @return {string} | 1073 * @return {string} |
1074 */ | 1074 */ |
1075 viewId: function() | 1075 viewId: function() |
1076 { | 1076 { |
1077 return this._name; | 1077 return this._name; |
1078 }, | 1078 }, |
1079 | 1079 |
1080 /** | 1080 /** |
1081 * @override | 1081 * @override |
1082 * @return {!Promise.<!WebInspector.Widget>} | 1082 * @return {!Promise.<!WebInspector.Widget>} |
1083 */ | 1083 */ |
1084 widget: function() | 1084 widget: function() |
1085 { | 1085 { |
1086 return /** @type {!Promise.<!WebInspector.Widget>} */ (Promise.resolve(t
his._panel)); | 1086 return /** @type {!Promise.<!WebInspector.Widget>} */ (Promise.resolve(t
his._panel)); |
1087 }, | 1087 }, |
1088 | 1088 |
1089 __proto__: WebInspector.SimpleView.prototype | 1089 __proto__: WebInspector.SimpleView.prototype |
1090 } | 1090 }; |
1091 | 1091 |
1092 /** | 1092 /** |
1093 * @constructor | 1093 * @constructor |
1094 */ | 1094 */ |
1095 WebInspector.ExtensionStatus = function() | 1095 WebInspector.ExtensionStatus = function() |
1096 { | 1096 { |
1097 /** | 1097 /** |
1098 * @param {string} code | 1098 * @param {string} code |
1099 * @param {string} description | 1099 * @param {string} description |
1100 * @return {!WebInspector.ExtensionStatus.Record} | 1100 * @return {!WebInspector.ExtensionStatus.Record} |
(...skipping 10 matching lines...) Expand all Loading... |
1111 } | 1111 } |
1112 | 1112 |
1113 this.OK = makeStatus.bind(null, "OK", "OK"); | 1113 this.OK = makeStatus.bind(null, "OK", "OK"); |
1114 this.E_EXISTS = makeStatus.bind(null, "E_EXISTS", "Object already exists: %s
"); | 1114 this.E_EXISTS = makeStatus.bind(null, "E_EXISTS", "Object already exists: %s
"); |
1115 this.E_BADARG = makeStatus.bind(null, "E_BADARG", "Invalid argument %s: %s")
; | 1115 this.E_BADARG = makeStatus.bind(null, "E_BADARG", "Invalid argument %s: %s")
; |
1116 this.E_BADARGTYPE = makeStatus.bind(null, "E_BADARGTYPE", "Invalid type for
argument %s: got %s, expected %s"); | 1116 this.E_BADARGTYPE = makeStatus.bind(null, "E_BADARGTYPE", "Invalid type for
argument %s: got %s, expected %s"); |
1117 this.E_NOTFOUND = makeStatus.bind(null, "E_NOTFOUND", "Object not found: %s"
); | 1117 this.E_NOTFOUND = makeStatus.bind(null, "E_NOTFOUND", "Object not found: %s"
); |
1118 this.E_NOTSUPPORTED = makeStatus.bind(null, "E_NOTSUPPORTED", "Object does n
ot support requested operation: %s"); | 1118 this.E_NOTSUPPORTED = makeStatus.bind(null, "E_NOTSUPPORTED", "Object does n
ot support requested operation: %s"); |
1119 this.E_PROTOCOLERROR = makeStatus.bind(null, "E_PROTOCOLERROR", "Inspector p
rotocol error: %s"); | 1119 this.E_PROTOCOLERROR = makeStatus.bind(null, "E_PROTOCOLERROR", "Inspector p
rotocol error: %s"); |
1120 this.E_FAILED = makeStatus.bind(null, "E_FAILED", "Operation failed: %s"); | 1120 this.E_FAILED = makeStatus.bind(null, "E_FAILED", "Operation failed: %s"); |
1121 } | 1121 }; |
1122 | 1122 |
1123 /** | 1123 /** |
1124 * @typedef {{code: string, description: string, details: !Array.<*>}} | 1124 * @typedef {{code: string, description: string, details: !Array.<*>}} |
1125 */ | 1125 */ |
1126 WebInspector.ExtensionStatus.Record; | 1126 WebInspector.ExtensionStatus.Record; |
1127 | 1127 |
1128 WebInspector.extensionAPI = {}; | 1128 WebInspector.extensionAPI = {}; |
1129 defineCommonExtensionSymbols(WebInspector.extensionAPI); | 1129 defineCommonExtensionSymbols(WebInspector.extensionAPI); |
1130 | 1130 |
1131 /** @type {!WebInspector.ExtensionServer} */ | 1131 /** @type {!WebInspector.ExtensionServer} */ |
1132 WebInspector.extensionServer; | 1132 WebInspector.extensionServer; |
OLD | NEW |