Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: chrome/browser/resources/local_ntp/most_visited_single.js

Issue 2535803002: NTP: Remove impression/click pings (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 /**
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 */ 76 */
77 var tiles = null; 77 var tiles = null;
78 78
79 79
80 /** 80 /**
81 * List of parameters passed by query args. 81 * List of parameters passed by query args.
82 * @type {Object} 82 * @type {Object}
83 */ 83 */
84 var queryArgs = {}; 84 var queryArgs = {};
85 85
86 /**
87 * Url to ping when suggestions have been shown.
88 */
89 var impressionUrl = null;
90
91 86
92 /** 87 /**
93 * Log an event on the NTP. 88 * Log an event on the NTP.
94 * @param {number} eventType Event from LOG_TYPE. 89 * @param {number} eventType Event from LOG_TYPE.
95 */ 90 */
96 var logEvent = function(eventType) { 91 var logEvent = function(eventType) {
97 chrome.embeddedSearch.newTabPage.logEvent(eventType); 92 chrome.embeddedSearch.newTabPage.logEvent(eventType);
98 }; 93 };
99 94
100 /** 95 /**
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 parent.appendChild(cur); 267 parent.appendChild(cur);
273 // getComputedStyle causes the initial style (opacity 0) to be applied, so 268 // getComputedStyle causes the initial style (opacity 0) to be applied, so
274 // that when we then set it to 1, that triggers the CSS transition. 269 // that when we then set it to 1, that triggers the CSS transition.
275 if (fadeIn) { 270 if (fadeIn) {
276 window.getComputedStyle(cur).opacity; 271 window.getComputedStyle(cur).opacity;
277 } 272 }
278 cur.style.opacity = 1.0; 273 cur.style.opacity = 1.0;
279 274
280 // Make sure the tiles variable contain the next tileset we may use. 275 // Make sure the tiles variable contain the next tileset we may use.
281 tiles = document.createElement('div'); 276 tiles = document.createElement('div');
282
283 if (impressionUrl) {
284 navigator.sendBeacon(impressionUrl);
285 impressionUrl = null;
286 }
287 }; 277 };
288 278
289 279
290 /** 280 /**
291 * Called when the host page wants to add a suggestion tile. 281 * Called when the host page wants to add a suggestion tile.
292 * For Most Visited, it grabs the data from Chrome and pass on. 282 * For Most Visited, it grabs the data from Chrome and pass on.
293 * For host page generated it just passes the data. 283 * For host page generated it just passes the data.
294 * @param {object} args Data for the tile to be rendered. 284 * @param {object} args Data for the tile to be rendered.
295 */ 285 */
296 var addTile = function(args) { 286 var addTile = function(args) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 html.push('<div class="mv-title"></div><div class="mv-thumb"></div>'); 366 html.push('<div class="mv-title"></div><div class="mv-thumb"></div>');
377 html.push('<div class="mv-x" role="button"></div>'); 367 html.push('<div class="mv-x" role="button"></div>');
378 tile.innerHTML = html.join(''); 368 tile.innerHTML = html.join('');
379 tile.lastElementChild.title = queryArgs['removeTooltip'] || ''; 369 tile.lastElementChild.title = queryArgs['removeTooltip'] || '';
380 370
381 if (isSchemeAllowed(data.url)) { 371 if (isSchemeAllowed(data.url)) {
382 tile.href = data.url; 372 tile.href = data.url;
383 } 373 }
384 tile.setAttribute('aria-label', data.title); 374 tile.setAttribute('aria-label', data.title);
385 tile.title = data.title; 375 tile.title = data.title;
386 if (data.impressionUrl) {
387 impressionUrl = data.impressionUrl;
388 }
389 if (data.pingUrl) {
390 tile.addEventListener('click', function(ev) {
391 navigator.sendBeacon(data.pingUrl);
392 });
393 }
394 376
395 tile.addEventListener('click', function(ev) { 377 tile.addEventListener('click', function(ev) {
396 logMostVisitedNavigation(position, data.tileSource); 378 logMostVisitedNavigation(position, data.tileSource);
397 }); 379 });
398 380
399 tile.addEventListener('keydown', function(event) { 381 tile.addEventListener('keydown', function(event) {
400 if (event.keyCode == 46 /* DELETE */ || 382 if (event.keyCode == 46 /* DELETE */ ||
401 event.keyCode == 8 /* BACKSPACE */) { 383 event.keyCode == 8 /* BACKSPACE */) {
402 event.preventDefault(); 384 event.preventDefault();
403 event.stopPropagation(); 385 event.stopPropagation();
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 var html = document.querySelector('html'); 588 var html = document.querySelector('html');
607 html.dir = 'rtl'; 589 html.dir = 'rtl';
608 } 590 }
609 591
610 window.addEventListener('message', handlePostMessage); 592 window.addEventListener('message', handlePostMessage);
611 }; 593 };
612 594
613 595
614 window.addEventListener('DOMContentLoaded', init); 596 window.addEventListener('DOMContentLoaded', init);
615 })(); 597 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698