| 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 22 matching lines...) Expand all Loading... |
| 33 NTP_GRAY_TILE: 4, | 33 NTP_GRAY_TILE: 4, |
| 34 // The visuals of that tile are handled externally by the page itself. | 34 // The visuals of that tile are handled externally by the page itself. |
| 35 NTP_EXTERNAL_TILE: 5, | 35 NTP_EXTERNAL_TILE: 5, |
| 36 // There was an error in loading both the thumbnail image and the fallback | 36 // There was an error in loading both the thumbnail image and the fallback |
| 37 // (if it was provided), resulting in a grey tile. | 37 // (if it was provided), resulting in a grey tile. |
| 38 NTP_THUMBNAIL_ERROR: 6, | 38 NTP_THUMBNAIL_ERROR: 6, |
| 39 // Used a gray tile with the domain as the fallback for a failed thumbnail. | 39 // Used a gray tile with the domain as the fallback for a failed thumbnail. |
| 40 NTP_GRAY_TILE_FALLBACK: 7, | 40 NTP_GRAY_TILE_FALLBACK: 7, |
| 41 // The visuals of that tile's fallback are handled externally. | 41 // The visuals of that tile's fallback are handled externally. |
| 42 NTP_EXTERNAL_TILE_FALLBACK: 8, | 42 NTP_EXTERNAL_TILE_FALLBACK: 8, |
| 43 // The user moused over an NTP tile or title. | |
| 44 NTP_MOUSEOVER: 9, | |
| 45 // A NTP Tile has finished loading (successfully or failing). | 43 // A NTP Tile has finished loading (successfully or failing). |
| 46 NTP_TILE_LOADED: 10, | 44 NTP_TILE_LOADED: 10, |
| 47 }; | 45 }; |
| 48 | 46 |
| 49 /** | 47 /** |
| 50 * Type of the impression provider for a generic client-provided suggestion. | 48 * Type of the impression provider for a generic client-provided suggestion. |
| 51 * @type {string} | 49 * @type {string} |
| 52 * @const | 50 * @const |
| 53 */ | 51 */ |
| 54 var CLIENT_PROVIDER_NAME = 'client'; | 52 var CLIENT_PROVIDER_NAME = 'client'; |
| (...skipping 74 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 if (navigator.sendBeacon) { | 303 if (navigator.sendBeacon) { |
| 310 navigator.sendBeacon(url); | 304 navigator.sendBeacon(url); |
| 311 } else { | 305 } else { |
| 312 // if sendBeacon is not enabled, we fallback for "a ping". | 306 // if sendBeacon is not enabled, we fallback for "a ping". |
| 313 var a = document.createElement('a'); | 307 var a = document.createElement('a'); |
| 314 a.href = '#'; | 308 a.href = '#'; |
| 315 a.ping = url; | 309 a.ping = url; |
| 316 a.click(); | 310 a.click(); |
| 317 } | 311 } |
| 318 } | 312 } |
| OLD | NEW |