Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(512)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/Script.js

Issue 2851913002: [DevTools] Do not expose agents on Target
Patch Set: storage and tests.js Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 12 matching lines...) Expand all
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 /** 26 /**
27 * @implements {Common.ContentProvider} 27 * @implements {Common.ContentProvider}
28 * @unrestricted 28 * @unrestricted
29 */ 29 */
30 SDK.Script = class { 30 SDK.Script = class {
31 /** 31 /**
32 * @param {!SDK.DebuggerModel} debuggerModel 32 * @param {!SDK.DebuggerModel} debuggerModel
33 * @param {!Protocol.DebuggerAgent} debuggerAgent
33 * @param {string} scriptId 34 * @param {string} scriptId
34 * @param {string} sourceURL 35 * @param {string} sourceURL
35 * @param {number} startLine 36 * @param {number} startLine
36 * @param {number} startColumn 37 * @param {number} startColumn
37 * @param {number} endLine 38 * @param {number} endLine
38 * @param {number} endColumn 39 * @param {number} endColumn
39 * @param {!Protocol.Runtime.ExecutionContextId} executionContextId 40 * @param {!Protocol.Runtime.ExecutionContextId} executionContextId
40 * @param {string} hash 41 * @param {string} hash
41 * @param {boolean} isContentScript 42 * @param {boolean} isContentScript
42 * @param {boolean} isLiveEdit 43 * @param {boolean} isLiveEdit
43 * @param {string|undefined} sourceMapURL 44 * @param {string|undefined} sourceMapURL
44 * @param {boolean} hasSourceURL 45 * @param {boolean} hasSourceURL
45 * @param {number} length 46 * @param {number} length
46 */ 47 */
47 constructor( 48 constructor(
48 debuggerModel, scriptId, sourceURL, startLine, startColumn, endLine, endCo lumn, executionContextId, hash, 49 debuggerModel, debuggerAgent, scriptId, sourceURL, startLine, startColumn, endLine, endColumn, executionContextId,
49 isContentScript, isLiveEdit, sourceMapURL, hasSourceURL, length) { 50 hash, isContentScript, isLiveEdit, sourceMapURL, hasSourceURL, length) {
50 this.debuggerModel = debuggerModel; 51 this.debuggerModel = debuggerModel;
52 this._debuggerAgent = debuggerAgent;
51 this.scriptId = scriptId; 53 this.scriptId = scriptId;
52 this.sourceURL = sourceURL; 54 this.sourceURL = sourceURL;
53 this.lineOffset = startLine; 55 this.lineOffset = startLine;
54 this.columnOffset = startColumn; 56 this.columnOffset = startColumn;
55 this.endLine = endLine; 57 this.endLine = endLine;
56 this.endColumn = endColumn; 58 this.endColumn = endColumn;
57 59
58 this.executionContextId = executionContextId; 60 this.executionContextId = executionContextId;
59 this.hash = hash; 61 this.hash = hash;
60 this._isContentScript = isContentScript; 62 this._isContentScript = isContentScript;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 * @return {!Promise<?string>} 130 * @return {!Promise<?string>}
129 */ 131 */
130 requestContent() { 132 requestContent() {
131 if (this._source) 133 if (this._source)
132 return Promise.resolve(this._source); 134 return Promise.resolve(this._source);
133 if (!this.scriptId) 135 if (!this.scriptId)
134 return Promise.resolve(/** @type {?string} */ ('')); 136 return Promise.resolve(/** @type {?string} */ (''));
135 137
136 var callback; 138 var callback;
137 var promise = new Promise(fulfill => callback = fulfill); 139 var promise = new Promise(fulfill => callback = fulfill);
138 this.debuggerModel.target().debuggerAgent().getScriptSource(this.scriptId, d idGetScriptSource.bind(this)); 140 this._debuggerAgent.getScriptSource(this.scriptId, didGetScriptSource.bind(t his));
139 return promise; 141 return promise;
140 142
141 /** 143 /**
142 * @this {SDK.Script} 144 * @this {SDK.Script}
143 * @param {?Protocol.Error} error 145 * @param {?Protocol.Error} error
144 * @param {string} source 146 * @param {string} source
145 */ 147 */
146 function didGetScriptSource(error, source) { 148 function didGetScriptSource(error, source) {
147 this._source = error ? '' : SDK.Script._trimSourceURLComment(source); 149 this._source = error ? '' : SDK.Script._trimSourceURLComment(source);
148 if (this._originalSource === null) 150 if (this._originalSource === null)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 for (var i = 0; i < searchMatches.length; ++i) { 187 for (var i = 0; i < searchMatches.length; ++i) {
186 var searchMatch = 188 var searchMatch =
187 new Common.ContentProvider.SearchMatch(searchMatches[i].lineNumber, searchMatches[i].lineContent); 189 new Common.ContentProvider.SearchMatch(searchMatches[i].lineNumber, searchMatches[i].lineContent);
188 result.push(searchMatch); 190 result.push(searchMatch);
189 } 191 }
190 callback(result || []); 192 callback(result || []);
191 } 193 }
192 194
193 if (this.scriptId) { 195 if (this.scriptId) {
194 // Script failed to parse. 196 // Script failed to parse.
195 this.debuggerModel.target().debuggerAgent().searchInContent( 197 this._debuggerAgent.searchInContent(this.scriptId, query, caseSensitive, i sRegex, innerCallback);
196 this.scriptId, query, caseSensitive, isRegex, innerCallback);
197 } else { 198 } else {
198 callback([]); 199 callback([]);
199 } 200 }
200 } 201 }
201 202
202 /** 203 /**
203 * @param {string} source 204 * @param {string} source
204 * @return {string} 205 * @return {string}
205 */ 206 */
206 _appendSourceURLCommentIfNeeded(source) { 207 _appendSourceURLCommentIfNeeded(source) {
(...skipping 21 matching lines...) Expand all
228 var needsStepIn = !!stackChanged; 229 var needsStepIn = !!stackChanged;
229 callback(error, exceptionDetails, callFrames, asyncStackTrace, needsStepIn ); 230 callback(error, exceptionDetails, callFrames, asyncStackTrace, needsStepIn );
230 } 231 }
231 232
232 newSource = SDK.Script._trimSourceURLComment(newSource); 233 newSource = SDK.Script._trimSourceURLComment(newSource);
233 // We append correct sourceURL to script for consistency only. It's not actu ally needed for things to work correctly. 234 // We append correct sourceURL to script for consistency only. It's not actu ally needed for things to work correctly.
234 newSource = this._appendSourceURLCommentIfNeeded(newSource); 235 newSource = this._appendSourceURLCommentIfNeeded(newSource);
235 236
236 if (this.scriptId) { 237 if (this.scriptId) {
237 this.requestContent().then( 238 this.requestContent().then(
238 () => this.debuggerModel.target().debuggerAgent().setScriptSource( 239 () =>
239 this.scriptId, newSource, undefined, didEditScriptSource.bind(this ))); 240 this._debuggerAgent.setScriptSource(this.scriptId, newSource, unde fined, didEditScriptSource.bind(this)));
240 } else { 241 } else {
241 callback('Script failed to parse'); 242 callback('Script failed to parse');
242 } 243 }
243 } 244 }
244 245
245 /** 246 /**
246 * @param {number} lineNumber 247 * @param {number} lineNumber
247 * @param {number=} columnNumber 248 * @param {number=} columnNumber
248 * @return {!SDK.DebuggerModel.Location} 249 * @return {!SDK.DebuggerModel.Location}
249 */ 250 */
(...skipping 29 matching lines...) Expand all
279 */ 280 */
280 setBlackboxedRanges(positions) { 281 setBlackboxedRanges(positions) {
281 return new Promise(setBlackboxedRanges.bind(this)); 282 return new Promise(setBlackboxedRanges.bind(this));
282 283
283 /** 284 /**
284 * @param {function(?)} fulfill 285 * @param {function(?)} fulfill
285 * @param {function(*)} reject 286 * @param {function(*)} reject
286 * @this {SDK.Script} 287 * @this {SDK.Script}
287 */ 288 */
288 function setBlackboxedRanges(fulfill, reject) { 289 function setBlackboxedRanges(fulfill, reject) {
289 this.debuggerModel.target().debuggerAgent().setBlackboxedRanges(this.scrip tId, positions, callback); 290 this._debuggerAgent.setBlackboxedRanges(this.scriptId, positions, callback );
290 /** 291 /**
291 * @param {?Protocol.Error} error 292 * @param {?Protocol.Error} error
292 */ 293 */
293 function callback(error) { 294 function callback(error) {
294 if (error) 295 if (error)
295 console.error(error); 296 console.error(error);
296 fulfill(!error); 297 fulfill(!error);
297 } 298 }
298 } 299 }
299 } 300 }
300 }; 301 };
301 302
302 SDK.Script.sourceURLRegex = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m; 303 SDK.Script.sourceURLRegex = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698