extensions: reinstate trash focus/closing logic after switch to
chrome.management.uninstall.

R=rdevlin.cronin@chromium.org
BUG=463003

Review URL: https://codereview.chromium.org/971993002

Cr-Commit-Position: refs/heads/master@{#318825}
diff --git a/chrome/browser/resources/extensions/extension_list.js b/chrome/browser/resources/extensions/extension_list.js
index a9363e1..16b1132 100644
--- a/chrome/browser/resources/extensions/extension_list.js
+++ b/chrome/browser/resources/extensions/extension_list.js
@@ -466,6 +466,17 @@
                                     function() {
           // TODO(devlin): What should we do if the uninstall fails?
           this.uninstallIsShowing_ = false;
+
+          if (trash.classList.contains('mouse-clicked'))
+            trash.blur();
+
+          if (chrome.runtime.lastError) {
+            // The uninstall failed (e.g. a cancel). Allow the trash to close.
+            trash.classList.remove('open');
+          } else {
+            // Leave the trash open if the uninstall succeded. Otherwise it can
+            // half-close right before it's removed when the DOM is modified.
+          }
         }.bind(this));
       }.bind(this));
       row.querySelector('.enable-controls').appendChild(trash);
@@ -899,13 +910,6 @@
     },
   };
 
-  ExtensionList.uninstallCancel = function() {
-    var trash = document.querySelector('.trash.open');
-    if (trash.classList.contains('mouse-clicked'))
-      trash.blur();
-    trash.classList.remove('open');
-  };
-
   return {
     ExtensionList: ExtensionList
   };