diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-01 18:02:15 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-01 18:02:15 +0000 |
commit | 68b8bd2ad83392190fd131c3a09442b6acd8065d (patch) | |
tree | 0f2e36912741d3bd91a4882356dca8beb1f23e87 /chrome/browser | |
parent | 68d8868d6dc72e763a2c3882dbace4c67a3b0747 (diff) | |
download | chromium_src-68b8bd2ad83392190fd131c3a09442b6acd8065d.zip chromium_src-68b8bd2ad83392190fd131c3a09442b6acd8065d.tar.gz chromium_src-68b8bd2ad83392190fd131c3a09442b6acd8065d.tar.bz2 |
ntp4: various minor cleanups
no functional change, just me trying to erase stupid mistakes
BUG=none
TEST=manual
Review URL: http://codereview.chromium.org/7817016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99209 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/resources/ntp4/apps_page.js | 33 | ||||
-rw-r--r-- | chrome/browser/resources/ntp4/new_tab.js | 12 |
2 files changed, 26 insertions, 19 deletions
diff --git a/chrome/browser/resources/ntp4/apps_page.js b/chrome/browser/resources/ntp4/apps_page.js index d389dc1..5359955 100644 --- a/chrome/browser/resources/ntp4/apps_page.js +++ b/chrome/browser/resources/ntp4/apps_page.js @@ -238,8 +238,7 @@ cr.define('ntp4', 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(); + this.tile.doRemove(); }, /** @@ -409,9 +408,8 @@ cr.define('ntp4', function() { removeFromChrome: function() { chrome.send('uninstallApp', [this.appData_.id, true]); - var tile = this.parentNode; - tile.tilePage.cleanupDrag(); - tile.parentNode.removeChild(tile); + this.tile.tilePage.cleanupDrag(); + this.tile.parentNode.removeChild(tile); }, /** @@ -523,8 +521,6 @@ cr.define('ntp4', function() { addOutsideData_: function(dataTransfer, index) { var url = dataTransfer.getData('url'); assert(url); - if (!url) - return; // If the dataTransfer has html data, use that html's text contents as the // title of the new link. @@ -597,8 +593,23 @@ cr.define('ntp4', function() { store.setAppsPromoData(data); }; - // Launches the specified app using the APP_LAUNCH_NTP_APP_RE_ENABLE - // histogram. This should only be invoked from the AppLauncherHandler. + + /** + * Callback invoked by chrome whenever an app preference changes. + * @param {Object} data An object with all the data on available + * applications. + */ + function appsPrefChangeCallback(data) { + for (var i = 0; i < data.apps.length; ++i) { + $(data.apps[i].id).appData = data.apps[i]; + } + } + + /** + * Launches the specified app using the APP_LAUNCH_NTP_APP_RE_ENABLE + * histogram. This should only be invoked from the AppLauncherHandler. + * @param {String} appID The ID of the app. + */ function launchAppAfterEnable(appId) { chrome.send('launchApp', [appId, APP_LAUNCH.NTP_APP_RE_ENABLE]); }; @@ -606,8 +617,12 @@ cr.define('ntp4', function() { return { APP_LAUNCH: APP_LAUNCH, AppsPage: AppsPage, + appsPrefChangeCallback: appsPrefChangeCallback, launchAppAfterEnable: launchAppAfterEnable, }; }); +// TODO(estade): update the content handlers to use ntp namespace instead of +// making these global. +var appsPrefChangeCallback = ntp4.appsPrefChangeCallback; var launchAppAfterEnable = ntp4.launchAppAfterEnable; diff --git a/chrome/browser/resources/ntp4/new_tab.js b/chrome/browser/resources/ntp4/new_tab.js index ecaf355..6c5fdee 100644 --- a/chrome/browser/resources/ntp4/new_tab.js +++ b/chrome/browser/resources/ntp4/new_tab.js @@ -388,16 +388,8 @@ cr.define('ntp4', function() { * applications. */ function appsPrefChangeCallback(data) { - var apps = document.querySelectorAll('.app'); - - // This is an expensive operation. We minimize how frequently it's called - // by only calling it for changes across different instances of the NTP - // (i.e. two separate tabs both showing NTP). - for (var j = 0; j < data.apps.length; ++j) { - for (var i = 0; i < apps.length; ++i) { - if (data.apps[j]['id'] == apps[i].appId) - apps[i].appData = data.apps[j]; - } + for (var i = 0; i < data.apps.length; ++i) { + $(data.apps[i].id).appData = data.apps[i]; } } |