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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 // The fading length in pixels is passed by the caller. | 116 // The fading length in pixels is passed by the caller. |
117 var mask = 'linear-gradient(' + dir + ', rgba(0,0,0,1), rgba(0,0,0,1) ' + | 117 var mask = 'linear-gradient(' + dir + ', rgba(0,0,0,1), rgba(0,0,0,1) ' + |
118 styles.textFadePos + 'px, rgba(0,0,0,0))'; | 118 styles.textFadePos + 'px, rgba(0,0,0,0))'; |
119 link.style.textOverflow = 'clip'; | 119 link.style.textOverflow = 'clip'; |
120 link.style.webkitMask = mask; | 120 link.style.webkitMask = mask; |
121 } | 121 } |
122 | 122 |
123 link.href = href; | 123 link.href = href; |
124 link.title = title; | 124 link.title = title; |
125 link.target = '_top'; | 125 link.target = '_top'; |
126 // Exclude links from the tab order. The tabIndex is added to the thumbnail | 126 // Include links in the tab order. The tabIndex is necessary for |
127 // parent container instead. | 127 // accessibility. |
128 link.tabIndex = '-1'; | 128 link.tabIndex = '0'; |
129 if (text) | 129 if (text) |
130 link.textContent = text; | 130 link.textContent = text; |
131 link.addEventListener('mouseover', function() { | 131 link.addEventListener('mouseover', function() { |
132 var ntpApiHandle = chrome.embeddedSearch.newTabPage; | 132 var ntpApiHandle = chrome.embeddedSearch.newTabPage; |
133 ntpApiHandle.logEvent(NTP_LOGGING_EVENT_TYPE.NTP_MOUSEOVER); | 133 ntpApiHandle.logEvent(NTP_LOGGING_EVENT_TYPE.NTP_MOUSEOVER); |
134 }); | 134 }); |
135 link.addEventListener('focus', function() { | |
136 window.parent.postMessage('linkFocused', DOMAIN_ORIGIN); | |
137 }); | |
138 link.addEventListener('blur', function() { | |
139 window.parent.postMessage('linkBlurred', DOMAIN_ORIGIN); | |
140 }); | |
141 link.addEventListener('keydown', function(event) { | |
142 if (event.keyCode == 46 /* DELETE */ || | |
huangs
2014/09/11 20:31:41
Need to handle ENTER, perhaps.
Mathieu
2014/09/11 20:54:10
Done.
| |
143 event.keyCode == 8 /* BACKSPACE */) { | |
144 event.preventDefault(); | |
145 window.parent.postMessage('tileBlacklisted,' + params.pos, DOMAIN_ORIGIN); | |
146 } | |
147 }); | |
135 | 148 |
136 // Webkit's security policy prevents some Most Visited thumbnails from | 149 // Webkit's security policy prevents some Most Visited thumbnails from |
137 // working (those with schemes different from http and https). Therefore, | 150 // working (those with schemes different from http and https). Therefore, |
138 // navigateContentWindow is being used in order to get all schemes working. | 151 // navigateContentWindow is being used in order to get all schemes working. |
139 link.addEventListener('click', function handleNavigation(e) { | 152 link.addEventListener('click', function handleNavigation(e) { |
140 var isServerSuggestion = 'url' in params; | 153 var isServerSuggestion = 'url' in params; |
141 | 154 |
142 // Ping are only populated for server-side suggestions, never for MV. | 155 // Ping are only populated for server-side suggestions, never for MV. |
143 if (isServerSuggestion && params.ping) { | 156 if (isServerSuggestion && params.ping) { |
144 generatePing(DOMAIN_ORIGIN + params.ping); | 157 generatePing(DOMAIN_ORIGIN + params.ping); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
278 if (navigator.sendBeacon) { | 291 if (navigator.sendBeacon) { |
279 navigator.sendBeacon(url); | 292 navigator.sendBeacon(url); |
280 } else { | 293 } else { |
281 // if sendBeacon is not enabled, we fallback for "a ping". | 294 // if sendBeacon is not enabled, we fallback for "a ping". |
282 var a = document.createElement('a'); | 295 var a = document.createElement('a'); |
283 a.href = '#'; | 296 a.href = '#'; |
284 a.ping = url; | 297 a.ping = url; |
285 a.click(); | 298 a.click(); |
286 } | 299 } |
287 } | 300 } |
OLD | NEW |