summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources
diff options
context:
space:
mode:
authormirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-03 21:44:58 +0000
committermirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-03 21:44:58 +0000
commitb2afacb2162f630136421a01094155474b081add (patch)
tree08d439caf1bf15a5c43aca4d3141dfd63a6c6b26 /chrome/browser/resources
parent7b18d3df1296b80bdcab81de40ccc63ccffeced9 (diff)
downloadchromium_src-b2afacb2162f630136421a01094155474b081add.zip
chromium_src-b2afacb2162f630136421a01094155474b081add.tar.gz
chromium_src-b2afacb2162f630136421a01094155474b081add.tar.bz2
Make sure that the "Recent activities" section of the NNTP does not include duplicates.
BUG= http://crbug.com/17896 TEST= Open a new tab. Close the same page more than once. Observe that this page only appears once in the "Recent activities" section of the NNTP. Review URL: http://codereview.chromium.org/160399 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22316 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources')
-rw-r--r--chrome/browser/resources/new_new_tab.js19
1 files changed, 6 insertions, 13 deletions
diff --git a/chrome/browser/resources/new_new_tab.js b/chrome/browser/resources/new_new_tab.js
index c30a773..86fb8dc 100644
--- a/chrome/browser/resources/new_new_tab.js
+++ b/chrome/browser/resources/new_new_tab.js
@@ -110,6 +110,11 @@ function downloadsList(data) {
function recentlyClosedTabs(data) {
logEvent('received recently closed tabs');
+ // Remove old tabs and windows to prevent duplicates.
+ recentItems = recentItems.filter(function(item) {
+ return item.type != 'tab' && item.type != 'window';
+ });
+
// We handle timestamp 0 as now
data.forEach(function(d) {
if (d.timestamp == 0) {
@@ -123,21 +128,9 @@ function recentlyClosedTabs(data) {
var recentItems = [];
var recentItemKeys = {};
-function getRecentItemKey(d) {
- // type == window does not have a URL
- return d.type + (d.url || d.sessionId) + d.timestamp;
-}
-
function gotRecentItems(data) {
// Add new items
- for (var i = 0; i < data.length; i++) {
- var d = data[i];
- var key = getRecentItemKey(d);
- if (!(key in recentItemKeys)) {
- recentItems.push(d);
- recentItemKeys[key] = true;
- }
- }
+ Array.prototype.push.apply(recentItems, data);
recentItems.sort(function(d1, d2) {
return d2.timestamp - d1.timestamp;