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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 | 100 |
101 | 101 |
102 /** | 102 /** |
103 * @param {string} location A location containing URL parameters. | 103 * @param {string} location A location containing URL parameters. |
104 * @param {function(Object, Object)} fill A function called with styles and | 104 * @param {function(Object, Object)} fill A function called with styles and |
105 * data to fill. | 105 * data to fill. |
106 */ | 106 */ |
107 function fillMostVisited(location, fill) { | 107 function fillMostVisited(location, fill) { |
108 var params = parseQueryParams(document.location); | 108 var params = parseQueryParams(document.location); |
109 params.rid = parseInt(params.rid, 10); | 109 params.rid = parseInt(params.rid, 10); |
110 if (!isFinite(params.rid)) | 110 if (!isFinite(params.rid) && !params.url) |
111 return; | 111 return; |
112 var apiHandle = chrome.embeddedSearch.searchBox; | 112 var data = {}; |
113 var data = apiHandle.getMostVisitedItemData(params.rid); | 113 if (params.url) { |
114 if (!data) | 114 // Means that we get suggestion data from the server. Create data object. |
samarth
2013/07/19 22:16:40
These fields are currently set by C++ code in chro
Mathieu
2013/07/22 17:32:50
The downstream code will create title and thumbnai
| |
115 return; | 115 data.url = params.url; |
116 data.thumbnailUrl = params.tu || ''; | |
117 data.title = params.ti || ''; | |
118 data.direction = params.di || ''; | |
119 } else { | |
120 var apiHandle = chrome.embeddedSearch.searchBox; | |
121 data = apiHandle.getMostVisitedItemData(params.rid); | |
122 if (!data) | |
123 return; | |
124 } | |
116 if (/^javascript:/i.test(data.url)) | 125 if (/^javascript:/i.test(data.url)) |
117 return; | 126 return; |
118 if (data.direction) | 127 if (data.direction) |
119 document.body.dir = data.direction; | 128 document.body.dir = data.direction; |
120 fill(params, data); | 129 fill(params, data); |
121 } | 130 } |
OLD | NEW |