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

Unified Diff: chrome/browser/resources/cryptotoken/textfetcher.js

Issue 596083002: Update cryptotoken to 0.8.63 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove a deprecated line Created 6 years, 3 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: chrome/browser/resources/cryptotoken/textfetcher.js
diff --git a/chrome/browser/resources/cryptotoken/textfetcher.js b/chrome/browser/resources/cryptotoken/textfetcher.js
index e63a8413a88edb5eb7689977fe2d8c476d5b68d7..4135b0e12cb81599fbaa254f1ae7d648328784ef 100644
--- a/chrome/browser/resources/cryptotoken/textfetcher.js
+++ b/chrome/browser/resources/cryptotoken/textfetcher.js
@@ -17,10 +17,12 @@ function TextFetcher() {}
/**
* @param {string} url The URL to fetch.
+ * @param {string?} opt_method The HTTP method to use (default GET)
+ * @param {string?} opt_body The request body
* @return {!Promise.<string>} A promise for the fetched text. In case of an
* error, this promise is rejected with an HTTP status code.
*/
-TextFetcher.prototype.fetch = function(url) {};
+TextFetcher.prototype.fetch = function(url, opt_method, opt_body) {};
/**
* @constructor
@@ -31,13 +33,16 @@ function XhrTextFetcher() {
/**
* @param {string} url The URL to fetch.
+ * @param {string?} opt_method The HTTP method to use (default GET)
+ * @param {string?} opt_body The request body
* @return {!Promise.<string>} A promise for the fetched text. In case of an
* error, this promise is rejected with an HTTP status code.
*/
-XhrTextFetcher.prototype.fetch = function(url) {
+XhrTextFetcher.prototype.fetch = function(url, opt_method, opt_body) {
return new Promise(function(resolve, reject) {
var xhr = new XMLHttpRequest();
- xhr.open('GET', url, true);
+ var method = opt_method || 'GET';
+ xhr.open(method, url, true);
xhr.onloadend = function() {
if (xhr.status != 200) {
reject(xhr.status);
@@ -45,6 +50,13 @@ XhrTextFetcher.prototype.fetch = function(url) {
}
resolve(xhr.responseText);
};
- xhr.send();
+ xhr.onerror = function() {
+ // Treat any network-level errors as though the page didn't exist.
+ reject(404);
+ };
+ if (opt_body)
+ xhr.send(opt_body);
+ else
+ xhr.send();
});
};
« no previous file with comments | « chrome/browser/resources/cryptotoken/singlesigner.js ('k') | chrome/browser/resources/cryptotoken/usbenrollhandler.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698