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

Unified Diff: chrome/browser/resources/ntp4/new_tab.js

Issue 7577002: ntp4: new app animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clear hash Created 9 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
« no previous file with comments | « no previous file | chrome/browser/ui/webui/ntp/app_launcher_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« no previous file with comments | « no previous file | chrome/browser/ui/webui/ntp/app_launcher_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698