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"> |
11 | 11 |
12 | 12 |
13 /** | 13 /** |
14 * The origin of this request. | 14 * The origin of this request. |
15 * @const {string} | 15 * @const {string} |
16 */ | 16 */ |
17 var DOMAIN_ORIGIN = '{{ORIGIN}}'; | 17 var DOMAIN_ORIGIN = '{{ORIGIN}}'; |
18 | 18 |
19 /** | 19 /** |
20 * Parses query parameters from Location. | 20 * Parses query parameters from Location. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 // Follow <a> normally, so transition type will be LINK. | 101 // Follow <a> normally, so transition type will be LINK. |
102 }; | 102 }; |
103 | 103 |
104 link.addEventListener('click', navigateFunction); | 104 link.addEventListener('click', navigateFunction); |
105 link.addEventListener('keydown', function(event) { | 105 link.addEventListener('keydown', function(event) { |
106 if (event.keyCode == 46 /* DELETE */ || | 106 if (event.keyCode == 46 /* DELETE */ || |
107 event.keyCode == 8 /* BACKSPACE */) { | 107 event.keyCode == 8 /* BACKSPACE */) { |
108 event.preventDefault(); | 108 event.preventDefault(); |
109 window.parent.postMessage('tileBlacklisted,' + params.pos, DOMAIN_ORIGIN); | 109 window.parent.postMessage('tileBlacklisted,' + params.pos, DOMAIN_ORIGIN); |
110 } else if (event.keyCode == 13 /* ENTER */ || | 110 } else if ( |
111 event.keyCode == 32 /* SPACE */) { | 111 event.keyCode == 13 /* ENTER */ || event.keyCode == 32 /* SPACE */) { |
112 // Event target is the <a> tag. Send a click event on it, which will | 112 // Event target is the <a> tag. Send a click event on it, which will |
113 // trigger the 'click' event registered above. | 113 // trigger the 'click' event registered above. |
114 event.preventDefault(); | 114 event.preventDefault(); |
115 event.target.click(); | 115 event.target.click(); |
116 } | 116 } |
117 }); | 117 }); |
118 | 118 |
119 return link; | 119 return link; |
120 } | 120 } |
121 | 121 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 } else { | 214 } else { |
215 var apiHandle = chrome.embeddedSearch.newTabPage; | 215 var apiHandle = chrome.embeddedSearch.newTabPage; |
216 data = apiHandle.getMostVisitedItemData(params.rid); | 216 data = apiHandle.getMostVisitedItemData(params.rid); |
217 if (!data) | 217 if (!data) |
218 return; | 218 return; |
219 } | 219 } |
220 | 220 |
221 if (isFinite(params.dummy) && parseInt(params.dummy, 10)) { | 221 if (isFinite(params.dummy) && parseInt(params.dummy, 10)) { |
222 data.dummy = true; | 222 data.dummy = true; |
223 } | 223 } |
224 if (/^javascript:/i.test(data.url) || | 224 if (/^javascript:/i.test(data.url) || /^javascript:/i.test(data.thumbnailUrl)) |
225 /^javascript:/i.test(data.thumbnailUrl)) | |
226 return; | 225 return; |
227 if (data.direction) | 226 if (data.direction) |
228 document.body.dir = data.direction; | 227 document.body.dir = data.direction; |
229 fill(params, data); | 228 fill(params, data); |
230 } | 229 } |
231 | 230 |
232 | 231 |
233 /** | 232 /** |
234 * Sends a POST request to ping url. | 233 * Sends a POST request to ping url. |
235 * @param {string} url URL to be pinged. | 234 * @param {string} url URL to be pinged. |
236 */ | 235 */ |
237 function generatePing(url) { | 236 function generatePing(url) { |
238 if (navigator.sendBeacon) { | 237 if (navigator.sendBeacon) { |
239 navigator.sendBeacon(url); | 238 navigator.sendBeacon(url); |
240 } else { | 239 } else { |
241 // if sendBeacon is not enabled, we fallback for "a ping". | 240 // if sendBeacon is not enabled, we fallback for "a ping". |
242 var a = document.createElement('a'); | 241 var a = document.createElement('a'); |
243 a.href = '#'; | 242 a.href = '#'; |
244 a.ping = url; | 243 a.ping = url; |
245 a.click(); | 244 a.click(); |
246 } | 245 } |
247 } | 246 } |
OLD | NEW |