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

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

Issue 473583002: [Local NTP] Implementing Material Design styling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing comments. Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
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 Rendering for iframed most visited thumbnails. 7 * @fileoverview Rendering for iframed most visited thumbnails.
8 */ 8 */
9 9
10 window.addEventListener('DOMContentLoaded', function() { 10 window.addEventListener('DOMContentLoaded', function() {
(...skipping 24 matching lines...) Expand all
35 // externally by the page itself. 35 // externally by the page itself.
36 function showEmptyTile() { 36 function showEmptyTile() {
37 displayLink(createMostVisitedLink( 37 displayLink(createMostVisitedLink(
38 params, data.url, data.title, undefined, data.direction, 38 params, data.url, data.title, undefined, data.direction,
39 data.provider)); 39 data.provider));
40 } 40 }
41 // Creates and adds an image. 41 // Creates and adds an image.
42 function createThumbnail(src) { 42 function createThumbnail(src) {
43 var image = document.createElement('img'); 43 var image = document.createElement('img');
44 image.onload = function() { 44 image.onload = function() {
45 var shadow = document.createElement('span');
46 shadow.className = 'shadow';
47 var link = createMostVisitedLink( 45 var link = createMostVisitedLink(
48 params, data.url, data.title, undefined, data.direction, 46 params, data.url, data.title, undefined, data.direction,
49 data.provider); 47 data.provider);
50 link.appendChild(shadow);
51 link.appendChild(image); 48 link.appendChild(image);
52 displayLink(link); 49 displayLink(link);
53 }; 50 };
54 image.onerror = function() { 51 image.onerror = function() {
55 if (data.domain) { 52 // If no external thumbnail fallback (etfb), and have domain.
53 if (!params.etfb && data.domain) {
56 showDomainElement(); 54 showDomainElement();
57 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_GRAY_TILE_FALLBACK); 55 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_GRAY_TILE_FALLBACK);
58 } else { 56 } else {
59 showEmptyTile(); 57 showEmptyTile();
60 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_EXTERNAL_TILE_FALLBACK); 58 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_EXTERNAL_TILE_FALLBACK);
61 } 59 }
62 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_THUMBNAIL_ERROR); 60 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_THUMBNAIL_ERROR);
63 }; 61 };
64 image.src = src; 62 image.src = src;
65 } 63 }
66 64
67 if (data.thumbnailUrl) { 65 if (data.thumbnailUrl) {
68 createThumbnail(data.thumbnailUrl); 66 createThumbnail(data.thumbnailUrl);
69 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_THUMBNAIL_TILE); 67 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_THUMBNAIL_TILE);
70 } else if (data.domain) { 68 } else if (data.domain) {
71 showDomainElement(); 69 showDomainElement();
72 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_GRAY_TILE); 70 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_GRAY_TILE);
73 } else { 71 } else {
74 showEmptyTile(); 72 showEmptyTile();
75 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_EXTERNAL_TILE); 73 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_EXTERNAL_TILE);
76 } 74 }
77 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_TILE); 75 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_TILE);
78 76
79 // Log an impression if we know the position of the tile. 77 // Log an impression if we know the position of the tile.
80 if (isFinite(params.pos) && data.provider) { 78 if (isFinite(params.pos) && data.provider) {
81 logMostVisitedImpression(parseInt(params.pos, 10), data.provider); 79 logMostVisitedImpression(parseInt(params.pos, 10), data.provider);
82 } 80 }
83 }); 81 });
84 }); 82 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/local_ntp/most_visited_thumbnail.css ('k') | chrome/browser/resources/local_ntp/most_visited_util.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698