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

Unified Diff: components/resources/enhanced_bookmarks/get_salient_image_url.js

Issue 1202713002: Replace enhanced bookmarks salient images with favicons (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Line wraps in EnhanacedBookmarkItem.java Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: components/resources/enhanced_bookmarks/get_salient_image_url.js
diff --git a/components/resources/enhanced_bookmarks/get_salient_image_url.js b/components/resources/enhanced_bookmarks/get_salient_image_url.js
deleted file mode 100644
index c7a32b6f43136abcd9c3ceebf9928cae437b9db2..0000000000000000000000000000000000000000
--- a/components/resources/enhanced_bookmarks/get_salient_image_url.js
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-goog.require('image.collections.extension.domextractor.DocumentImageExtractor');
-
-/*
- * Examines the DOM to find the image that is the most representative of the
- * webpage.
- */
-var GetSalientImageUrl = function() {
- // Extract the referrer policy from the page.
- var referrerPolicy = 'default';
- var metaTags = document.getElementsByTagName('meta');
- for (var i = 0; i < metaTags.length; i++) {
- if (metaTags[i].name.toLowerCase() == 'referrer') {
- referrerPolicy = metaTags[i].content.toLowerCase();
- break;
- }
- }
-
- // Determine which JSON method (stringify or encode) to use for encoding.
- // Some pages use a library that overrides JSON, so JSON['stringify'] is not
- // always available.
- var jsonEncoder = JSON['stringify'];
- if (!jsonEncoder)
- jsonEncoder = JSON['encode'];
-
- var context = new
- image.collections.extension.domextractor.DocumentImageExtractor.Context();
- var documentImageExtractor =
- new image.collections.extension.domextractor.DocumentImageExtractor();
- var images = documentImageExtractor.extractFromNodeList(
- document.querySelectorAll('img,link,meta'), context);
-
- var maxImage = null;
- var maxRelevance = 0;
- for (var i = 0; i < images.length; i++) {
- var currentImage = images[i];
- var imageSize = currentImage.getSize();
- if (!imageSize)
- continue;
-
- if (currentImage.getRelevance() > maxRelevance) {
- maxImage = currentImage;
- maxRelevance = currentImage.getRelevance();
- }
- }
-
- if (maxImage === null)
- return '';
-
- var result = jsonEncoder({
- 'imageUrl': maxImage.getUrl(),
- 'referrerPolicy': referrerPolicy
- });
-
- return result;
-};
« no previous file with comments | « components/resources/enhanced_bookmarks/enhanced_bookmarks_resources.gyp ('k') | tools/gritsettings/resource_ids » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698