Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Grab the querystring, removing question mark at the front and splitting on | 5 // Grab the querystring, removing question mark at the front and splitting on |
| 6 // the ampersand. | 6 // the ampersand. |
| 7 var queryString = location.search.substring(1).split("&"); | 7 var queryString = location.search.substring(1).split("&"); |
| 8 | 8 |
| 9 // The feed URL is the first component and always present. | 9 // The feed URL is the first component and always present. |
| 10 var feedUrl = decodeURIComponent(queryString[0]); | 10 var feedUrl = decodeURIComponent(queryString[0]); |
|
Finnur
2011/01/20 14:56:46
We already decode the feedUrl here, which is why w
| |
| 11 | 11 |
| 12 // We allow synchronous requests for testing. This component is only present | 12 // We allow synchronous requests for testing. This component is only present |
| 13 // if true. | 13 // if true. |
| 14 var synchronousRequest = queryString[1] == "synchronous"; | 14 var synchronousRequest = queryString[1] == "synchronous"; |
| 15 | 15 |
| 16 // The XMLHttpRequest object that tries to load and parse the feed, and (if | 16 // The XMLHttpRequest object that tries to load and parse the feed, and (if |
| 17 // testing) also the style sheet and the frame js. | 17 // testing) also the style sheet and the frame js. |
| 18 var req; | 18 var req; |
| 19 | 19 |
| 20 // Depending on whether this is run from a test or from the extension, this | 20 // Depending on whether this is run from a test or from the extension, this |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 32 | 32 |
| 33 // A list of feed readers, populated by localStorage if available, otherwise | 33 // A list of feed readers, populated by localStorage if available, otherwise |
| 34 // hard coded. | 34 // hard coded. |
| 35 var feedReaderList; | 35 var feedReaderList; |
| 36 | 36 |
| 37 // Navigates to the reader of the user's choice (for subscribing to the feed). | 37 // Navigates to the reader of the user's choice (for subscribing to the feed). |
| 38 function navigate() { | 38 function navigate() { |
| 39 var select = document.getElementById('readerDropdown'); | 39 var select = document.getElementById('readerDropdown'); |
| 40 var url = | 40 var url = |
| 41 feedReaderList[select.selectedIndex].url.replace( | 41 feedReaderList[select.selectedIndex].url.replace( |
| 42 "%s", escape(encodeURI(feedUrl))); | 42 "%s", escape(feedUrl)); |
|
Aaron Boodman
2011/01/20 17:47:15
escape and encodeURI do subtlety different things.
| |
| 43 | 43 |
| 44 // Before we navigate, see if we want to skip this step in the future... | 44 // Before we navigate, see if we want to skip this step in the future... |
| 45 if (storageEnabled) { | 45 if (storageEnabled) { |
| 46 // See if the user wants to always use this reader. | 46 // See if the user wants to always use this reader. |
| 47 var alwaysUse = document.getElementById('alwaysUse'); | 47 var alwaysUse = document.getElementById('alwaysUse'); |
| 48 if (alwaysUse.checked) { | 48 if (alwaysUse.checked) { |
| 49 window.localStorage.defaultReader = | 49 window.localStorage.defaultReader = |
| 50 feedReaderList[select.selectedIndex].url; | 50 feedReaderList[select.selectedIndex].url; |
| 51 window.localStorage.showPreviewPage = "No"; | 51 window.localStorage.showPreviewPage = "No"; |
| 52 } | 52 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 frameScript = "<script>" + req.responseText + | 98 frameScript = "<script>" + req.responseText + |
| 99 "<" + "/script>"; | 99 "<" + "/script>"; |
| 100 } else { | 100 } else { |
| 101 // Normal loading just requires links to the css and the js file. | 101 // Normal loading just requires links to the css and the js file. |
| 102 styleSheet = "<link rel='stylesheet' type='text/css' href='" + | 102 styleSheet = "<link rel='stylesheet' type='text/css' href='" + |
| 103 chrome.extension.getURL("style.css") + "'>"; | 103 chrome.extension.getURL("style.css") + "'>"; |
| 104 frameScript = "<script src='" + chrome.extension.getURL("iframe.js") + | 104 frameScript = "<script src='" + chrome.extension.getURL("iframe.js") + |
| 105 "'></" + "script>"; | 105 "'></" + "script>"; |
| 106 } | 106 } |
| 107 | 107 |
| 108 feedUrl = decodeURIComponent(feedUrl); | |
| 109 req.onload = handleResponse; | 108 req.onload = handleResponse; |
| 110 req.onerror = handleError; | 109 req.onerror = handleError; |
| 111 // Not everyone sets the mime type correctly, which causes handleResponse | 110 // Not everyone sets the mime type correctly, which causes handleResponse |
| 112 // to fail to XML parse the response text from the server. By forcing | 111 // to fail to XML parse the response text from the server. By forcing |
| 113 // it to text/xml we avoid this. | 112 // it to text/xml we avoid this. |
| 114 req.overrideMimeType('text/xml'); | 113 req.overrideMimeType('text/xml'); |
| 115 req.open("GET", feedUrl, !synchronousRequest); | 114 req.open("GET", feedUrl, !synchronousRequest); |
| 116 req.send(null); | 115 req.send(null); |
| 117 | 116 |
| 118 document.getElementById('feedUrl').href = 'view-source:' + feedUrl; | 117 document.getElementById('feedUrl').href = 'view-source:' + feedUrl; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 function onSelectChanged() { | 215 function onSelectChanged() { |
| 217 if (!storageEnabled) | 216 if (!storageEnabled) |
| 218 return; | 217 return; |
| 219 var readerDropdown = document.getElementById('readerDropdown'); | 218 var readerDropdown = document.getElementById('readerDropdown'); |
| 220 | 219 |
| 221 // If the last item (Manage...) was selected we show the options. | 220 // If the last item (Manage...) was selected we show the options. |
| 222 var oldSelection = readerDropdown.selectedIndex; | 221 var oldSelection = readerDropdown.selectedIndex; |
| 223 if (readerDropdown.selectedIndex == readerDropdown.length - 1) | 222 if (readerDropdown.selectedIndex == readerDropdown.length - 1) |
| 224 window.location = "options.html"; | 223 window.location = "options.html"; |
| 225 } | 224 } |
| OLD | NEW |