OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 | 5 |
6 /** | 6 /** |
7 * @fileoverview Rendering for iframed most visited thumbnails. | 7 * @fileoverview Rendering for iframed most visited thumbnails. |
8 */ | 8 */ |
9 | 9 |
10 window.addEventListener('DOMContentLoaded', function() { | 10 window.addEventListener('DOMContentLoaded', function() { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 blocker.className = 'blocker'; | 53 blocker.className = 'blocker'; |
54 link.appendChild(blocker); | 54 link.appendChild(blocker); |
55 link.appendChild(image); | 55 link.appendChild(image); |
56 displayLink(link); | 56 displayLink(link); |
57 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_TILE_LOADED); | 57 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_TILE_LOADED); |
58 }; | 58 }; |
59 image.onerror = function() { | 59 image.onerror = function() { |
60 // If no external thumbnail fallback (etfb), and have domain. | 60 // If no external thumbnail fallback (etfb), and have domain. |
61 if (!params.etfb && data.domain) { | 61 if (!params.etfb && data.domain) { |
62 showDomainElement(); | 62 showDomainElement(); |
63 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_GRAY_TILE_FALLBACK); | |
64 } else { | 63 } else { |
65 showEmptyTile(); | 64 showEmptyTile(); |
66 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_EXTERNAL_TILE_FALLBACK); | |
67 } | 65 } |
68 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_THUMBNAIL_ERROR); | |
69 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_TILE_LOADED); | 66 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_TILE_LOADED); |
70 }; | 67 }; |
71 image.src = src; | 68 image.src = src; |
72 } | 69 } |
73 | 70 |
74 var useIcons = params['icons'] == '1'; | 71 var useIcons = params['icons'] == '1'; |
75 if (data.dummy) { | 72 if (data.dummy) { |
76 showEmptyTile(); | 73 showEmptyTile(); |
77 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_EXTERNAL_TILE); | |
78 } else if (useIcons && data.largeIconUrl) { | 74 } else if (useIcons && data.largeIconUrl) { |
79 createThumbnail(data.largeIconUrl, 'large-icon'); | 75 createThumbnail(data.largeIconUrl, 'large-icon'); |
80 // TODO(huangs): Log event for large icons. | 76 // TODO(huangs): Log event for large icons. |
81 } else if (!useIcons && data.thumbnailUrls && data.thumbnailUrls.length) { | 77 } else if (!useIcons && data.thumbnailUrls && data.thumbnailUrls.length) { |
82 createThumbnail(data.thumbnailUrls[0], 'thumbnail'); | 78 createThumbnail(data.thumbnailUrls[0], 'thumbnail'); |
83 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_THUMBNAIL_TILE); | |
84 } else if (data.domain) { | 79 } else if (data.domain) { |
85 showDomainElement(); | 80 showDomainElement(); |
86 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_GRAY_TILE); | |
87 } else { | 81 } else { |
88 showEmptyTile(); | 82 showEmptyTile(); |
89 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_EXTERNAL_TILE); | |
90 } | 83 } |
91 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_TILE); | 84 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_TILE); |
92 | 85 |
93 // Log an impression if we know the position of the tile. | 86 // Log an impression if we know the position of the tile. |
94 if (isFinite(params.pos)) { | 87 if (isFinite(params.pos)) { |
95 logMostVisitedImpression(parseInt(params.pos, 10), data.tileSource); | 88 logMostVisitedImpression(parseInt(params.pos, 10), data.tileSource); |
96 } | 89 } |
97 }); | 90 }); |
98 }); | 91 }); |
OLD | NEW |