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 * Enum for the different types of events that are logged from the NTP. | 13 * Enum for the different types of events that are logged from the NTP. |
14 * @enum {number} | 14 * @enum {number} |
15 * @const | 15 * @const |
16 */ | 16 */ |
17 var NTP_LOGGING_EVENT_TYPE = { | 17 var NTP_LOGGING_EVENT_TYPE = { |
18 // The user moused over an NTP tile or title. | 18 // The suggestion is coming from the server. |
19 NTP_MOUSEOVER: 0, | 19 NTP_SERVER_SIDE_SUGGESTION: 0, |
20 // The page attempted to load a thumbnail image. | 20 // The suggestion is coming from the client. |
21 NTP_THUMBNAIL_ATTEMPT: 1, | 21 NTP_CLIENT_SIDE_SUGGESTION: 1, |
| 22 // Indicates a tile was rendered, no matter if it's a thumbnail, a gray tile |
| 23 // or an external tile. |
| 24 NTP_TILE: 2, |
| 25 // The tile uses a local thumbnail image. |
| 26 NTP_THUMBNAIL_TILE: 3, |
| 27 // Used when no thumbnail is specified and a gray tile with the domain is used |
| 28 // as the main tile. |
| 29 NTP_GRAY_TILE: 4, |
| 30 // The visuals of that tile are handled externally by the page itself. |
| 31 NTP_EXTERNAL_TILE: 5, |
22 // There was an error in loading both the thumbnail image and the fallback | 32 // There was an error in loading both the thumbnail image and the fallback |
23 // (if it was provided), resulting in a grey tile. | 33 // (if it was provided), resulting in a grey tile. |
24 NTP_THUMBNAIL_ERROR: 2, | 34 NTP_THUMBNAIL_ERROR: 6, |
25 // The page attempted to load a thumbnail URL while a fallback thumbnail was | 35 // Used a gray tile with the domain as the fallback for a failed thumbnail. |
26 // provided. | 36 NTP_GRAY_TILE_FALLBACK: 7, |
27 NTP_FALLBACK_THUMBNAIL_REQUESTED: 3, | 37 // The visuals of that tile's fallback are handled externally. |
28 // The primary thumbnail image failed to load and caused us to use the | 38 NTP_EXTERNAL_TILE_FALLBACK: 8, |
29 // secondary thumbnail as a fallback. | 39 // The user moused over an NTP tile or title. |
30 NTP_FALLBACK_THUMBNAIL_USED: 4, | 40 NTP_MOUSEOVER: 9 |
31 // The suggestion is coming from the server. | |
32 NTP_SERVER_SIDE_SUGGESTION: 5, | |
33 // The suggestion is coming from the client. | |
34 NTP_CLIENT_SIDE_SUGGESTION: 6, | |
35 // The visuals of that tile are handled externally by the page itself. | |
36 NTP_EXTERNAL_TILE: 7 | |
37 }; | 41 }; |
38 | 42 |
39 /** | 43 /** |
40 * Type of the impression provider for a generic client-provided suggestion. | 44 * Type of the impression provider for a generic client-provided suggestion. |
41 * @type {string} | 45 * @type {string} |
42 * @const | 46 * @const |
43 */ | 47 */ |
44 var CLIENT_PROVIDER_NAME = 'client'; | 48 var CLIENT_PROVIDER_NAME = 'client'; |
45 | 49 |
46 /** | 50 /** |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 } | 200 } |
197 if (/^javascript:/i.test(data.url) || | 201 if (/^javascript:/i.test(data.url) || |
198 /^javascript:/i.test(data.thumbnailUrl) || | 202 /^javascript:/i.test(data.thumbnailUrl) || |
199 /^javascript:/i.test(data.thumbnailUrl2) || | 203 /^javascript:/i.test(data.thumbnailUrl2) || |
200 !/^[a-z0-9]{0,8}$/i.test(data.provider)) | 204 !/^[a-z0-9]{0,8}$/i.test(data.provider)) |
201 return; | 205 return; |
202 if (data.direction) | 206 if (data.direction) |
203 document.body.dir = data.direction; | 207 document.body.dir = data.direction; |
204 fill(params, data); | 208 fill(params, data); |
205 } | 209 } |
OLD | NEW |