OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <include src="extension_error.js"> | 5 <include src="extension_error.js"> |
6 | 6 |
7 /////////////////////////////////////////////////////////////////////////////// | 7 /////////////////////////////////////////////////////////////////////////////// |
8 // ExtensionFocusRow: | 8 // ExtensionFocusRow: |
9 | 9 |
10 /** | 10 /** |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 chrome.developerPrivate.onItemStateChanged.addListener( | 263 chrome.developerPrivate.onItemStateChanged.addListener( |
264 function(eventData) { | 264 function(eventData) { |
265 var EventType = chrome.developerPrivate.EventType; | 265 var EventType = chrome.developerPrivate.EventType; |
266 switch (eventData.event_type) { | 266 switch (eventData.event_type) { |
267 case EventType.VIEW_REGISTERED: | 267 case EventType.VIEW_REGISTERED: |
268 case EventType.VIEW_UNREGISTERED: | 268 case EventType.VIEW_UNREGISTERED: |
269 case EventType.INSTALLED: | 269 case EventType.INSTALLED: |
270 case EventType.LOADED: | 270 case EventType.LOADED: |
271 case EventType.UNLOADED: | 271 case EventType.UNLOADED: |
272 case EventType.ERROR_ADDED: | 272 case EventType.ERROR_ADDED: |
| 273 case EventType.ERRORS_REMOVED: |
273 case EventType.PREFS_CHANGED: | 274 case EventType.PREFS_CHANGED: |
274 if (eventData.extensionInfo) | 275 if (eventData.extensionInfo) |
275 this.updateExtension_(eventData.extensionInfo); | 276 this.updateExtension_(eventData.extensionInfo); |
276 break; | 277 break; |
277 case EventType.UNINSTALLED: | 278 case EventType.UNINSTALLED: |
278 var index = this.getIndexOfExtension_(eventData.item_id); | 279 var index = this.getIndexOfExtension_(eventData.item_id); |
279 this.extensions_.splice(index, 1); | 280 this.extensions_.splice(index, 1); |
280 var childNode = $(eventData.item_id); | 281 var childNode = $(eventData.item_id); |
281 childNode.parentNode.removeChild(childNode); | 282 childNode.parentNode.removeChild(childNode); |
282 break; | 283 break; |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 row.setupColumn('.reload-link', 'localReload', 'click', function(e) { | 550 row.setupColumn('.reload-link', 'localReload', 'click', function(e) { |
550 chrome.developerPrivate.reload(extension.id, {failQuietly: true}); | 551 chrome.developerPrivate.reload(extension.id, {failQuietly: true}); |
551 extensionReloadedTimestamp[extension.id] = Date.now(); | 552 extensionReloadedTimestamp[extension.id] = Date.now(); |
552 }); | 553 }); |
553 | 554 |
554 // The 'Launch' link. | 555 // The 'Launch' link. |
555 row.setupColumn('.launch-link', 'launch', 'click', function(e) { | 556 row.setupColumn('.launch-link', 'launch', 'click', function(e) { |
556 chrome.management.launchApp(extension.id); | 557 chrome.management.launchApp(extension.id); |
557 }); | 558 }); |
558 | 559 |
| 560 row.setupColumn('.errors-link', 'errors', 'click', function(e) { |
| 561 var extensionId = extension.id; |
| 562 assert(this.extensions_.length > 0); |
| 563 var newEx = this.extensions_.filter(function(e) { |
| 564 return e.state == chrome.developerPrivate.ExtensionState.ENABLED && |
| 565 e.id == extensionId; |
| 566 })[0]; |
| 567 var errors = newEx.manifestErrors.concat(newEx.runtimeErrors); |
| 568 extensions.ExtensionErrorOverlay.getInstance().setErrorsAndShowOverlay( |
| 569 errors, extensionId, newEx.name); |
| 570 }.bind(this)); |
| 571 |
559 // The 'Reload' terminated link. | 572 // The 'Reload' terminated link. |
560 row.setupColumn('.terminated-reload-link', 'terminatedReload', 'click', | 573 row.setupColumn('.terminated-reload-link', 'terminatedReload', 'click', |
561 function(e) { | 574 function(e) { |
562 chrome.developerPrivate.reload(extension.id, {failQuietly: true}); | 575 chrome.developerPrivate.reload(extension.id, {failQuietly: true}); |
563 }); | 576 }); |
564 | 577 |
565 // The 'Repair' corrupted link. | 578 // The 'Repair' corrupted link. |
566 row.setupColumn('.corrupted-repair-button', 'repair', 'click', | 579 row.setupColumn('.corrupted-repair-button', 'repair', 'click', |
567 function(e) { | 580 function(e) { |
568 chrome.developerPrivate.repairExtension(extension.id); | 581 chrome.developerPrivate.repairExtension(extension.id); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 extension.location == chrome.developerPrivate.Location.UNPACKED; | 762 extension.location == chrome.developerPrivate.Location.UNPACKED; |
750 // The 'Reload' link. | 763 // The 'Reload' link. |
751 this.updateVisibility_(row, '.reload-link', isUnpacked); | 764 this.updateVisibility_(row, '.reload-link', isUnpacked); |
752 | 765 |
753 // The 'Launch' link. | 766 // The 'Launch' link. |
754 this.updateVisibility_( | 767 this.updateVisibility_( |
755 row, '.launch-link', | 768 row, '.launch-link', |
756 isUnpacked && extension.type == | 769 isUnpacked && extension.type == |
757 chrome.developerPrivate.ExtensionType.PLATFORM_APP); | 770 chrome.developerPrivate.ExtensionType.PLATFORM_APP); |
758 | 771 |
| 772 // The 'Errors' link. |
| 773 var hasErrors = extension.runtimeErrors.length > 0 || |
| 774 extension.manifestErrors.length > 0; |
| 775 this.updateVisibility_(row, '.errors-link', hasErrors, function(item) { |
| 776 var Level = chrome.developerPrivate.ErrorLevel; |
| 777 |
| 778 var map = {}; |
| 779 map[Level.LOG] = {weight: 0, name: 'extension-error-info-icon'}; |
| 780 map[Level.WARN] = {weight: 1, name: 'extension-error-warning-icon'}; |
| 781 map[Level.ERROR] = {weight: 2, name: 'extension-error-fatal-icon'}; |
| 782 |
| 783 // Find the highest severity of all the errors; manifest errors all have |
| 784 // a 'warning' level severity. |
| 785 var highestSeverity = extension.runtimeErrors.reduce( |
| 786 function(prev, error) { |
| 787 return map[error.severity].weight > map[prev].weight ? |
| 788 error.severity : prev; |
| 789 }, extension.manifestErrors.length ? Level.WARN : Level.LOG); |
| 790 |
| 791 // Adjust the class on the icon. |
| 792 var icon = item.querySelector('.extension-error-icon'); |
| 793 // TODO(hcarmona): Populate alt text with a proper description since |
| 794 // this icon conveys the severity of the error. (info, warning, fatal). |
| 795 icon.alt = ''; |
| 796 icon.className = 'extension-error-icon'; // Remove other classes. |
| 797 icon.classList.add(map[highestSeverity].name); |
| 798 }); |
| 799 |
759 // The 'Reload' terminated link. | 800 // The 'Reload' terminated link. |
760 var isTerminated = | 801 var isTerminated = |
761 extension.state == chrome.developerPrivate.ExtensionState.TERMINATED; | 802 extension.state == chrome.developerPrivate.ExtensionState.TERMINATED; |
762 this.updateVisibility_(row, '.terminated-reload-link', isTerminated); | 803 this.updateVisibility_(row, '.terminated-reload-link', isTerminated); |
763 | 804 |
764 // The 'Repair' corrupted link. | 805 // The 'Repair' corrupted link. |
765 var canRepair = !isTerminated && | 806 var canRepair = !isTerminated && |
766 extension.disableReasons.corruptInstall && | 807 extension.disableReasons.corruptInstall && |
767 extension.location == | 808 extension.location == |
768 chrome.developerPrivate.Location.FROM_STORE; | 809 chrome.developerPrivate.Location.FROM_STORE; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
934 extension.runtimeWarnings.length > 0, | 975 extension.runtimeWarnings.length > 0, |
935 function(item) { | 976 function(item) { |
936 var warningList = item.querySelector('ul'); | 977 var warningList = item.querySelector('ul'); |
937 warningList.textContent = ''; | 978 warningList.textContent = ''; |
938 extension.runtimeWarnings.forEach(function(warning) { | 979 extension.runtimeWarnings.forEach(function(warning) { |
939 var li = document.createElement('li'); | 980 var li = document.createElement('li'); |
940 warningList.appendChild(li).innerText = warning; | 981 warningList.appendChild(li).innerText = warning; |
941 }); | 982 }); |
942 }); | 983 }); |
943 | 984 |
944 // If the ErrorConsole is enabled, we should have manifest and/or runtime | |
945 // errors. Otherwise, we may have install warnings. We should not have | |
946 // both ErrorConsole errors and install warnings. | |
947 // Errors. | |
948 this.updateErrors_(row.querySelector('.manifest-errors'), | |
949 'dev-manifestErrors', extension.manifestErrors); | |
950 this.updateErrors_(row.querySelector('.runtime-errors'), | |
951 'dev-runtimeErrors', extension.runtimeErrors); | |
952 | |
953 // Install warnings. | 985 // Install warnings. |
954 this.updateVisibility_(row, '.install-warnings', | 986 this.updateVisibility_(row, '.install-warnings', |
955 extension.installWarnings.length > 0, | 987 extension.installWarnings.length > 0, |
956 function(item) { | 988 function(item) { |
957 var installWarningList = item.querySelector('ul'); | 989 var installWarningList = item.querySelector('ul'); |
958 installWarningList.textContent = ''; | 990 installWarningList.textContent = ''; |
959 if (extension.installWarnings) { | 991 if (extension.installWarnings) { |
960 extension.installWarnings.forEach(function(warning) { | 992 extension.installWarnings.forEach(function(warning) { |
961 var li = document.createElement('li'); | 993 var li = document.createElement('li'); |
962 li.innerText = warning; | 994 li.innerText = warning; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 * @private | 1034 * @private |
1003 */ | 1035 */ |
1004 updateVisibility_: function(node, query, visible, opt_shownCallback) { | 1036 updateVisibility_: function(node, query, visible, opt_shownCallback) { |
1005 var item = assert(node.querySelector(query)); | 1037 var item = assert(node.querySelector(query)); |
1006 item.hidden = !visible; | 1038 item.hidden = !visible; |
1007 if (visible && opt_shownCallback) | 1039 if (visible && opt_shownCallback) |
1008 opt_shownCallback(item); | 1040 opt_shownCallback(item); |
1009 }, | 1041 }, |
1010 | 1042 |
1011 /** | 1043 /** |
1012 * Updates an element to show a list of errors. | |
1013 * @param {Element} panel An element to hold the errors. | |
1014 * @param {string} columnType A tag used to identify the column when | |
1015 * changing focus. | |
1016 * @param {Array<RuntimeError|ManifestError>|undefined} errors The errors | |
1017 * to be displayed. | |
1018 * @private | |
1019 */ | |
1020 updateErrors_: function(panel, columnType, errors) { | |
1021 // TODO(hcarmona): Look into updating the ExtensionErrorList rather than | |
1022 // rebuilding it every time. | |
1023 panel.hidden = !errors || errors.length == 0; | |
1024 panel.textContent = ''; | |
1025 | |
1026 if (panel.hidden) | |
1027 return; | |
1028 | |
1029 var errorList = | |
1030 new extensions.ExtensionErrorList(assertInstanceof(errors, Array)); | |
1031 | |
1032 panel.appendChild(errorList); | |
1033 | |
1034 var list = errorList.getErrorListElement(); | |
1035 if (list) | |
1036 list.setAttribute('column-type', columnType + 'list'); | |
1037 | |
1038 var button = errorList.getToggleElement(); | |
1039 if (button) | |
1040 button.setAttribute('column-type', columnType + 'button'); | |
1041 }, | |
1042 | |
1043 /** | |
1044 * Opens the extension options overlay for the extension with the given id. | 1044 * Opens the extension options overlay for the extension with the given id. |
1045 * @param {string} extensionId The id of extension whose options page should | 1045 * @param {string} extensionId The id of extension whose options page should |
1046 * be displayed. | 1046 * be displayed. |
1047 * @param {boolean} scroll Whether the page should scroll to the extension | 1047 * @param {boolean} scroll Whether the page should scroll to the extension |
1048 * @private | 1048 * @private |
1049 */ | 1049 */ |
1050 showEmbeddedExtensionOptions_: function(extensionId, scroll) { | 1050 showEmbeddedExtensionOptions_: function(extensionId, scroll) { |
1051 if (this.optionsShown_) | 1051 if (this.optionsShown_) |
1052 return; | 1052 return; |
1053 | 1053 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 this.createNode_(extension, nextExt ? $(nextExt.id) : null); | 1119 this.createNode_(extension, nextExt ? $(nextExt.id) : null); |
1120 } | 1120 } |
1121 } | 1121 } |
1122 }; | 1122 }; |
1123 | 1123 |
1124 return { | 1124 return { |
1125 ExtensionList: ExtensionList, | 1125 ExtensionList: ExtensionList, |
1126 ExtensionListDelegate: ExtensionListDelegate | 1126 ExtensionListDelegate: ExtensionListDelegate |
1127 }; | 1127 }; |
1128 }); | 1128 }); |
OLD | NEW |