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

Side by Side Diff: chrome/browser/resources/enhanced_bookmarks/get_salient_image_url.js

Issue 958383003: Output closure-compiled JavaScript files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Little bit of clean up Created 5 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 * Looks on the page to find the image that could be the most representative 6 * Looks on the page to find the image that could be the most representative
7 * one. 7 * one.
8 */ 8 */
9 (function() { 9 (function() {
10 // Extract the referrer policy from the page. 10 // Extract the referrer policy from the page.
11 var referrerPolicy = 'default'; 11 var referrerPolicy = 'default';
12 var metaTags = document.getElementsByTagName('meta'); 12 var metaTags = document.getElementsByTagName('meta');
13 for (var i = 0; i < metaTags.length; ++i) { 13 for (var i = 0; i < metaTags.length; ++i) {
14 if (metaTags[i].name.toLowerCase() == 'referrer') { 14 if (metaTags[i].name.toLowerCase() == 'referrer') {
15 referrerPolicy = metaTags[i].content.toLowerCase(); 15 referrerPolicy = metaTags[i].content.toLowerCase();
16 break; 16 break;
17 } 17 }
18 } 18 }
19 19
20 // See what to use for JSON. Some pages use a library that overrides JSON. 20 // See what to use for JSON. Some pages use a library that overrides JSON.
21 var jsonEncoder = JSON.stringify; 21 var jsonEncoder = JSON['stringify'];
Dan Beam 2015/03/06 02:57:28 is JSON.{encode,stringify} not in the externs? wh
22 if (!jsonEncoder) 22 if (!jsonEncoder)
23 jsonEncoder = JSON.encode; 23 jsonEncoder = JSON['encode'];
24 24
25 // First look if there is an Open Graph Image property available. 25 // First look if there is an Open Graph Image property available.
26 var ogImage = document.querySelector('meta[property=\"og:image\"]'); 26 var ogImage = document.querySelector('meta[property=\"og:image\"]');
27 if (ogImage) { 27 if (ogImage) {
28 // Checks that the url in ogImage has a path that contains more than just a 28 // Checks that the url in ogImage has a path that contains more than just a
29 // simple '/'. 29 // simple '/'.
30 var url = ogImage.content; 30 var url = ogImage.content;
31 var location = document.createElement('a'); 31 var location = document.createElement('a');
32 location.href = url; 32 location.href = url;
33 if (location.pathname.length > 1) { 33 if (location.pathname.length > 1) {
(...skipping 24 matching lines...) Expand all
58 58
59 // Only keep images larger than 320*160. 59 // Only keep images larger than 320*160.
60 if (maxPointSize <= 51200.0 || maxImage === null) 60 if (maxPointSize <= 51200.0 || maxImage === null)
61 return ''; 61 return '';
62 62
63 return jsonEncoder({ 63 return jsonEncoder({
64 'imageUrl': maxImage.src, 64 'imageUrl': maxImage.src,
65 'referrerPolicy': referrerPolicy 65 'referrerPolicy': referrerPolicy
66 }); 66 });
67 })(); 67 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698