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

Side by Side Diff: chrome/browser/resources/ntp_search/thumbnail_page.js

Issue 11416091: NTP5: Implementing new specification for favicons of Most Visited Pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('ntp', function() { 5 cr.define('ntp', function() {
6 'use strict'; 6 'use strict';
7 7
8 var Tile = ntp.Tile; 8 var Tile = ntp.Tile;
9 var TilePage = ntp.TilePage; 9 var TilePage = ntp.TilePage;
10 10
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 var dataUrl = data.url; 78 var dataUrl = data.url;
79 // Allow an empty string href (e.g. for a multiple tab thumbnail). 79 // Allow an empty string href (e.g. for a multiple tab thumbnail).
80 this.href = typeof data.href != 'undefined' ? data.href : dataUrl; 80 this.href = typeof data.href != 'undefined' ? data.href : dataUrl;
81 81
82 var thumbnailImage = this.querySelector('.thumbnail-image'); 82 var thumbnailImage = this.querySelector('.thumbnail-image');
83 83
84 var banner = thumbnailImage.querySelector('.thumbnail-banner'); 84 var banner = thumbnailImage.querySelector('.thumbnail-banner');
85 if (banner) 85 if (banner)
86 thumbnailImage.removeChild(banner); 86 thumbnailImage.removeChild(banner);
87 87
88 var favicon = thumbnailImage.querySelector('.thumbnail-favicon'); 88 var favicon = this.querySelector('.thumbnail-favicon') ||
89 if (favicon) 89 this.ownerDocument.createElement('div');
Evan Stade 2012/11/20 20:05:00 var favicon = this.querySelector('.thumbnail-favic
pedro (no code reviews) 2012/11/20 20:14:00 Done.
90 thumbnailImage.removeChild(favicon); 90 favicon.className = 'thumbnail-favicon';
91 favicon.style.backgroundImage =
92 url('chrome://favicon/size/16/' + dataUrl);
93 this.appendChild(favicon);
91 94
92 var self = this; 95 var self = this;
93 var image = new Image(); 96 var image = new Image();
94 97
95 // If the thumbnail image fails to load, show the favicon and URL instead. 98 // If the thumbnail image fails to load, show the favicon and URL instead.
96 // TODO(jeremycho): Move to a separate function? 99 // TODO(jeremycho): Move to a separate function?
97 image.onerror = function() { 100 image.onerror = function() {
98 banner = thumbnailImage.querySelector('.thumbnail-banner') || 101 banner = thumbnailImage.querySelector('.thumbnail-banner') ||
99 self.ownerDocument.createElement('div'); 102 self.ownerDocument.createElement('div');
100 banner.className = 'thumbnail-banner'; 103 banner.className = 'thumbnail-banner';
101 104
102 // For now, just strip leading http://www and trailing backslash. 105 // For now, just strip leading http://www and trailing backslash.
103 // TODO(jeremycho): Consult with UX on URL truncation. 106 // TODO(jeremycho): Consult with UX on URL truncation.
104 banner.textContent = dataUrl.replace(/^(http:\/\/)?(www\.)?|\/$/gi, ''); 107 banner.textContent = dataUrl.replace(/^(http:\/\/)?(www\.)?|\/$/gi, '');
105 thumbnailImage.appendChild(banner); 108 thumbnailImage.appendChild(banner);
106
107 favicon = thumbnailImage.querySelector('.thumbnail-favicon') ||
108 self.ownerDocument.createElement('div');
109 favicon.className = 'thumbnail-favicon';
110 favicon.style.backgroundImage =
111 url('chrome://favicon/size/16/' + dataUrl);
112 thumbnailImage.appendChild(favicon);
113 }; 109 };
114 110
115 var thumbnailUrl = ntp.getThumbnailUrl(dataUrl); 111 var thumbnailUrl = ntp.getThumbnailUrl(dataUrl);
116 thumbnailImage.style.backgroundImage = url(thumbnailUrl); 112 thumbnailImage.style.backgroundImage = url(thumbnailUrl);
117 image.src = thumbnailUrl; 113 image.src = thumbnailUrl;
118 }, 114 },
119 115
120 /** 116 /**
121 * Returns true if this is a thumbnail or descendant thereof. Used to 117 * Returns true if this is a thumbnail or descendant thereof. Used to
122 * detect when the mouse has transitioned into this thumbnail from a 118 * detect when the mouse has transitioned into this thumbnail from a
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 shouldAcceptDrag: function(e) { 169 shouldAcceptDrag: function(e) {
174 return false; 170 return false;
175 }, 171 },
176 }; 172 };
177 173
178 return { 174 return {
179 Thumbnail: Thumbnail, 175 Thumbnail: Thumbnail,
180 ThumbnailPage: ThumbnailPage, 176 ThumbnailPage: ThumbnailPage,
181 }; 177 };
182 }); 178 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698