| 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 Utilities for rendering most visited thumbnails and titles. | 7 * @fileoverview Utilities for rendering most visited thumbnails and titles. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 <include src="instant_iframe_validation.js"> | 10 <include src="instant_iframe_validation.js"> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 NTP_GRAY_TILE: 4, | 37 NTP_GRAY_TILE: 4, |
| 38 // The visuals of that tile are handled externally by the page itself. | 38 // The visuals of that tile are handled externally by the page itself. |
| 39 NTP_EXTERNAL_TILE: 5, | 39 NTP_EXTERNAL_TILE: 5, |
| 40 // There was an error in loading both the thumbnail image and the fallback | 40 // There was an error in loading both the thumbnail image and the fallback |
| 41 // (if it was provided), resulting in a grey tile. | 41 // (if it was provided), resulting in a grey tile. |
| 42 NTP_THUMBNAIL_ERROR: 6, | 42 NTP_THUMBNAIL_ERROR: 6, |
| 43 // Used a gray tile with the domain as the fallback for a failed thumbnail. | 43 // Used a gray tile with the domain as the fallback for a failed thumbnail. |
| 44 NTP_GRAY_TILE_FALLBACK: 7, | 44 NTP_GRAY_TILE_FALLBACK: 7, |
| 45 // The visuals of that tile's fallback are handled externally. | 45 // The visuals of that tile's fallback are handled externally. |
| 46 NTP_EXTERNAL_TILE_FALLBACK: 8, | 46 NTP_EXTERNAL_TILE_FALLBACK: 8, |
| 47 // The user moused over an NTP tile or title. | |
| 48 NTP_MOUSEOVER: 9, | |
| 49 // A NTP Tile has finished loading (successfully or failing). | 47 // A NTP Tile has finished loading (successfully or failing). |
| 50 NTP_TILE_LOADED: 10, | 48 NTP_TILE_LOADED: 10, |
| 51 }; | 49 }; |
| 52 | 50 |
| 53 /** | 51 /** |
| 54 * The different sources that an NTP tile can have. | 52 * The different sources that an NTP tile can have. |
| 55 * Note: Keep in sync with common/ntp_logging_events.h | 53 * Note: Keep in sync with common/ntp_logging_events.h |
| 56 * @enum {number} | 54 * @enum {number} |
| 57 * @const | 55 * @const |
| 58 */ | 56 */ |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 link.target = '_top'; | 127 link.target = '_top'; |
| 130 // Include links in the tab order. The tabIndex is necessary for | 128 // Include links in the tab order. The tabIndex is necessary for |
| 131 // accessibility. | 129 // accessibility. |
| 132 link.tabIndex = '0'; | 130 link.tabIndex = '0'; |
| 133 if (text) { | 131 if (text) { |
| 134 // Wrap text with span so ellipsis will appear at the end of multiline. | 132 // Wrap text with span so ellipsis will appear at the end of multiline. |
| 135 var spanWrap = document.createElement('span'); | 133 var spanWrap = document.createElement('span'); |
| 136 spanWrap.textContent = text; | 134 spanWrap.textContent = text; |
| 137 link.appendChild(spanWrap); | 135 link.appendChild(spanWrap); |
| 138 } | 136 } |
| 139 link.addEventListener('mouseover', function() { | |
| 140 var ntpApiHandle = chrome.embeddedSearch.newTabPage; | |
| 141 ntpApiHandle.logEvent(NTP_LOGGING_EVENT_TYPE.NTP_MOUSEOVER); | |
| 142 }); | |
| 143 link.addEventListener('focus', function() { | 137 link.addEventListener('focus', function() { |
| 144 window.parent.postMessage('linkFocused', DOMAIN_ORIGIN); | 138 window.parent.postMessage('linkFocused', DOMAIN_ORIGIN); |
| 145 }); | 139 }); |
| 146 link.addEventListener('blur', function() { | 140 link.addEventListener('blur', function() { |
| 147 window.parent.postMessage('linkBlurred', DOMAIN_ORIGIN); | 141 window.parent.postMessage('linkBlurred', DOMAIN_ORIGIN); |
| 148 }); | 142 }); |
| 149 | 143 |
| 150 var navigateFunction = function handleNavigation(e) { | 144 var navigateFunction = function handleNavigation(e) { |
| 151 var isServerSuggestion = 'url' in params; | 145 var isServerSuggestion = 'url' in params; |
| 152 | 146 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 if (navigator.sendBeacon) { | 301 if (navigator.sendBeacon) { |
| 308 navigator.sendBeacon(url); | 302 navigator.sendBeacon(url); |
| 309 } else { | 303 } else { |
| 310 // if sendBeacon is not enabled, we fallback for "a ping". | 304 // if sendBeacon is not enabled, we fallback for "a ping". |
| 311 var a = document.createElement('a'); | 305 var a = document.createElement('a'); |
| 312 a.href = '#'; | 306 a.href = '#'; |
| 313 a.ping = url; | 307 a.ping = url; |
| 314 a.click(); | 308 a.click(); |
| 315 } | 309 } |
| 316 } | 310 } |
| OLD | NEW |