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

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

Issue 1013173003: [Icons NTP] Make Local NTP render largeIconUrl instead of thumbnail, if available. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 | « chrome/browser/resources/local_ntp/most_visited_thumbnail.css ('k') | 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 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 21 matching lines...) Expand all
32 displayLink(link); 32 displayLink(link);
33 } 33 }
34 // Called on intentionally empty tiles for which the visuals are handled 34 // Called on intentionally empty tiles for which the visuals are handled
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, imageClass) {
43 var image = document.createElement('img'); 43 var image = document.createElement('img');
44 if (imageClass) {
45 image.classList.add(imageClass);
46 }
44 image.onload = function() { 47 image.onload = function() {
45 var link = createMostVisitedLink( 48 var link = createMostVisitedLink(
46 params, data.url, data.title, undefined, data.direction, 49 params, data.url, data.title, undefined, data.direction,
47 data.provider); 50 data.provider);
48 // Use blocker to prevent context menu from showing image-related items. 51 // Use blocker to prevent context menu from showing image-related items.
49 var blocker = document.createElement('span'); 52 var blocker = document.createElement('span');
50 blocker.className = 'blocker'; 53 blocker.className = 'blocker';
51 link.appendChild(blocker); 54 link.appendChild(blocker);
52 link.appendChild(image); 55 link.appendChild(image);
53 displayLink(link); 56 displayLink(link);
54 }; 57 };
55 image.onerror = function() { 58 image.onerror = function() {
56 // If no external thumbnail fallback (etfb), and have domain. 59 // If no external thumbnail fallback (etfb), and have domain.
57 if (!params.etfb && data.domain) { 60 if (!params.etfb && data.domain) {
58 showDomainElement(); 61 showDomainElement();
59 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_GRAY_TILE_FALLBACK); 62 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_GRAY_TILE_FALLBACK);
60 } else { 63 } else {
61 showEmptyTile(); 64 showEmptyTile();
62 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_EXTERNAL_TILE_FALLBACK); 65 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_EXTERNAL_TILE_FALLBACK);
63 } 66 }
64 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_THUMBNAIL_ERROR); 67 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_THUMBNAIL_ERROR);
65 }; 68 };
66 image.src = src; 69 image.src = src;
67 } 70 }
68 71
69 if (data.dummy) { 72 if (data.dummy) {
70 showEmptyTile(); 73 showEmptyTile();
71 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_EXTERNAL_TILE); 74 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_EXTERNAL_TILE);
75 } else if (data.largeIconUrl) {
76 createThumbnail(data.largeIconUrl, 'large-icon');
77 // TODO(huangs): Log event for large icons.
72 } else if (data.thumbnailUrl) { 78 } else if (data.thumbnailUrl) {
73 createThumbnail(data.thumbnailUrl); 79 createThumbnail(data.thumbnailUrl, 'thumbnail');
74 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_THUMBNAIL_TILE); 80 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_THUMBNAIL_TILE);
75 } else if (data.domain) { 81 } else if (data.domain) {
76 showDomainElement(); 82 showDomainElement();
77 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_GRAY_TILE); 83 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_GRAY_TILE);
78 } else { 84 } else {
79 showEmptyTile(); 85 showEmptyTile();
80 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_EXTERNAL_TILE); 86 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_EXTERNAL_TILE);
81 } 87 }
82 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_TILE); 88 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_TILE);
83 89
84 // Log an impression if we know the position of the tile. 90 // Log an impression if we know the position of the tile.
85 if (isFinite(params.pos) && data.provider) { 91 if (isFinite(params.pos) && data.provider) {
86 logMostVisitedImpression(parseInt(params.pos, 10), data.provider); 92 logMostVisitedImpression(parseInt(params.pos, 10), data.provider);
87 } 93 }
88 }); 94 });
89 }); 95 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/local_ntp/most_visited_thumbnail.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698