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

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: 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 (!params.tfb && data.domain) {
Mathieu 2014/08/13 20:09:30 handle this param better
huangs 2014/08/13 21:34:09 Calling this etfb and adding comments. Note that
56 showDomainElement(); 53 showDomainElement();
57 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_GRAY_TILE_FALLBACK); 54 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_GRAY_TILE_FALLBACK);
58 } else { 55 } else {
59 showEmptyTile(); 56 showEmptyTile();
60 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_EXTERNAL_TILE_FALLBACK); 57 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_EXTERNAL_TILE_FALLBACK);
61 } 58 }
62 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_THUMBNAIL_ERROR); 59 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_THUMBNAIL_ERROR);
63 }; 60 };
64 image.src = src; 61 image.src = src;
65 } 62 }
66 63
67 if (data.thumbnailUrl) { 64 if (data.thumbnailUrl) {
68 createThumbnail(data.thumbnailUrl); 65 createThumbnail(data.thumbnailUrl);
69 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_THUMBNAIL_TILE); 66 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_THUMBNAIL_TILE);
70 } else if (data.domain) { 67 } else if (data.domain) {
71 showDomainElement(); 68 showDomainElement();
72 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_GRAY_TILE); 69 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_GRAY_TILE);
73 } else { 70 } else {
74 showEmptyTile(); 71 showEmptyTile();
75 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_EXTERNAL_TILE); 72 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_EXTERNAL_TILE);
76 } 73 }
77 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_TILE); 74 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_TILE);
78 75
79 // Log an impression if we know the position of the tile. 76 // Log an impression if we know the position of the tile.
80 if (isFinite(params.pos) && data.provider) { 77 if (isFinite(params.pos) && data.provider) {
81 logMostVisitedImpression(parseInt(params.pos, 10), data.provider); 78 logMostVisitedImpression(parseInt(params.pos, 10), data.provider);
82 } 79 }
83 }); 80 });
84 }); 81 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698