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

Side by Side Diff: chrome/browser/resources/md_extensions/code_section.js

Issue 2769293002: [MD Extensions] Include the manifest code snippet in load errors (Closed)
Patch Set: . Created 3 years, 9 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('extensions', function() { 5 cr.define('extensions', function() {
6 'use strict'; 6 'use strict';
7 7
8 var CodeSection = Polymer({ 8 var CodeSection = Polymer({
9 is: 'extensions-code-section', 9 is: 'extensions-code-section',
10 10
11 properties: { 11 properties: {
12 /** 12 /**
13 * The code this object is displaying. 13 * The code this object is displaying.
14 * @type {?chrome.developerPrivate.RequestFileSourceResponse} 14 * @type {?chrome.developerPrivate.RequestFileSourceResponse}
15 */ 15 */
16 code: { 16 code: {
17 type: Object, 17 type: Object,
18 // We initialize to null so that Polymer sees it as defined and calls 18 // We initialize to null so that Polymer sees it as defined and calls
19 // isMainHidden_(). 19 // isMainHidden_().
20 value: null, 20 value: null,
21 }, 21 },
22 22
23 /** 23 /**
24 * The string to display if no code is set. 24 * The string to display if no code is set.
25 * @type {string} 25 * @type {string}
26 */ 26 */
27 noCodeError: String, 27 noCodeError: String,
michaelpg 2017/03/24 02:59:01 I might just be silly, but I'm not sure which of t
Devlin 2017/03/24 16:03:08 It's actually the first - we fail to load the rele
28 }, 28 },
29 29
30 /** 30 /**
31 * Computes the content of the line numbers span, which basically just 31 * Computes the content of the line numbers span, which basically just
32 * contains 1\n2\n3\n... for the number of lines. 32 * contains 1\n2\n3\n... for the number of lines.
33 * @return {string} 33 * @return {string}
34 * @private 34 * @private
35 */ 35 */
36 computeLineNumbersContent_: function() { 36 computeLineNumbersContent_: function() {
37 if (!this.code) 37 if (!this.code)
38 return ''; 38 return '';
39 39
40 var lines = [this.code.beforeHighlight, 40 var lines = [this.code.beforeHighlight,
41 this.code.highlight, 41 this.code.highlight,
42 this.code.afterHighlight].join('').match(/\n/g); 42 this.code.afterHighlight].join('').match(/\n/g);
43 var lineCount = lines ? lines.length : 0; 43 var lineCount = lines ? lines.length : 0;
44 var textContent = ''; 44 var textContent = '';
45 for (var i = 1; i <= lineCount; ++i) 45 for (var i = 1; i <= lineCount; ++i)
46 textContent += i + '\n'; 46 textContent += i + '\n';
47 return textContent; 47 return textContent;
48 }, 48 },
49 49
50 /** 50 /**
51 * Returns true if no code could be displayed.
michaelpg 2017/03/24 02:59:01 As above, I'm asking myself *why* the code couldn'
Devlin 2017/03/24 16:03:08 added "e.g. because the file could not be loaded."
51 * @return {boolean} 52 * @return {boolean}
52 * @private
53 */ 53 */
54 isMainHidden_: function() { 54 isEmpty: function() {
michaelpg 2017/03/24 02:59:01 nit: move above @private method
Devlin 2017/03/24 16:03:08 Done.
55 return !this.code; 55 return !this.code ||
56 (!this.code.beforeHighlight && !this.code.highlight &&
57 !this.code.afterHighlight);
56 }, 58 },
57 }); 59 });
58 60
59 return {CodeSection: CodeSection}; 61 return {CodeSection: CodeSection};
60 }); 62 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698