Chromium Code Reviews| 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 // Don't remove; see crbug.com/678778. | |
| 10 // <include src="instant_iframe_validation.js"> | 11 // <include src="instant_iframe_validation.js"> |
| 11 | 12 |
| 12 | 13 |
| 13 /** | 14 /** |
| 15 * The different types of events that are logged from the NTP. The multi-iframe | |
| 16 * version of the NTP does *not* actually log any statistics anymore; this is | |
| 17 * only required as a workaround for crbug.com/698675. | |
| 18 * Note: Keep in sync with common/ntp_logging_events.h | |
| 19 * @enum {number} | |
| 20 * @const | |
| 21 */ | |
| 22 var NTP_LOGGING_EVENT_TYPE = { | |
| 23 NTP_ALL_TILES_RECEIVED: 12, | |
| 24 }; | |
| 25 | |
| 26 | |
| 27 /** | |
| 14 * The origin of this request. | 28 * The origin of this request. |
| 15 * @const {string} | 29 * @const {string} |
| 16 */ | 30 */ |
| 17 var DOMAIN_ORIGIN = '{{ORIGIN}}'; | 31 var DOMAIN_ORIGIN = '{{ORIGIN}}'; |
| 18 | 32 |
| 19 /** | 33 /** |
| 20 * Parses query parameters from Location. | 34 * Parses query parameters from Location. |
| 21 * @param {string} location The URL to generate the CSS url for. | 35 * @param {string} location The URL to generate the CSS url for. |
| 22 * @return {Object} Dictionary containing name value pairs for URL. | 36 * @return {Object} Dictionary containing name value pairs for URL. |
| 23 */ | 37 */ |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 /** | 207 /** |
| 194 * @param {string} location A location containing URL parameters. | 208 * @param {string} location A location containing URL parameters. |
| 195 * @param {function(Object, Object)} fill A function called with styles and | 209 * @param {function(Object, Object)} fill A function called with styles and |
| 196 * data to fill. | 210 * data to fill. |
| 197 */ | 211 */ |
| 198 function fillMostVisited(location, fill) { | 212 function fillMostVisited(location, fill) { |
| 199 var params = parseQueryParams(location); | 213 var params = parseQueryParams(location); |
| 200 params.rid = parseInt(params.rid, 10); | 214 params.rid = parseInt(params.rid, 10); |
| 201 if (!isFinite(params.rid) && !params.url) | 215 if (!isFinite(params.rid) && !params.url) |
| 202 return; | 216 return; |
| 217 | |
| 218 // Note: This does not actually result in any logging; it's a workaround for | |
| 219 // crbug.com/698675. It effectively sets the "instant support" state of the | |
| 220 // page to true, which makes later calls to fetch the most visited items | |
|
sfiera
2017/03/06 15:48:01
"of the page": are we setting it for the page, or
Marc Treib
2017/03/06 18:59:18
It's a property of the whole Tab/WebContents, i.e.
sfiera
2017/03/07 15:07:59
Then, should the comment here read "state of the t
Marc Treib
2017/03/07 16:08:19
Done.
sfiera
2017/03/07 16:26:24
OK, so it sounds like "page supports Instant" is n
Marc Treib
2017/03/07 16:33:55
Well, the problem is really that "Instant" means d
| |
| 221 // succeed. | |
| 222 chrome.embeddedSearch.newTabPage.logEvent( | |
| 223 NTP_LOGGING_EVENT_TYPE.NTP_ALL_TILES_RECEIVED); | |
|
sfiera
2017/03/06 15:48:01
Would it make more sense to put this right before
Marc Treib
2017/03/06 18:59:18
I haven't tried, but I think that's too late: This
sfiera
2017/03/07 15:07:59
It looks to me that the only things happening betw
Marc Treib
2017/03/07 16:08:19
D'oh, somehow I missed that that other call is jus
| |
| 224 | |
| 203 var data; | 225 var data; |
| 204 if (params.url) { | 226 if (params.url) { |
| 205 // Means that the suggestion data comes from the server. Create data object. | 227 // Means that the suggestion data comes from the server. Create data object. |
| 206 data = { | 228 data = { |
| 207 url: params.url, | 229 url: params.url, |
| 208 thumbnailUrl: params.tu || '', | 230 thumbnailUrl: params.tu || '', |
| 209 title: params.ti || '', | 231 title: params.ti || '', |
| 210 direction: params.di || '', | 232 direction: params.di || '', |
| 211 domain: params.dom || '' | 233 domain: params.dom || '' |
| 212 }; | 234 }; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 237 if (navigator.sendBeacon) { | 259 if (navigator.sendBeacon) { |
| 238 navigator.sendBeacon(url); | 260 navigator.sendBeacon(url); |
| 239 } else { | 261 } else { |
| 240 // if sendBeacon is not enabled, we fallback for "a ping". | 262 // if sendBeacon is not enabled, we fallback for "a ping". |
| 241 var a = document.createElement('a'); | 263 var a = document.createElement('a'); |
| 242 a.href = '#'; | 264 a.href = '#'; |
| 243 a.ping = url; | 265 a.ping = url; |
| 244 a.click(); | 266 a.click(); |
| 245 } | 267 } |
| 246 } | 268 } |
| OLD | NEW |