Commit a93379ad authored by estade@chromium.org's avatar estade@chromium.org

ntp4: fix app load/unload race condition

BUG=94095
TEST=open ntp and chrome://extensions, spam disable/enable on something that's both an app and an extension (such as weatherbug). NTP should not start creating multiple copies of the icon.


Review URL: http://codereview.chromium.org/7764013

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98685 0039d316-1c4b-4281-b951-d872f2087c98
parent 5931a643
...@@ -229,6 +229,18 @@ cr.define('ntp4', function() { ...@@ -229,6 +229,18 @@ cr.define('ntp4', function() {
this.createAppsPromoExtras_(); this.createAppsPromoExtras_();
}, },
/**
* Removes the app tile from the page. Should be called after the app has
* been uninstalled.
*/
remove: function() {
// Unset the ID immediately, because the app is already gone. But leave
// the tile on the page as it animates out.
this.id = '';
var tile = findAncestorByClass(this, 'tile');
tile.doRemove();
},
/** /**
* Creates the apps-promo section of the app (should only be called for the * Creates the apps-promo section of the app (should only be called for the
* webstore app). * webstore app).
......
...@@ -377,9 +377,7 @@ cr.define('ntp4', function() { ...@@ -377,9 +377,7 @@ cr.define('ntp4', function() {
function appRemoved(appData) { function appRemoved(appData) {
var app = $(appData.id); var app = $(appData.id);
assert(app, 'trying to remove an app that doesn\'t exist'); assert(app, 'trying to remove an app that doesn\'t exist');
app.remove();
var tile = findAncestorByClass(app, 'tile');
tile.doRemove();
} }
/** /**
......
...@@ -265,7 +265,6 @@ cr.define('ntp4', function() { ...@@ -265,7 +265,6 @@ cr.define('ntp4', function() {
* Called when an app is removed from Chrome. Animates its disappearance. * Called when an app is removed from Chrome. Animates its disappearance.
*/ */
doRemove: function() { doRemove: function() {
var contents = this.firstChild;
this.firstChild.classList.add('removing-tile-contents'); this.firstChild.classList.add('removing-tile-contents');
}, },
...@@ -276,7 +275,7 @@ cr.define('ntp4', function() { ...@@ -276,7 +275,7 @@ cr.define('ntp4', function() {
onContentsAnimationEnd_: function(e) { onContentsAnimationEnd_: function(e) {
if (this.firstChild.classList.contains('new-tile-contents')) if (this.firstChild.classList.contains('new-tile-contents'))
this.firstChild.classList.remove('new-tile-contents'); this.firstChild.classList.remove('new-tile-contents');
else if (this.firstChild.classList.contains('removing-tile-contents')) if (this.firstChild.classList.contains('removing-tile-contents'))
this.tilePage.removeTile(this); this.tilePage.removeTile(this);
}, },
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment