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

Side by Side Diff: chrome/browser/resources/file_manager/js/file_manager.js

Issue 8772041: Remove deprecated TabContentsDelegate::OpenURLFromTab variant (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Setting the src of an img to an empty string can crash the browser, so we 5 // Setting the src of an img to an empty string can crash the browser, so we
6 // use an empty 1x1 gif instead. 6 // use an empty 1x1 gif instead.
7 const EMPTY_IMAGE_URI = 'data:image/gif;base64,' 7 const EMPTY_IMAGE_URI = 'data:image/gif;base64,'
8 + 'R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D'; 8 + 'R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D';
9 9
10 var g_slideshow_data = null; 10 var g_slideshow_data = null;
(...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 this.dialogDom_.querySelector('.dialog-title').textContent = dialogTitle; 1475 this.dialogDom_.querySelector('.dialog-title').textContent = dialogTitle;
1476 }; 1476 };
1477 1477
1478 /** 1478 /**
1479 * Cache necessary data before a sort happens. 1479 * Cache necessary data before a sort happens.
1480 * 1480 *
1481 * This is called by the table code before a sort happens, so that we can 1481 * This is called by the table code before a sort happens, so that we can
1482 * go fetch data for the sort field that we may not have yet. 1482 * go fetch data for the sort field that we may not have yet.
1483 */ 1483 */
1484 FileManager.prototype.prepareSort_ = function(field, callback) { 1484 FileManager.prototype.prepareSort_ = function(field, callback) {
1485 this.prepareSortEntries_(this.dataModel_.slice(), field, callback);
1486 };
1487
1488 FileManager.prototype.prepareSortEntries_ = function(entries, field,
1489 callback) {
1485 var cacheFunction; 1490 var cacheFunction;
1486 1491
1487 if (field == 'name' || field == 'cachedMtime_') { 1492 if (field == 'name' || field == 'cachedMtime_') {
1488 // Mtime is the tie-breaker for a name sort, so we need to resolve 1493 // Mtime is the tie-breaker for a name sort, so we need to resolve
1489 // it for both mtime and name sorts. 1494 // it for both mtime and name sorts.
1490 cacheFunction = cacheEntryDate; 1495 cacheFunction = cacheEntryDate;
1491 } else if (field == 'cachedSize_') { 1496 } else if (field == 'cachedSize_') {
1492 cacheFunction = cacheEntrySize; 1497 cacheFunction = cacheEntrySize;
1493 } else if (field == 'type') { 1498 } else if (field == 'type') {
1494 cacheFunction = this.cacheEntryFileType.bind(this); 1499 cacheFunction = this.cacheEntryFileType.bind(this);
1495 } else if (field == 'cachedIconType_') { 1500 } else if (field == 'cachedIconType_') {
1496 cacheFunction = this.cacheEntryIconType.bind(this); 1501 cacheFunction = this.cacheEntryIconType.bind(this);
1497 } else { 1502 } else {
1498 setTimeout(callback, 0); 1503 setTimeout(callback, 0);
1499 return; 1504 return;
1500 } 1505 }
1501 1506
1502 function checkCount() { 1507 function checkCount() {
1503 if (uncachedCount == 0) { 1508 if (uncachedCount == 0) {
1504 // Callback via a setTimeout so the sync/async semantics don't change 1509 // Callback via a setTimeout so the sync/async semantics don't change
1505 // based on whether or not the value is cached. 1510 // based on whether or not the value is cached.
1506 setTimeout(callback, 0); 1511 setTimeout(callback, 0);
1507 } 1512 }
1508 } 1513 }
1509 1514
1510 var dataModel = this.dataModel_; 1515 var uncachedCount = entries.length;
1511 var uncachedCount = dataModel.length;
1512 1516
1513 for (var i = uncachedCount - 1; i >= 0 ; i--) { 1517 for (var i = uncachedCount - 1; i >= 0 ; i--) {
1514 var entry = dataModel.item(i); 1518 var entry = entries[i];
1515 if (field in entry) { 1519 if (field in entry) {
1516 uncachedCount--; 1520 uncachedCount--;
1517 } else { 1521 } else {
1518 cacheFunction(entry, function() { 1522 cacheFunction(entry, function() {
1519 uncachedCount--; 1523 uncachedCount--;
1520 checkCount(); 1524 checkCount();
1521 }); 1525 });
1522 } 1526 }
1523 } 1527 }
1524 1528
(...skipping 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after
3205 3209
3206 // Hide files that start with a dot ('.'). 3210 // Hide files that start with a dot ('.').
3207 // TODO(rginda): User should be able to override this. Support for other 3211 // TODO(rginda): User should be able to override this. Support for other
3208 // commonly hidden patterns might be nice too. 3212 // commonly hidden patterns might be nice too.
3209 if (self.filterFiles_) { 3213 if (self.filterFiles_) {
3210 spliceArgs = spliceArgs.filter(function(e) { 3214 spliceArgs = spliceArgs.filter(function(e) {
3211 return e.name.substr(0, 1) != '.'; 3215 return e.name.substr(0, 1) != '.';
3212 }); 3216 });
3213 } 3217 }
3214 3218
3215 spliceArgs.unshift(0, 0); // index, deleteCount 3219 self.prefetchCacheForSorting_(spliceArgs, function() {
3216 self.dataModel_.splice.apply(self.dataModel_, spliceArgs); 3220 spliceArgs.unshift(0, 0); // index, deleteCount
3221 self.dataModel_.splice.apply(self.dataModel_, spliceArgs);
3217 3222
3218 // Keep reading until entries.length is 0. 3223 // Keep reading until entries.length is 0.
3219 reader.readEntries(onReadSome, onError); 3224 reader.readEntries(onReadSome, onError);
3225 });
3220 }; 3226 };
3221 3227
3222 metrics.startInterval('DirectoryScan'); 3228 metrics.startInterval('DirectoryScan');
3223 3229
3224 // If not the root directory, just read the contents. 3230 // If not the root directory, just read the contents.
3225 reader = this.currentDirEntry_.createReader(); 3231 reader = this.currentDirEntry_.createReader();
3226 reader.readEntries(onReadSome, onError); 3232 reader.readEntries(onReadSome, onError);
3227 return; 3233 return;
3228 } 3234 }
3229 3235
3230 // Otherwise, use the provided list of root subdirectories, since the 3236 // Otherwise, use the provided list of root subdirectories, since the
3231 // real local filesystem root directory (the one we use outside the 3237 // real local filesystem root directory (the one we use outside the
3232 // harness) can't be enumerated yet. 3238 // harness) can't be enumerated yet.
3233 var spliceArgs = [].slice.call(this.rootEntries_); 3239 var spliceArgs = [].slice.call(this.rootEntries_);
3234 spliceArgs.unshift(0, 0); // index, deleteCount 3240 spliceArgs.unshift(0, 0); // index, deleteCount
3235 this.dataModel_.splice.apply(this.dataModel_, spliceArgs); 3241 this.dataModel_.splice.apply(this.dataModel_, spliceArgs);
3236 3242
3237 if (opt_callback) 3243 if (opt_callback)
3238 opt_callback(); 3244 opt_callback();
3239 }; 3245 };
3240 3246
3247 FileManager.prototype.prefetchCacheForSorting_ = function(entries, callback) {
3248 var field = this.dataModel_.sortStatus.field;
3249 if (field) {
3250 this.prepareSortEntries_(entries, field, callback);
3251 } else {
3252 callback();
3253 return;
3254 }
3255 };
3256
3241 FileManager.prototype.findListItem_ = function(event) { 3257 FileManager.prototype.findListItem_ = function(event) {
3242 var node = event.srcElement; 3258 var node = event.srcElement;
3243 while (node) { 3259 while (node) {
3244 if (node.tagName == 'LI') 3260 if (node.tagName == 'LI')
3245 break; 3261 break;
3246 node = node.parentNode; 3262 node = node.parentNode;
3247 } 3263 }
3248 3264
3249 return node; 3265 return node;
3250 }; 3266 };
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
3956 }); 3972 });
3957 }, onError); 3973 }, onError);
3958 3974
3959 function onError(err) { 3975 function onError(err) {
3960 console.log('Error while checking free space: ' + err); 3976 console.log('Error while checking free space: ' + err);
3961 setTimeout(doCheck, 1000 * 60); 3977 setTimeout(doCheck, 1000 * 60);
3962 } 3978 }
3963 } 3979 }
3964 } 3980 }
3965 })(); 3981 })();
OLDNEW
« no previous file with comments | « chrome/browser/process_singleton_linux.cc ('k') | chrome/browser/resources/file_manager/js/image_editor/image_editor.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698