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

Unified Diff: chrome/browser/resources/extensions/extension_error_overlay.js

Issue 22938005: Add ErrorConsole UI for Extension Install Warnings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dc_ec_install_warnings
Patch Set: Rebase to Master Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/extensions/extension_error_overlay.js
diff --git a/chrome/browser/resources/extensions/extension_error_overlay.js b/chrome/browser/resources/extensions/extension_error_overlay.js
new file mode 100644
index 0000000000000000000000000000000000000000..691f4937c74359ba54dc3cf982098875d9a8551c
--- /dev/null
+++ b/chrome/browser/resources/extensions/extension_error_overlay.js
@@ -0,0 +1,86 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+cr.define('extensions', function() {
+ 'use strict';
+
+ function ExtensionErrorOverlay() {
+ }
+
+ cr.addSingletonGetter(ExtensionErrorOverlay);
+
+ ExtensionErrorOverlay.prototype = {
+ /**
+ * Initialize the page.
+ */
+ initializePage: function() {
+ var overlay = $('overlay');
+ cr.ui.overlay.setupOverlay(overlay);
+ cr.ui.overlay.globalInitialization();
+ overlay.addEventListener('cancelOverlay', this.handleDismiss_.bind(this));
+
+ $('extensionErrorOverlayDismiss').addEventListener(
+ 'click', this.handleDismiss_.bind(this));
+ },
+
+ /**
+ * Handles a click on the dismiss button.
+ * @param {Event} e The click event.
+ */
+ handleDismiss_: function(e) {
+ $('extensionErrorOverlayContent').innerHTML = '';
+ ExtensionSettings.showOverlay(null);
+ },
+ };
+
+ /**
+ * Called by the dom_ui_ to re-populate the page with data representing
+ * the current state of extension commands.
+ */
+ ExtensionErrorOverlay.returnExtensionsData = function(extensionsData) {
+ };
+
+ /**
+ * Called by the ExtensionErrorHandler responding to the request for a file's
+ * source. Populate the content area of the overlay and display the overlay.
+ * @param {Object} result An object with four strings - the title,
+ * beforeHighlight, afterHighlight, and highlight. The three 'highlight'
+ * strings represent three portions of the file's content to display - the
+ * portion which is most relevant and should be emphasized (highlight),
+ * and the parts both before and after this portion. These may be empty.
+ */
+ ExtensionErrorOverlay.requestFileSourceResponse = function(result) {
+ var content = $('extensionErrorOverlayContent');
+ $('extensionErrorOverlay').querySelector(
+ '.extension-error-overlay-title').innerText = result.title;
+
+ var createSpan = function(source, isHighlighted) {
+ var span = document.createElement('span');
+ span.className = isHighlighted ? 'highlighted-source' : 'normal-source';
+ source = source.replace(/ /g, '&nbsp').replace(/\n/g, '<br/>');
Yoyo Zhou 2013/08/16 00:17:26 &nbsp; ?
Devlin 2013/08/16 18:07:49 Huh. I wonder why that worked... oh well. Fixed.
+ span.innerHTML = source;
+ return span;
+ };
+
+ if (result.beforeHighlight)
+ content.appendChild(createSpan(result.beforeHighlight, false));
+ if (result.highlight) {
+ var highlightSpan = createSpan(result.highlight, true);
+ highlightSpan.title = result.errorMessage;
+ content.appendChild(highlightSpan);
+ }
+ if (result.afterHighlight)
+ content.appendChild(createSpan(result.afterHighlight, false));
+
+ ExtensionSettings.showOverlay($('extensionErrorOverlay'));
+ };
+
+ // Export
+ return {
+ ExtensionErrorOverlay: ExtensionErrorOverlay
+ };
+});
+
+// Update the C++ call so this isn't necessary.
Yoyo Zhou 2013/08/16 00:17:26 Is this a TODO?
Devlin 2013/08/16 18:07:49 I was following the pattern of PackExtension/Comma
+var ExtensionErrorOverlay = extensions.ExtensionErrorOverlay;

Powered by Google App Engine
This is Rietveld 408576698