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

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

Issue 111423005: [Most Visited] Log suggestion provider to UMA (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years 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() {
11 'use strict'; 11 'use strict';
12 12
13 fillMostVisited(document.location, function(params, data) { 13 fillMostVisited(document.location, function(params, data) {
14 function logEvent(eventName) { 14 function logEvent(eventName) {
15 chrome.embeddedSearch.newTabPage.logEvent(eventName); 15 chrome.embeddedSearch.newTabPage.logEvent(eventName);
16 } 16 }
17 function showDomainElement() { 17 function showDomainElement() {
18 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_THUMBNAIL_ERROR); 18 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_THUMBNAIL_ERROR);
19 var link = createMostVisitedLink( 19 var link = createMostVisitedLink(
20 params, data.url, data.title, undefined, data.ping); 20 params, data.url, data.title, undefined, data.ping, data.provider);
21 var domain = document.createElement('div'); 21 var domain = document.createElement('div');
22 domain.textContent = data.domain; 22 domain.textContent = data.domain;
23 link.appendChild(domain); 23 link.appendChild(domain);
24 document.body.appendChild(link); 24 document.body.appendChild(link);
25 } 25 }
26 // Called on intentionally empty tiles for which the visuals are handled 26 // Called on intentionally empty tiles for which the visuals are handled
27 // externally by the page itself. 27 // externally by the page itself.
28 function showEmptyTile() { 28 function showEmptyTile() {
29 var link = createMostVisitedLink( 29 var link = createMostVisitedLink(
30 params, data.url, data.title, undefined, data.ping); 30 params, data.url, data.title, undefined, data.ping, data.provider);
31 document.body.appendChild(link); 31 document.body.appendChild(link);
32 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_EXTERNAL_TILE); 32 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_EXTERNAL_TILE);
33 } 33 }
34 function createAndAppendThumbnail(isVisible) { 34 function createAndAppendThumbnail(isVisible) {
35 var image = new Image(); 35 var image = new Image();
36 image.onload = function() { 36 image.onload = function() {
37 var shadow = document.createElement('span'); 37 var shadow = document.createElement('span');
38 shadow.classList.add('shadow'); 38 shadow.classList.add('shadow');
39 var link = createMostVisitedLink( 39 var link = createMostVisitedLink(
40 params, data.url, data.title, undefined, data.ping); 40 params, data.url, data.title, undefined, data.ping, data.provider);
41 link.appendChild(shadow); 41 link.appendChild(shadow);
42 link.appendChild(image); 42 link.appendChild(image);
43 // We add 'position: absolute' in anticipation that there could be more 43 // We add 'position: absolute' in anticipation that there could be more
44 // than one thumbnail. This will superpose the elements. 44 // than one thumbnail. This will superpose the elements.
45 link.style.position = 'absolute'; 45 link.style.position = 'absolute';
46 document.body.appendChild(link); 46 document.body.appendChild(link);
47 }; 47 };
48 if (!isVisible) { 48 if (!isVisible) {
49 image.style.visibility = 'hidden'; 49 image.style.visibility = 'hidden';
50 } 50 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 86 }
87 image.src = data.thumbnailUrl; 87 image.src = data.thumbnailUrl;
88 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_THUMBNAIL_ATTEMPT); 88 logEvent(NTP_LOGGING_EVENT_TYPE.NTP_THUMBNAIL_ATTEMPT);
89 } else if (data.domain) { 89 } else if (data.domain) {
90 showDomainElement(); 90 showDomainElement();
91 } else { 91 } else {
92 showEmptyTile(); 92 showEmptyTile();
93 } 93 }
94 }); 94 });
95 }); 95 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698