Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Utilities for rendering most visited thumbnails and titles. | 7 * @fileoverview Utilities for rendering most visited thumbnails and titles. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 <include src="instant_iframe_validation.js"> | 10 <include src="instant_iframe_validation.js"> |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * Creates a new most visited link element. | 65 * Creates a new most visited link element. |
| 66 * @param {Object} params URL parameters containing styles for the link. | 66 * @param {Object} params URL parameters containing styles for the link. |
| 67 * @param {string} href The destination for the link. | 67 * @param {string} href The destination for the link. |
| 68 * @param {string} title The title for the link. | 68 * @param {string} title The title for the link. |
| 69 * @param {string|undefined} text The text for the link or none. | 69 * @param {string|undefined} text The text for the link or none. |
| 70 * @param {string|undefined} ping If specified, a location relative to the | 70 * @param {string|undefined} ping If specified, a location relative to the |
| 71 * referrer of this iframe, to ping when the link is clicked. Only works if | 71 * referrer of this iframe, to ping when the link is clicked. Only works if |
| 72 * the referrer is HTTPS. | 72 * the referrer is HTTPS. |
| 73 * @param {string|undefined} provider A provider name (max 8 alphanumeric | |
| 74 * characters) used for logging. Undefined if suggestion is not coming from | |
| 75 * the server. | |
| 73 * @return {HTMLAnchorElement} A new link element. | 76 * @return {HTMLAnchorElement} A new link element. |
| 74 */ | 77 */ |
| 75 function createMostVisitedLink(params, href, title, text, ping) { | 78 function createMostVisitedLink(params, href, title, text, ping, provider) { |
| 76 var styles = getMostVisitedStyles(params, !!text); | 79 var styles = getMostVisitedStyles(params, !!text); |
| 77 var link = document.createElement('a'); | 80 var link = document.createElement('a'); |
| 78 link.style.color = styles.color; | 81 link.style.color = styles.color; |
| 79 link.style.fontSize = styles.fontSize + 'px'; | 82 link.style.fontSize = styles.fontSize + 'px'; |
| 80 if (styles.fontFamily) | 83 if (styles.fontFamily) |
| 81 link.style.fontFamily = styles.fontFamily; | 84 link.style.fontFamily = styles.fontFamily; |
| 82 link.href = href; | 85 link.href = href; |
| 83 if ('pos' in params && isFinite(params.pos)) { | 86 if ('pos' in params && isFinite(params.pos)) { |
| 84 link.ping = '/log.html?pos=' + params.pos; | 87 link.ping = '/log.html?pos=' + params.pos; |
| 88 if (provider) | |
| 89 link.ping += '&pr=' + provider; | |
| 85 // If a ping parameter was specified, add it to the list of pings, relative | 90 // If a ping parameter was specified, add it to the list of pings, relative |
| 86 // to the referrer of this iframe, which is the default search provider. | 91 // to the referrer of this iframe, which is the default search provider. |
| 87 if (ping) { | 92 if (ping) { |
| 88 var parentUrl = document.createElement('a'); | 93 var parentUrl = document.createElement('a'); |
| 89 parentUrl.href = document.referrer; | 94 parentUrl.href = document.referrer; |
| 90 if (parentUrl.protocol == 'https:') { | 95 if (parentUrl.protocol == 'https:') { |
| 91 link.ping += ' ' + parentUrl.origin + '/' + ping; | 96 link.ping += ' ' + parentUrl.origin + '/' + ping; |
| 92 } | 97 } |
| 93 } | 98 } |
| 94 } | 99 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 var data = {}; | 160 var data = {}; |
| 156 if (params.url) { | 161 if (params.url) { |
| 157 // Means that the suggestion data comes from the server. Create data object. | 162 // Means that the suggestion data comes from the server. Create data object. |
| 158 data.url = params.url; | 163 data.url = params.url; |
| 159 data.thumbnailUrl = params.tu || ''; | 164 data.thumbnailUrl = params.tu || ''; |
| 160 data.thumbnailUrl2 = params.tu2 || ''; | 165 data.thumbnailUrl2 = params.tu2 || ''; |
| 161 data.title = params.ti || ''; | 166 data.title = params.ti || ''; |
| 162 data.direction = params.di || ''; | 167 data.direction = params.di || ''; |
| 163 data.domain = params.dom || ''; | 168 data.domain = params.dom || ''; |
| 164 data.ping = params.ping || ''; | 169 data.ping = params.ping || ''; |
| 170 data.provider = params.pr || ''; | |
|
beaudoin
2013/12/12 19:37:21
I suggest:
params.pr || SERVER;
With SERVER bein
Mathieu
2013/12/12 21:39:13
Done.
| |
| 165 // Log the fact that suggestion was obtained from the server. | 171 // Log the fact that suggestion was obtained from the server. |
| 166 var ntpApiHandle = chrome.embeddedSearch.newTabPage; | 172 var ntpApiHandle = chrome.embeddedSearch.newTabPage; |
| 167 ntpApiHandle.logEvent(NTP_LOGGING_EVENT_TYPE.NTP_SERVER_SIDE_SUGGESTION); | 173 ntpApiHandle.logEvent(NTP_LOGGING_EVENT_TYPE.NTP_SERVER_SIDE_SUGGESTION); |
| 168 } else { | 174 } else { |
| 169 var apiHandle = chrome.embeddedSearch.searchBox; | 175 var apiHandle = chrome.embeddedSearch.searchBox; |
| 170 data = apiHandle.getMostVisitedItemData(params.rid); | 176 data = apiHandle.getMostVisitedItemData(params.rid); |
| 171 if (!data) | 177 if (!data) |
| 172 return; | 178 return; |
|
beaudoin
2013/12/12 19:37:21
I suggest adding:
data.provider = CLIENT
(see abov
Mathieu
2013/12/12 21:39:13
Done.
| |
| 173 delete data.ping; | 179 delete data.ping; |
| 174 } | 180 } |
| 175 if (/^javascript:/i.test(data.url) || | 181 if (/^javascript:/i.test(data.url) || |
| 176 /^javascript:/i.test(data.thumbnailUrl) || | 182 /^javascript:/i.test(data.thumbnailUrl) || |
| 177 /^javascript:/i.test(data.thumbnailUrl2)) | 183 /^javascript:/i.test(data.thumbnailUrl2) || |
| 184 (data.provider && !/^[a-z0-9]{0,8}$/i.test(data.provider))) | |
| 178 return; | 185 return; |
| 179 if (data.direction) | 186 if (data.direction) |
| 180 document.body.dir = data.direction; | 187 document.body.dir = data.direction; |
| 181 fill(params, data); | 188 fill(params, data); |
| 182 } | 189 } |
| OLD | NEW |