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

Unified Diff: extensions/renderer/resources/set_icon.js

Issue 477193003: Refactor setIcon to allow for more general use of imageData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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: extensions/renderer/resources/set_icon.js
diff --git a/extensions/renderer/resources/set_icon.js b/extensions/renderer/resources/set_icon.js
index 883fd673997f849eaef0dc3514f6291131dadfb6..0df1c6939643728fced9ed1bd22634c1f5bc2921 100644
--- a/extensions/renderer/resources/set_icon.js
+++ b/extensions/renderer/resources/set_icon.js
@@ -49,10 +49,10 @@ function verifyImageData(imageData, iconSize) {
}
}
-function setIcon(details, callback, name, parameters, actionType) {
+function setIcon(details, actionType, callback) {
not at google - send to devlin 2014/08/19 00:04:43 It looks like the only reason we need to thread th
gpdavis 2014/08/19 00:54:15 Done.
var iconSizes = [19, 38];
if ('iconIndex' in details) {
- sendRequest(name, [details, callback], parameters);
+ callback(details);
not at google - send to devlin 2014/08/19 00:04:43 This code is such a nightmare. Sheesh. Such a nest
gpdavis 2014/08/19 00:54:15 Done.
} else if ('imageData' in details) {
if (typeof details.imageData == 'object') {
not at google - send to devlin 2014/08/19 00:04:43 Checks like these are so unnecessary, it's exactly
gpdavis 2014/08/19 00:54:15 Done.
var isEmpty = true;
@@ -65,8 +65,7 @@ function setIcon(details, callback, name, parameters, actionType) {
}
if (!isEmpty) {
- sendRequest(name, [details, callback], parameters,
- {nativeFunction: SetIconCommon});
+ callback(SetIconCommon(details));
} else {
// If details.imageData is not dictionary with keys in set {'19', '38'},
// it must be an ImageData object.
@@ -75,8 +74,7 @@ function setIcon(details, callback, name, parameters, actionType) {
details.imageData = {};
details.imageData[sizeKey] = imageData;
verifyImageData(details.imageData[sizeKey], iconSizes[0]);
- sendRequest(name, [details, callback], parameters,
- {nativeFunction: SetIconCommon});
+ callback(SetIconCommon(details));
}
} else {
throw new Error('imageData property has unexpected type.');
@@ -90,9 +88,7 @@ function setIcon(details, callback, name, parameters, actionType) {
delete details.path;
if (isEmpty)
throw new Error('The path property must not be empty.');
- sendRequest(name, [details, callback], parameters,
- {nativeFunction: SetIconCommon});
- return;
+ callback(SetIconCommon(details));
}
var sizeKey = iconSizes[index].toString();
if (!(sizeKey in details.path)) {
@@ -115,8 +111,7 @@ function setIcon(details, callback, name, parameters, actionType) {
function(imageData) {
details.imageData[sizeKey] = imageData;
delete details.path;
- sendRequest(name, [details, callback], parameters,
- {nativeFunction: SetIconCommon});
+ callback(SetIconCommon(details));
});
} else {
throw new Error('The path property should contain either string or ' +

Powered by Google App Engine
This is Rietveld 408576698