OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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('ntp4', function() { | 5 cr.define('ntp4', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 var TilePage = ntp4.TilePage; | 8 var TilePage = ntp4.TilePage; |
9 | 9 |
10 /** | 10 /** |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 } | 77 } |
78 this.classList.remove('blacklisted'); | 78 this.classList.remove('blacklisted'); |
79 | 79 |
80 if (!data || data.filler) { | 80 if (!data || data.filler) { |
81 if (this.data_) | 81 if (this.data_) |
82 this.reset(); | 82 this.reset(); |
83 return; | 83 return; |
84 } | 84 } |
85 | 85 |
86 var id = tileID++; | 86 var id = tileID++; |
87 this.setAttribute('id', 'tile' + id); | 87 this.id = 'most_visited_tile_' + id; |
arv (Not doing code reviews)
2011/08/15 17:46:30
most-visited-tile
csilv
2011/08/15 18:24:28
Done.
| |
88 this.data_ = data; | 88 this.data_ = data; |
89 // TODO(estade): this shouldn't be focusable if the page isn't showing. | 89 // TODO(estade): this shouldn't be focusable if the page isn't showing. |
90 this.tabIndex = 0; | 90 this.tabIndex = 0; |
91 | 91 |
92 var faviconDiv = this.querySelector('.favicon'); | 92 var faviconDiv = this.querySelector('.favicon'); |
93 var faviconUrl = data.faviconUrl || | 93 var faviconUrl = data.faviconUrl || |
94 'chrome://favicon/size/32/' + data.url; | 94 'chrome://favicon/size/32/' + data.url; |
95 faviconDiv.style.backgroundImage = url(faviconUrl); | 95 faviconDiv.style.backgroundImage = url(faviconUrl); |
96 faviconDiv.dir = data.direction; | 96 faviconDiv.dir = data.direction; |
97 if (data.faviconDominantColor) | 97 if (data.faviconDominantColor) |
98 this.setStripeColor(data.faviconDominantColor); | 98 this.setStripeColor(data.faviconDominantColor); |
99 else | 99 else |
100 chrome.send('getFaviconDominantColor', [faviconUrl, id]); | 100 chrome.send('getFaviconDominantColor', |
101 [faviconUrl, id, 'ntp4.setMostVisitedFaviconDominantColor']); | |
101 | 102 |
102 var title = this.querySelector('.title'); | 103 var title = this.querySelector('.title'); |
103 title.textContent = data.title; | 104 title.textContent = data.title; |
104 title.dir = data.direction; | 105 title.dir = data.direction; |
105 | 106 |
106 var thumbnailUrl = data.thumbnailUrl || 'chrome://thumb/' + data.url; | 107 var thumbnailUrl = data.thumbnailUrl || 'chrome://thumb/' + data.url; |
107 this.querySelector('.thumbnail').style.backgroundImage = | 108 this.querySelector('.thumbnail').style.backgroundImage = |
108 url(thumbnailUrl); | 109 url(thumbnailUrl); |
109 | 110 |
110 this.href = data.url; | 111 this.href = data.url; |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 | 421 |
421 // Clear 'updated' flags so this function will work next time it's called. | 422 // Clear 'updated' flags so this function will work next time it's called. |
422 for (var i = 0; i < THUMBNAIL_COUNT; i++) { | 423 for (var i = 0; i < THUMBNAIL_COUNT; i++) { |
423 if (oldData[i]) | 424 if (oldData[i]) |
424 oldData[i].updated = false; | 425 oldData[i].updated = false; |
425 } | 426 } |
426 | 427 |
427 return oldData; | 428 return oldData; |
428 }; | 429 }; |
429 | 430 |
430 function setFaviconDominantColor(id, color) { | 431 function setMostVisitedFaviconDominantColor(id, color) { |
431 var tile = $('tile' + id); | 432 var tile = $('most_visited_tile_' + id); |
432 if (tile) | 433 if (tile) |
433 tile.setStripeColor(color); | 434 tile.setStripeColor(color); |
434 }; | 435 }; |
435 | 436 |
436 return { | 437 return { |
437 MostVisitedPage: MostVisitedPage, | 438 MostVisitedPage: MostVisitedPage, |
438 refreshData: refreshData, | 439 refreshData: refreshData, |
439 setFaviconDominantColor: setFaviconDominantColor, | 440 setMostVisitedFaviconDominantColor: setMostVisitedFaviconDominantColor, |
440 }; | 441 }; |
441 }); | 442 }); |
OLD | NEW |