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

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

Issue 2525653002: NewTabPage: Remove impression/click ping plumbing for local NTP (Closed)
Patch Set: Created 4 years, 1 month 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
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
mastiz 2016/11/28 13:46:22 As discussed offline, I'd prefer if the javascript
Marc Treib 2016/11/28 13:56:47 Done.
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 html.push('<div class="mv-title"></div><div class="mv-thumb"></div>'); 365 html.push('<div class="mv-title"></div><div class="mv-thumb"></div>');
376 html.push('<div class="mv-x" role="button"></div>'); 366 html.push('<div class="mv-x" role="button"></div>');
377 tile.innerHTML = html.join(''); 367 tile.innerHTML = html.join('');
378 tile.lastElementChild.title = queryArgs['removeTooltip'] || ''; 368 tile.lastElementChild.title = queryArgs['removeTooltip'] || '';
379 369
380 if (isSchemeAllowed(data.url)) { 370 if (isSchemeAllowed(data.url)) {
381 tile.href = data.url; 371 tile.href = data.url;
382 } 372 }
383 tile.setAttribute('aria-label', data.title); 373 tile.setAttribute('aria-label', data.title);
384 tile.title = data.title; 374 tile.title = data.title;
385 if (data.impressionUrl) {
386 impressionUrl = data.impressionUrl;
387 }
388 if (data.pingUrl) {
389 tile.addEventListener('click', function(ev) {
390 navigator.sendBeacon(data.pingUrl);
391 });
392 }
393 375
394 tile.addEventListener('click', function(ev) { 376 tile.addEventListener('click', function(ev) {
395 logMostVisitedNavigation(position, data.tileSource); 377 logMostVisitedNavigation(position, data.tileSource);
396 }); 378 });
397 379
398 tile.addEventListener('keydown', function(event) { 380 tile.addEventListener('keydown', function(event) {
399 if (event.keyCode == 46 /* DELETE */ || 381 if (event.keyCode == 46 /* DELETE */ ||
400 event.keyCode == 8 /* BACKSPACE */) { 382 event.keyCode == 8 /* BACKSPACE */) {
401 event.preventDefault(); 383 event.preventDefault();
402 event.stopPropagation(); 384 event.stopPropagation();
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 var html = document.querySelector('html'); 587 var html = document.querySelector('html');
606 html.dir = 'rtl'; 588 html.dir = 'rtl';
607 } 589 }
608 590
609 window.addEventListener('message', handlePostMessage); 591 window.addEventListener('message', handlePostMessage);
610 }; 592 };
611 593
612 594
613 window.addEventListener('DOMContentLoaded', init); 595 window.addEventListener('DOMContentLoaded', init);
614 })(); 596 })();
OLDNEW
« no previous file with comments | « no previous file | chrome/common/render_messages.h » ('j') | components/suggestions/proto/suggestions.proto » ('J')

Powered by Google App Engine
This is Rietveld 408576698