Index: chrome/browser/resources/ntp4/new_tab.js |
diff --git a/chrome/browser/resources/ntp4/new_tab.js b/chrome/browser/resources/ntp4/new_tab.js |
index 22790245ab83a176b5be4ab0a97a9c08c4918f27..a25dc363a1a4d7cd16bd2a3e94c1c2f9f6811b35 100644 |
--- a/chrome/browser/resources/ntp4/new_tab.js |
+++ b/chrome/browser/resources/ntp4/new_tab.js |
@@ -102,6 +102,14 @@ cr.define('ntp4', function() { |
var localStrings = new LocalStrings; |
/** |
+ * If non-null, this is the ID of the app to highlight to the user the next |
+ * time getAppsCallback runs. "Highlight" in this case means to switch to |
+ * the page and run the new tile animation. |
+ * @type {String} |
+ */ |
+ var highlightAppId = null; |
+ |
+ /** |
* The time in milliseconds for most transitions. This should match what's |
* in new_tab.css. Unfortunately there's no better way to try to time |
* something to occur until after a transition has completed. |
@@ -127,6 +135,16 @@ cr.define('ntp4', function() { |
shownPage = templateData['shown_page_type']; |
shownPageIndex = templateData['shown_page_index']; |
+ // When a new app has been installed, we will be opened with a hash value |
+ // that corresponds to the new app ID. |
+ var hash = location.hash; |
+ if (hash && hash.indexOf('#app-id=') == 0) { |
+ highlightAppId = hash.split('=')[1]; |
+ // Clear the hash so if the user bookmarks this page, they'll just get |
+ // chrome://newtab/. |
+ window.history.replaceState({}, '', '/'); |
+ } |
+ |
document.querySelector('#notification button').onclick = function(e) { |
hideNotification(); |
}; |
@@ -257,6 +275,9 @@ cr.define('ntp4', function() { |
return a.app_launch_index - b.app_launch_index; |
}); |
+ // An app to animate (in case it was just installed). |
+ var highlightApp; |
+ |
// Add the apps, creating pages as necessary |
for (var i = 0; i < apps.length; i++) { |
var app = apps[i]; |
@@ -273,7 +294,12 @@ cr.define('ntp4', function() { |
assert(appsPages.length == origPageCount + 1, 'expected new page'); |
} |
- appsPages[pageIndex].appendApp(app); |
+ if (app.id == highlightAppId) { |
+ highlightApp = app; |
+ highlightAppId = null; |
+ } else { |
+ appsPages[pageIndex].appendApp(app); |
+ } |
} |
ntp4.AppsPage.setPromo(data.showPromo ? data : null); |
@@ -281,6 +307,9 @@ cr.define('ntp4', function() { |
// Tell the slider about the pages |
updateSliderCards(); |
+ if (highlightApp) |
+ appAdded(highlightApp); |
+ |
// Mark the current page |
dots[cardSlider.currentCard].classList.add('selected'); |
logEvent('apps.layout: ' + (Date.now() - startTime)); |