| OLD | NEW |
| 1 /* Copyright 2015 The Chromium Authors. All rights reserved. | 1 /* Copyright 2015 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 // Single iframe for NTP tiles. | 5 // Single iframe for NTP tiles. |
| 6 (function() { | 6 (function() { |
| 7 'use strict'; | 7 'use strict'; |
| 8 | 8 |
| 9 | 9 |
| 10 /** | 10 /** |
| 11 * The different types of events that are logged from the NTP. This enum is | 11 * The different types of events that are logged from the NTP. This enum is |
| 12 * used to transfer information from the NTP JavaScript to the renderer and is | 12 * used to transfer information from the NTP JavaScript to the renderer and is |
| 13 * not used as a UMA enum histogram's logged value. | 13 * not used as a UMA enum histogram's logged value. |
| 14 * Note: Keep in sync with common/ntp_logging_events.h | 14 * Note: Keep in sync with common/ntp_logging_events.h |
| 15 * @enum {number} | 15 * @enum {number} |
| 16 * @const | 16 * @const |
| 17 */ | 17 */ |
| 18 var LOG_TYPE = { | 18 var LOG_TYPE = { |
| 19 // The suggestion is coming from the server. | 19 // A suggestion coming from the server was rendered. |
| 20 NTP_SERVER_SIDE_SUGGESTION: 0, | 20 NTP_SERVER_SIDE_SUGGESTION: 0, |
| 21 // The suggestion is coming from the client. | 21 // A suggestion coming from the client was rendered. |
| 22 NTP_CLIENT_SIDE_SUGGESTION: 1, | 22 NTP_CLIENT_SIDE_SUGGESTION: 1, |
| 23 // Indicates a tile was rendered, no matter if it's a thumbnail, a gray tile | |
| 24 // or an external tile. | |
| 25 NTP_TILE: 2, | |
| 26 // All NTP Tiles have finished loading (successfully or failing). | 23 // All NTP Tiles have finished loading (successfully or failing). |
| 27 NTP_ALL_TILES_LOADED: 11, | 24 NTP_ALL_TILES_LOADED: 11, |
| 28 }; | 25 }; |
| 29 | 26 |
| 30 | 27 |
| 31 /** | 28 /** |
| 32 * The different sources that an NTP tile can have. | 29 * The different sources that an NTP tile can have. |
| 33 * Note: Keep in sync with common/ntp_logging_events.h | 30 * Note: Keep in sync with common/ntp_logging_events.h |
| 34 * @enum {number} | 31 * @enum {number} |
| 35 * @const | 32 * @const |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 * data is null if you want to construct an empty tile. | 361 * data is null if you want to construct an empty tile. |
| 365 */ | 362 */ |
| 366 var renderTile = function(data) { | 363 var renderTile = function(data) { |
| 367 var tile = document.createElement('a'); | 364 var tile = document.createElement('a'); |
| 368 | 365 |
| 369 if (data == null) { | 366 if (data == null) { |
| 370 tile.className = 'mv-empty-tile'; | 367 tile.className = 'mv-empty-tile'; |
| 371 return tile; | 368 return tile; |
| 372 } | 369 } |
| 373 | 370 |
| 374 logEvent(LOG_TYPE.NTP_TILE); | |
| 375 // The tile will be appended to tiles. | 371 // The tile will be appended to tiles. |
| 376 var position = tiles.children.length; | 372 var position = tiles.children.length; |
| 377 logMostVisitedImpression(position, data.tileSource); | 373 logMostVisitedImpression(position, data.tileSource); |
| 378 | 374 |
| 379 tile.className = 'mv-tile'; | 375 tile.className = 'mv-tile'; |
| 380 tile.setAttribute('data-tid', data.tid); | 376 tile.setAttribute('data-tid', data.tid); |
| 381 var html = []; | 377 var html = []; |
| 382 if (!USE_ICONS) { | 378 if (!USE_ICONS) { |
| 383 html.push('<div class="mv-favicon"></div>'); | 379 html.push('<div class="mv-favicon"></div>'); |
| 384 } | 380 } |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 var html = document.querySelector('html'); | 611 var html = document.querySelector('html'); |
| 616 html.dir = 'rtl'; | 612 html.dir = 'rtl'; |
| 617 } | 613 } |
| 618 | 614 |
| 619 window.addEventListener('message', handlePostMessage); | 615 window.addEventListener('message', handlePostMessage); |
| 620 }; | 616 }; |
| 621 | 617 |
| 622 | 618 |
| 623 window.addEventListener('DOMContentLoaded', init); | 619 window.addEventListener('DOMContentLoaded', init); |
| 624 })(); | 620 })(); |
| OLD | NEW |