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

Side by Side Diff: chrome/renderer/resources/extensions/image_util.js

Issue 17451011: Make the externally connectable browser test clobber all of the builtins, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // This function takes an object |imageSpec| with the key |path| - 5 // This function takes an object |imageSpec| with the key |path| -
6 // corresponding to the internet URL to be translated - and optionally 6 // corresponding to the internet URL to be translated - and optionally
7 // |width| and |height| which are the maximum dimensions to be used when 7 // |width| and |height| which are the maximum dimensions to be used when
8 // converting the image. 8 // converting the image.
9 function loadImageData(imageSpec, callbacks) { 9 function loadImageData(imageSpec, callbacks) {
10 var path = imageSpec.path; 10 var path = imageSpec.path;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 53 }
54 img.src = path; 54 img.src = path;
55 } 55 }
56 56
57 function on_complete_index(index, err, loading, finished, callbacks) { 57 function on_complete_index(index, err, loading, finished, callbacks) {
58 return function(width, height, imageData) { 58 return function(width, height, imageData) {
59 delete loading[index]; 59 delete loading[index];
60 finished[index] = { width: width, height: height, data: imageData }; 60 finished[index] = { width: width, height: height, data: imageData };
61 if (err) 61 if (err)
62 callbacks.onerror(index); 62 callbacks.onerror(index);
63 if (Object.keys(loading).length == 0) 63 if ($Object.keys(loading).length == 0)
64 callbacks.oncomplete(finished); 64 callbacks.oncomplete(finished);
65 } 65 }
66 } 66 }
67 67
68 function loadAllImages(imageSpecs, callbacks) { 68 function loadAllImages(imageSpecs, callbacks) {
69 var loading = {}, finished = [], 69 var loading = {}, finished = [],
70 index, pathname; 70 index, pathname;
71 71
72 for (var index = 0; index < imageSpecs.length; index++) { 72 for (var index = 0; index < imageSpecs.length; index++) {
73 loading[index] = imageSpecs[index]; 73 loading[index] = imageSpecs[index];
74 loadImageData(imageSpecs[index], { 74 loadImageData(imageSpecs[index], {
75 oncomplete: on_complete_index(index, false, loading, finished, callbacks), 75 oncomplete: on_complete_index(index, false, loading, finished, callbacks),
76 onerror: on_complete_index(index, true, loading, finished, callbacks) 76 onerror: on_complete_index(index, true, loading, finished, callbacks)
77 }); 77 });
78 } 78 }
79 } 79 }
80 80
81 exports.loadImageData = loadImageData; 81 exports.loadImageData = loadImageData;
82 exports.loadAllImages = loadAllImages; 82 exports.loadAllImages = loadAllImages;
OLDNEW
« no previous file with comments | « chrome/renderer/resources/extensions/i18n_custom_bindings.js ('k') | chrome/renderer/resources/extensions/json_schema.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698