Index: chrome/browser/resources/ntp4/page_list_view.js |
diff --git a/chrome/browser/resources/ntp4/page_list_view.js b/chrome/browser/resources/ntp4/page_list_view.js |
index a001e185196eb69bd1ba7f71a3082f01dce0f2a0..0ae63202bbcf4fdbc6de10bc3280ce1f8caf949a 100644 |
--- a/chrome/browser/resources/ntp4/page_list_view.js |
+++ b/chrome/browser/resources/ntp4/page_list_view.js |
@@ -59,6 +59,12 @@ cr.define('ntp', function() { |
appsPages: undefined, |
/** |
+ * The Suggestions page. |
+ * @type {!Element|undefined} |
+ */ |
+ suggestionsPage: undefined, |
+ |
+ /** |
* The Most Visited page. |
* @type {!Element|undefined} |
*/ |
@@ -199,7 +205,7 @@ cr.define('ntp', function() { |
appendTilePage: function(page, title, titleIsEditable, opt_refNode) { |
if (opt_refNode) { |
var refIndex = this.getTilePageIndex(opt_refNode); |
- this.cardSlider.insertCardAtIndex(page, refIndex); |
+ this.cardSlider.addCardAtIndex(page, refIndex); |
} else { |
this.cardSlider.appendCard(page); |
} |
@@ -212,6 +218,11 @@ cr.define('ntp', function() { |
this.mostVisitedPage = page; |
} |
+ if (typeof ntp.SuggestionsPage != 'undefined' && |
+ page instanceof ntp.SuggestionsPage) { |
+ this.suggestionsPage = page; |
+ } |
+ |
// If we're appending an AppsPage and it's a temporary page, animate it. |
var animate = page instanceof ntp.AppsPage && |
page.classList.contains('temporary'); |
@@ -319,6 +330,14 @@ cr.define('ntp', function() { |
// An app to animate (in case it was just installed). |
var highlightApp; |
+ // If there are any pages after the apps, add new pages before them. |
+ var lastAppsPage = (this.appsPages.length > 0) ? |
+ this.appsPages[this.appsPages.length - 1] : null; |
+ var lastAppsPageIndex = (lastAppsPage != null) ? |
+ Array.prototype.indexOf.call(this.tilePages, lastAppsPage) : -1; |
+ var nextPageAfterApps = lastAppsPageIndex != -1 ? |
+ this.tilePages[lastAppsPageIndex + 1] : null; |
+ |
// Add the apps, creating pages as necessary |
for (var i = 0; i < apps.length; i++) { |
var app = apps[i]; |
@@ -329,7 +348,8 @@ cr.define('ntp', function() { |
pageName = pageNames[this.appsPages.length]; |
var origPageCount = this.appsPages.length; |
- this.appendTilePage(new ntp.AppsPage(), pageName, true); |
+ this.appendTilePage(new ntp.AppsPage(), pageName, true, |
+ nextPageAfterApps); |
// Confirm that appsPages is a live object, updated when a new page is |
// added (otherwise we'd have an infinite loop) |
assert(this.appsPages.length == origPageCount + 1, |
@@ -429,6 +449,10 @@ cr.define('ntp', function() { |
if (this.mostVisitedPage) |
this.cardSlider.selectCardByValue(this.mostVisitedPage); |
break; |
+ case templateData['suggestions_page_id']: |
+ if (this.suggestionsPage) |
+ this.cardSlider.selectCardByValue(this.suggestionsPage); |
+ break; |
} |
}, |
@@ -543,6 +567,9 @@ cr.define('ntp', function() { |
} else if (page.classList.contains('most-visited-page')) { |
this.shownPage = templateData.most_visited_page_id; |
this.shownPageIndex = 0; |
+ } else if (page.classList.contains('suggestions-page')) { |
+ this.shownPage = templateData.suggestions_page_id; |
+ this.shownPageIndex = 0; |
} else { |
console.error('unknown page selected'); |
} |