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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 chrome.developerPrivate.onItemStateChanged.addListener( | 238 chrome.developerPrivate.onItemStateChanged.addListener( |
239 function(eventData) { | 239 function(eventData) { |
240 var EventType = chrome.developerPrivate.EventType; | 240 var EventType = chrome.developerPrivate.EventType; |
241 switch (eventData.event_type) { | 241 switch (eventData.event_type) { |
242 case EventType.VIEW_REGISTERED: | 242 case EventType.VIEW_REGISTERED: |
243 case EventType.VIEW_UNREGISTERED: | 243 case EventType.VIEW_UNREGISTERED: |
244 case EventType.INSTALLED: | 244 case EventType.INSTALLED: |
245 case EventType.LOADED: | 245 case EventType.LOADED: |
246 case EventType.UNLOADED: | 246 case EventType.UNLOADED: |
247 case EventType.ERROR_ADDED: | 247 case EventType.ERROR_ADDED: |
| 248 case EventType.ERRORS_REMOVED: |
248 case EventType.PREFS_CHANGED: | 249 case EventType.PREFS_CHANGED: |
249 if (eventData.extensionInfo) | 250 if (eventData.extensionInfo) |
250 this.updateExtension_(eventData.extensionInfo); | 251 this.updateExtension_(eventData.extensionInfo); |
251 break; | 252 break; |
252 case EventType.UNINSTALLED: | 253 case EventType.UNINSTALLED: |
253 var childNode = $(eventData.item_id); | 254 var childNode = $(eventData.item_id); |
254 childNode.parentNode.removeChild(childNode); | 255 childNode.parentNode.removeChild(childNode); |
255 break; | 256 break; |
256 default: | 257 default: |
257 assertNotReached(); | 258 assertNotReached(); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 row.setupColumn('.reload-link', 'localReload', 'click', function(e) { | 482 row.setupColumn('.reload-link', 'localReload', 'click', function(e) { |
482 chrome.developerPrivate.reload(extension.id, {failQuietly: true}); | 483 chrome.developerPrivate.reload(extension.id, {failQuietly: true}); |
483 extensionReloadedTimestamp[extension.id] = Date.now(); | 484 extensionReloadedTimestamp[extension.id] = Date.now(); |
484 }); | 485 }); |
485 | 486 |
486 // The 'Launch' link. | 487 // The 'Launch' link. |
487 row.setupColumn('.launch-link', 'launch', 'click', function(e) { | 488 row.setupColumn('.launch-link', 'launch', 'click', function(e) { |
488 chrome.management.launchApp(extension.id); | 489 chrome.management.launchApp(extension.id); |
489 }); | 490 }); |
490 | 491 |
| 492 row.setupColumn('.errors-link', 'errors', 'click', function(e) { |
| 493 var extensionId = extension.id; |
| 494 assert(this.extensions_.length > 0); |
| 495 var newEx = this.extensions_.filter(function(e) { |
| 496 return e.state == chrome.developerPrivate.ExtensionState.ENABLED && |
| 497 e.id == extensionId; |
| 498 })[0]; |
| 499 var errors = newEx.manifestErrors.concat(newEx.runtimeErrors); |
| 500 extensions.ExtensionErrorOverlay.getInstance().setErrorsAndShowOverlay( |
| 501 errors, extensionId, newEx.name); |
| 502 }.bind(this)); |
| 503 |
491 // The 'Reload' terminated link. | 504 // The 'Reload' terminated link. |
492 row.setupColumn('.terminated-reload-link', 'terminatedReload', 'click', | 505 row.setupColumn('.terminated-reload-link', 'terminatedReload', 'click', |
493 function(e) { | 506 function(e) { |
494 chrome.developerPrivate.reload(extension.id, {failQuietly: true}); | 507 chrome.developerPrivate.reload(extension.id, {failQuietly: true}); |
495 }); | 508 }); |
496 | 509 |
497 // The 'Repair' corrupted link. | 510 // The 'Repair' corrupted link. |
498 row.setupColumn('.corrupted-repair-button', 'repair', 'click', | 511 row.setupColumn('.corrupted-repair-button', 'repair', 'click', |
499 function(e) { | 512 function(e) { |
500 chrome.developerPrivate.repairExtension(extension.id); | 513 chrome.developerPrivate.repairExtension(extension.id); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 extension.location == chrome.developerPrivate.Location.UNPACKED; | 694 extension.location == chrome.developerPrivate.Location.UNPACKED; |
682 // The 'Reload' link. | 695 // The 'Reload' link. |
683 this.updateVisibility_(row, '.reload-link', isUnpacked); | 696 this.updateVisibility_(row, '.reload-link', isUnpacked); |
684 | 697 |
685 // The 'Launch' link. | 698 // The 'Launch' link. |
686 this.updateVisibility_( | 699 this.updateVisibility_( |
687 row, '.launch-link', | 700 row, '.launch-link', |
688 isUnpacked && extension.type == | 701 isUnpacked && extension.type == |
689 chrome.developerPrivate.ExtensionType.PLATFORM_APP); | 702 chrome.developerPrivate.ExtensionType.PLATFORM_APP); |
690 | 703 |
| 704 // The 'Errors' link. |
| 705 var hasErrors = extension.runtimeErrors.length || |
| 706 extension.manifestErrors.length; |
| 707 this.updateVisibility_(row, '.errors-link', hasErrors, function(item) { |
| 708 var Level = chrome.developerPrivate.ErrorLevel; |
| 709 var map = {}; |
| 710 map[Level.LOG] = {weight: 0, name: 'extension-error-info-icon'}; |
| 711 map[Level.WARN] = {weight: 1, name: 'extension-error-warning-icon'}; |
| 712 map[Level.ERROR] = {weight: 2, name: 'extension-error-fatal-icon'}; |
| 713 |
| 714 // Find the highest severity of all the errors; manifest errors all have |
| 715 // a 'warning' level severity. |
| 716 var highSeverity = extension.runtimeErrors.reduce( |
| 717 function(prev, error) { |
| 718 return map[error.severity].weight > map[prev].weight ? |
| 719 error.severity : prev; |
| 720 }, extension.manifestErrors.length ? Level.WARN : Level.LOG); |
| 721 |
| 722 // Adjust the class on the icon. |
| 723 var icon = item.querySelector('.extension-error-icon'); |
| 724 icon.className = 'extension-error-icon'; |
| 725 icon.classList.add(map[highSeverity].name); |
| 726 }); |
| 727 |
691 // The 'Reload' terminated link. | 728 // The 'Reload' terminated link. |
692 var isTerminated = | 729 var isTerminated = |
693 extension.state == chrome.developerPrivate.ExtensionState.TERMINATED; | 730 extension.state == chrome.developerPrivate.ExtensionState.TERMINATED; |
694 this.updateVisibility_(row, '.terminated-reload-link', isTerminated); | 731 this.updateVisibility_(row, '.terminated-reload-link', isTerminated); |
695 | 732 |
696 // The 'Repair' corrupted link. | 733 // The 'Repair' corrupted link. |
697 var canRepair = !isTerminated && | 734 var canRepair = !isTerminated && |
698 extension.disableReasons.corruptInstall && | 735 extension.disableReasons.corruptInstall && |
699 extension.location == | 736 extension.location == |
700 chrome.developerPrivate.Location.FROM_STORE; | 737 chrome.developerPrivate.Location.FROM_STORE; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 extension.runtimeWarnings.length > 0, | 903 extension.runtimeWarnings.length > 0, |
867 function(item) { | 904 function(item) { |
868 var warningList = item.querySelector('ul'); | 905 var warningList = item.querySelector('ul'); |
869 warningList.textContent = ''; | 906 warningList.textContent = ''; |
870 extension.runtimeWarnings.forEach(function(warning) { | 907 extension.runtimeWarnings.forEach(function(warning) { |
871 var li = document.createElement('li'); | 908 var li = document.createElement('li'); |
872 warningList.appendChild(li).innerText = warning; | 909 warningList.appendChild(li).innerText = warning; |
873 }); | 910 }); |
874 }); | 911 }); |
875 | 912 |
876 // If the ErrorConsole is enabled, we should have manifest and/or runtime | |
877 // errors. Otherwise, we may have install warnings. We should not have | |
878 // both ErrorConsole errors and install warnings. | |
879 // Errors. | |
880 this.updateErrors_(row.querySelector('.manifest-errors'), | |
881 'dev-manifestErrors', extension.manifestErrors); | |
882 this.updateErrors_(row.querySelector('.runtime-errors'), | |
883 'dev-runtimeErrors', extension.runtimeErrors); | |
884 | |
885 // Install warnings. | 913 // Install warnings. |
886 this.updateVisibility_(row, '.install-warnings', | 914 this.updateVisibility_(row, '.install-warnings', |
887 extension.installWarnings.length > 0, | 915 extension.installWarnings.length > 0, |
888 function(item) { | 916 function(item) { |
889 var installWarningList = item.querySelector('ul'); | 917 var installWarningList = item.querySelector('ul'); |
890 installWarningList.textContent = ''; | 918 installWarningList.textContent = ''; |
891 if (extension.installWarnings) { | 919 if (extension.installWarnings) { |
892 extension.installWarnings.forEach(function(warning) { | 920 extension.installWarnings.forEach(function(warning) { |
893 var li = document.createElement('li'); | 921 var li = document.createElement('li'); |
894 li.innerText = warning; | 922 li.innerText = warning; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
934 * @private | 962 * @private |
935 */ | 963 */ |
936 updateVisibility_: function(node, query, visible, opt_shownCallback) { | 964 updateVisibility_: function(node, query, visible, opt_shownCallback) { |
937 var item = assert(node.querySelector(query)); | 965 var item = assert(node.querySelector(query)); |
938 item.hidden = !visible; | 966 item.hidden = !visible; |
939 if (visible && opt_shownCallback) | 967 if (visible && opt_shownCallback) |
940 opt_shownCallback(item); | 968 opt_shownCallback(item); |
941 }, | 969 }, |
942 | 970 |
943 /** | 971 /** |
944 * Updates an element to show a list of errors. | |
945 * @param {Element} panel An element to hold the errors. | |
946 * @param {string} columnType A tag used to identify the column when | |
947 * changing focus. | |
948 * @param {Array<RuntimeError|ManifestError>|undefined} errors The errors | |
949 * to be displayed. | |
950 * @private | |
951 */ | |
952 updateErrors_: function(panel, columnType, errors) { | |
953 // TODO(hcarmona): Look into updating the ExtensionErrorList rather than | |
954 // rebuilding it every time. | |
955 panel.hidden = !errors || errors.length == 0; | |
956 panel.textContent = ''; | |
957 | |
958 if (panel.hidden) | |
959 return; | |
960 | |
961 var errorList = | |
962 new extensions.ExtensionErrorList(assertInstanceof(errors, Array)); | |
963 | |
964 panel.appendChild(errorList); | |
965 | |
966 var list = errorList.getErrorListElement(); | |
967 if (list) | |
968 list.setAttribute('column-type', columnType + 'list'); | |
969 | |
970 var button = errorList.getToggleElement(); | |
971 if (button) | |
972 button.setAttribute('column-type', columnType + 'button'); | |
973 }, | |
974 | |
975 /** | |
976 * Opens the extension options overlay for the extension with the given id. | 972 * Opens the extension options overlay for the extension with the given id. |
977 * @param {string} extensionId The id of extension whose options page should | 973 * @param {string} extensionId The id of extension whose options page should |
978 * be displayed. | 974 * be displayed. |
979 * @param {boolean} scroll Whether the page should scroll to the extension | 975 * @param {boolean} scroll Whether the page should scroll to the extension |
980 * @private | 976 * @private |
981 */ | 977 */ |
982 showEmbeddedExtensionOptions_: function(extensionId, scroll) { | 978 showEmbeddedExtensionOptions_: function(extensionId, scroll) { |
983 if (this.optionsShown_) | 979 if (this.optionsShown_) |
984 return; | 980 return; |
985 | 981 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 var nextExt = this.extensions_[this.extensions_.indexOf(extension) + 1]; | 1052 var nextExt = this.extensions_[this.extensions_.indexOf(extension) + 1]; |
1057 this.createNode_(extension, nextExt ? $(nextExt.id) : null); | 1053 this.createNode_(extension, nextExt ? $(nextExt.id) : null); |
1058 } | 1054 } |
1059 } | 1055 } |
1060 }; | 1056 }; |
1061 | 1057 |
1062 return { | 1058 return { |
1063 ExtensionList: ExtensionList | 1059 ExtensionList: ExtensionList |
1064 }; | 1060 }; |
1065 }); | 1061 }); |
OLD | NEW |