Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 var chrome; | 5 var chrome; |
| 6 if (!chrome) | 6 if (!chrome) |
| 7 chrome = {}; | 7 chrome = {}; |
| 8 | 8 |
| 9 if (!chrome.embeddedSearch) { | 9 if (!chrome.embeddedSearch) { |
| 10 chrome.embeddedSearch = new function() { | 10 chrome.embeddedSearch = new function() { |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 250 native function GetMostVisitedItems(); | 250 native function GetMostVisitedItems(); |
| 251 native function GetThemeBackgroundInfo(); | 251 native function GetThemeBackgroundInfo(); |
| 252 native function DeleteMostVisitedItem(); | 252 native function DeleteMostVisitedItem(); |
| 253 native function UndoAllMostVisitedDeletions(); | 253 native function UndoAllMostVisitedDeletions(); |
| 254 native function UndoMostVisitedDeletion(); | 254 native function UndoMostVisitedDeletion(); |
| 255 native function NavigateNewTabPage(); | 255 native function NavigateNewTabPage(); |
| 256 | 256 |
| 257 function GetMostVisitedItemsWrapper() { | 257 function GetMostVisitedItemsWrapper() { |
| 258 var mostVisitedItems = GetMostVisitedItems(); | 258 var mostVisitedItems = GetMostVisitedItems(); |
| 259 for (var i = 0, item; item = mostVisitedItems[i]; ++i) { | 259 for (var i = 0, item; item = mostVisitedItems[i]; ++i) { |
| 260 item.faviconUrl = UpdateFaviconUrl(item.faviconUrl); | |
| 260 // These properties are private data and should not be returned to | 261 // These properties are private data and should not be returned to |
| 261 // the page. They are only accessible via getMostVisitedItemData(). | 262 // the page. They are only accessible via getMostVisitedItemData(). |
| 262 item.url = null; | 263 item.url = null; |
| 263 item.title = null; | 264 item.title = null; |
| 264 item.domain = null; | 265 item.domain = null; |
| 265 item.direction = null; | 266 item.direction = null; |
| 266 } | 267 } |
| 267 return mostVisitedItems; | 268 return mostVisitedItems; |
| 268 } | 269 } |
| 269 | 270 |
| 271 function UpdateFaviconUrl(faviconUrl) { | |
|
samarth
2013/06/14 21:54:46
Don't try to parse this URL in javascript. Instea
pedro (no code reviews)
2013/06/18 22:35:13
Done.
| |
| 272 var chromeSearchFaviconHost = "chrome-search://favicon/"; | |
| 273 if (faviconUrl.indexOf(chromeSearchFaviconHost) == 0) { | |
| 274 return chromeSearchFaviconHost + "size/16@" + | |
| 275 window.devicePixelRatio + "x/" + | |
| 276 faviconUrl.replace(chromeSearchFaviconHost, ''); | |
| 277 } | |
| 278 } | |
| 279 | |
| 270 // ======================================================================= | 280 // ======================================================================= |
| 271 // Exported functions | 281 // Exported functions |
| 272 // ======================================================================= | 282 // ======================================================================= |
| 273 this.__defineGetter__('mostVisited', GetMostVisitedItemsWrapper); | 283 this.__defineGetter__('mostVisited', GetMostVisitedItemsWrapper); |
| 274 this.__defineGetter__('themeBackgroundInfo', GetThemeBackgroundInfo); | 284 this.__defineGetter__('themeBackgroundInfo', GetThemeBackgroundInfo); |
| 275 | 285 |
| 276 this.deleteMostVisitedItem = function(restrictedId) { | 286 this.deleteMostVisitedItem = function(restrictedId) { |
| 277 DeleteMostVisitedItem(restrictedId); | 287 DeleteMostVisitedItem(restrictedId); |
| 278 }; | 288 }; |
| 279 this.undoAllMostVisitedDeletions = function() { | 289 this.undoAllMostVisitedDeletions = function() { |
| 280 UndoAllMostVisitedDeletions(); | 290 UndoAllMostVisitedDeletions(); |
| 281 }; | 291 }; |
| 282 this.undoMostVisitedDeletion = function(restrictedId) { | 292 this.undoMostVisitedDeletion = function(restrictedId) { |
| 283 UndoMostVisitedDeletion(restrictedId); | 293 UndoMostVisitedDeletion(restrictedId); |
| 284 }; | 294 }; |
| 285 this.navigateContentWindow = function(destination, disposition) { | 295 this.navigateContentWindow = function(destination, disposition) { |
| 286 NavigateNewTabPage(destination, disposition); | 296 NavigateNewTabPage(destination, disposition); |
| 287 } | 297 } |
| 288 | 298 |
| 289 this.onmostvisitedchange = null; | 299 this.onmostvisitedchange = null; |
| 290 this.onthemechange = null; | 300 this.onthemechange = null; |
| 291 }; | 301 }; |
| 292 | 302 |
| 293 // Export legacy searchbox API. | 303 // Export legacy searchbox API. |
| 294 // TODO: Remove this when Instant Extended is fully launched. | 304 // TODO: Remove this when Instant Extended is fully launched. |
| 295 chrome.searchBox = this.searchBox; | 305 chrome.searchBox = this.searchBox; |
| 296 }; | 306 }; |
| 297 } | 307 } |
| OLD | NEW |