| 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 title: params.ti || '', | 277 title: params.ti || '', |
| 278 direction: params.di || '', | 278 direction: params.di || '', |
| 279 domain: params.dom || '', | 279 domain: params.dom || '', |
| 280 tileSource: NTPLoggingTileSource.SERVER | 280 tileSource: NTPLoggingTileSource.SERVER |
| 281 }; | 281 }; |
| 282 } else { | 282 } else { |
| 283 var apiHandle = chrome.embeddedSearch.searchBox; | 283 var apiHandle = chrome.embeddedSearch.searchBox; |
| 284 data = apiHandle.getMostVisitedItemData(params.rid); | 284 data = apiHandle.getMostVisitedItemData(params.rid); |
| 285 if (!data) | 285 if (!data) |
| 286 return; | 286 return; |
| 287 data.tileSource: NTPLoggingTileSource.CLIENT; | 287 data.tileSource = NTPLoggingTileSource.CLIENT; |
| 288 } | 288 } |
| 289 | 289 |
| 290 if (isFinite(params.dummy) && parseInt(params.dummy, 10)) { | 290 if (isFinite(params.dummy) && parseInt(params.dummy, 10)) { |
| 291 data.dummy = true; | 291 data.dummy = true; |
| 292 } | 292 } |
| 293 if (/^javascript:/i.test(data.url) || | 293 if (/^javascript:/i.test(data.url) || |
| 294 /^javascript:/i.test(data.thumbnailUrl)) | 294 /^javascript:/i.test(data.thumbnailUrl)) |
| 295 return; | 295 return; |
| 296 if (data.direction) | 296 if (data.direction) |
| 297 document.body.dir = data.direction; | 297 document.body.dir = data.direction; |
| 298 fill(params, data); | 298 fill(params, data); |
| 299 } | 299 } |
| 300 | 300 |
| 301 | 301 |
| 302 /** | 302 /** |
| 303 * Sends a POST request to ping url. | 303 * Sends a POST request to ping url. |
| 304 * @param {string} url URL to be pinged. | 304 * @param {string} url URL to be pinged. |
| 305 */ | 305 */ |
| 306 function generatePing(url) { | 306 function generatePing(url) { |
| 307 if (navigator.sendBeacon) { | 307 if (navigator.sendBeacon) { |
| 308 navigator.sendBeacon(url); | 308 navigator.sendBeacon(url); |
| 309 } else { | 309 } else { |
| 310 // if sendBeacon is not enabled, we fallback for "a ping". | 310 // if sendBeacon is not enabled, we fallback for "a ping". |
| 311 var a = document.createElement('a'); | 311 var a = document.createElement('a'); |
| 312 a.href = '#'; | 312 a.href = '#'; |
| 313 a.ping = url; | 313 a.ping = url; |
| 314 a.click(); | 314 a.click(); |
| 315 } | 315 } |
| 316 } | 316 } |
| OLD | NEW |