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

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

Issue 2124953004: Remove a bunch of broken/unused/non-useful NTP UMA histograms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 months 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 | chrome/browser/resources/local_ntp/most_visited_thumbnail.js » ('j') | 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 /**
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 // The suggestion is coming from the server.
20 NTP_SERVER_SIDE_SUGGESTION: 0, 20 NTP_SERVER_SIDE_SUGGESTION: 0,
21 // The suggestion is coming from the client. 21 // The suggestion is coming from the client.
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 23 // Indicates a tile was rendered, no matter if it's a thumbnail, a gray tile
24 // or an external tile. 24 // or an external tile.
25 NTP_TILE: 2, 25 NTP_TILE: 2,
26 // The tile uses a local thumbnail image.
27 NTP_THUMBNAIL_TILE: 3,
28 // There was an error in loading both the thumbnail image and the fallback
29 // (if it was provided), resulting in a gray tile.
30 NTP_THUMBNAIL_ERROR: 6,
31 // A NTP Tile has finished loading (successfully or failing). 26 // A NTP Tile has finished loading (successfully or failing).
32 NTP_TILE_LOADED: 10, 27 NTP_TILE_LOADED: 10,
33 }; 28 };
34 29
35 30
36 /** 31 /**
37 * The different sources that an NTP tile can have. 32 * The different sources that an NTP tile can have.
38 * Note: Keep in sync with common/ntp_logging_events.h 33 * Note: Keep in sync with common/ntp_logging_events.h
39 * @enum {number} 34 * @enum {number}
40 * @const 35 * @const
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 img.classList.add('large-icon'); 458 img.classList.add('large-icon');
464 loadedCounter += 1; 459 loadedCounter += 1;
465 img.addEventListener('load', countLoad); 460 img.addEventListener('load', countLoad);
466 img.addEventListener('load', function(ev) { 461 img.addEventListener('load', function(ev) {
467 thumb.classList.add('large-icon-outer'); 462 thumb.classList.add('large-icon-outer');
468 }); 463 });
469 img.addEventListener('error', countLoad); 464 img.addEventListener('error', countLoad);
470 img.addEventListener('error', function(ev) { 465 img.addEventListener('error', function(ev) {
471 thumb.classList.add('failed-img'); 466 thumb.classList.add('failed-img');
472 thumb.removeChild(img); 467 thumb.removeChild(img);
473 logEvent(LOG_TYPE.NTP_THUMBNAIL_ERROR);
474 }); 468 });
475 thumb.appendChild(img); 469 thumb.appendChild(img);
476 logEvent(LOG_TYPE.NTP_THUMBNAIL_TILE);
477 } else { 470 } else {
478 thumb.classList.add('failed-img'); 471 thumb.classList.add('failed-img');
479 } 472 }
480 } else { // THUMBNAILS 473 } else { // THUMBNAILS
481 // We keep track of the outcome of loading possible thumbnails for this 474 // We keep track of the outcome of loading possible thumbnails for this
482 // tile. Possible values: 475 // tile. Possible values:
483 // - null: waiting for load/error 476 // - null: waiting for load/error
484 // - false: error 477 // - false: error
485 // - a string: URL that loaded correctly. 478 // - a string: URL that loaded correctly.
486 // This is populated by acceptImage/rejectImage and loadBestImage 479 // This is populated by acceptImage/rejectImage and loadBestImage
(...skipping 12 matching lines...) Expand all
499 return; 492 return;
500 } 493 }
501 if (results[i] != false) { 494 if (results[i] != false) {
502 img.src = results[i]; 495 img.src = results[i];
503 loaded = true; 496 loaded = true;
504 return; 497 return;
505 } 498 }
506 } 499 }
507 thumb.classList.add('failed-img'); 500 thumb.classList.add('failed-img');
508 thumb.removeChild(img); 501 thumb.removeChild(img);
509 logEvent(LOG_TYPE.NTP_THUMBNAIL_ERROR);
510 countLoad(); 502 countLoad();
511 }; 503 };
512 504
513 var acceptImage = function(idx, url) { 505 var acceptImage = function(idx, url) {
514 return function(ev) { 506 return function(ev) {
515 results[idx] = url; 507 results[idx] = url;
516 loadBestImage(); 508 loadBestImage();
517 }; 509 };
518 }; 510 };
519 511
520 var rejectImage = function(idx) { 512 var rejectImage = function(idx) {
521 return function(ev) { 513 return function(ev) {
522 results[idx] = false; 514 results[idx] = false;
523 loadBestImage(); 515 loadBestImage();
524 }; 516 };
525 }; 517 };
526 518
527 img.title = data.title; 519 img.title = data.title;
528 img.classList.add('thumbnail'); 520 img.classList.add('thumbnail');
529 loadedCounter += 1; 521 loadedCounter += 1;
530 img.addEventListener('load', countLoad); 522 img.addEventListener('load', countLoad);
531 img.addEventListener('error', countLoad); 523 img.addEventListener('error', countLoad);
532 img.addEventListener('error', function(ev) { 524 img.addEventListener('error', function(ev) {
533 thumb.classList.add('failed-img'); 525 thumb.classList.add('failed-img');
534 thumb.removeChild(img); 526 thumb.removeChild(img);
535 logEvent(LOG_TYPE.NTP_THUMBNAIL_ERROR);
536 }); 527 });
537 thumb.appendChild(img); 528 thumb.appendChild(img);
538 logEvent(LOG_TYPE.NTP_THUMBNAIL_TILE);
539 529
540 if (data.thumbnailUrl) { 530 if (data.thumbnailUrl) {
541 img.src = data.thumbnailUrl; 531 img.src = data.thumbnailUrl;
542 } else { 532 } else {
543 // Get all thumbnailUrls for the tile. 533 // Get all thumbnailUrls for the tile.
544 // They are ordered from best one to be used to worst. 534 // They are ordered from best one to be used to worst.
545 for (var i = 0; i < data.thumbnailUrls.length; ++i) { 535 for (var i = 0; i < data.thumbnailUrls.length; ++i) {
546 results.push(null); 536 results.push(null);
547 } 537 }
548 for (var i = 0; i < data.thumbnailUrls.length; ++i) { 538 for (var i = 0; i < data.thumbnailUrls.length; ++i) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 var html = document.querySelector('html'); 610 var html = document.querySelector('html');
621 html.dir = 'rtl'; 611 html.dir = 'rtl';
622 } 612 }
623 613
624 window.addEventListener('message', handlePostMessage); 614 window.addEventListener('message', handlePostMessage);
625 }; 615 };
626 616
627 617
628 window.addEventListener('DOMContentLoaded', init); 618 window.addEventListener('DOMContentLoaded', init);
629 })(); 619 })();
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/local_ntp/most_visited_thumbnail.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698