| OLD | NEW |
| 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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 | 492 |
| 493 function onDone() { | 493 function onDone() { |
| 494 if (self.mountPoints_ && self.rootEntries_) | 494 if (self.mountPoints_ && self.rootEntries_) |
| 495 self.init_(); | 495 self.init_(); |
| 496 } | 496 } |
| 497 | 497 |
| 498 chrome.fileBrowserPrivate.requestLocalFileSystem(function(filesystem) { | 498 chrome.fileBrowserPrivate.requestLocalFileSystem(function(filesystem) { |
| 499 self.filesystem_ = filesystem; | 499 self.filesystem_ = filesystem; |
| 500 util.installFileErrorToString(); | 500 util.installFileErrorToString(); |
| 501 | 501 |
| 502 metrics.recordTime('Load.FileSystem'); | 502 metrics.recordInterval('Load.FileSystem'); |
| 503 | 503 |
| 504 var rootEntries = []; | 504 var rootEntries = []; |
| 505 | 505 |
| 506 function onAllRootsFound() { | 506 function onAllRootsFound() { |
| 507 metrics.recordTime('Load.Roots'); | 507 metrics.recordInterval('Load.Roots'); |
| 508 self.rootEntries_ = rootEntries; | 508 self.rootEntries_ = rootEntries; |
| 509 onDone(); | 509 onDone(); |
| 510 } | 510 } |
| 511 | 511 |
| 512 function onPathError(path, err) { | 512 function onPathError(path, err) { |
| 513 console.error('Error locating root path: ' + path + ': ' + err); | 513 console.error('Error locating root path: ' + path + ': ' + err); |
| 514 } | 514 } |
| 515 | 515 |
| 516 function onEntryFound(entry) { | 516 function onEntryFound(entry) { |
| 517 if (entry) { | 517 if (entry) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 | 611 |
| 612 this.setupCurrentDirectory_(); | 612 this.setupCurrentDirectory_(); |
| 613 | 613 |
| 614 this.summarizeSelection_(); | 614 this.summarizeSelection_(); |
| 615 | 615 |
| 616 this.dataModel_.sort('cachedMtime_', 'desc'); | 616 this.dataModel_.sort('cachedMtime_', 'desc'); |
| 617 | 617 |
| 618 this.refocus(); | 618 this.refocus(); |
| 619 | 619 |
| 620 this.createMetadataProvider_(); | 620 this.createMetadataProvider_(); |
| 621 metrics.recordTime('Load.DOM'); | 621 metrics.recordInterval('Load.DOM'); |
| 622 metrics.recordTime('Load.Total'); | 622 metrics.recordInterval('Load.Total'); |
| 623 }; | 623 }; |
| 624 | 624 |
| 625 /** | 625 /** |
| 626 * One-time initialization of commands. | 626 * One-time initialization of commands. |
| 627 */ | 627 */ |
| 628 FileManager.prototype.initCommands_ = function() { | 628 FileManager.prototype.initCommands_ = function() { |
| 629 var commands = this.dialogDom_.querySelectorAll('command'); | 629 var commands = this.dialogDom_.querySelectorAll('command'); |
| 630 for (var i = 0; i < commands.length; i++) { | 630 for (var i = 0; i < commands.length; i++) { |
| 631 var command = commands[i]; | 631 var command = commands[i]; |
| 632 cr.ui.Command.decorate(command); | 632 cr.ui.Command.decorate(command); |
| (...skipping 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2361 urls.push(entry.toURL()); | 2361 urls.push(entry.toURL()); |
| 2362 } | 2362 } |
| 2363 } | 2363 } |
| 2364 } else { | 2364 } else { |
| 2365 // Multiple selection. Pass just those items, select the first entry. | 2365 // Multiple selection. Pass just those items, select the first entry. |
| 2366 selectedUrl = urls[0]; | 2366 selectedUrl = urls[0]; |
| 2367 } | 2367 } |
| 2368 | 2368 |
| 2369 galleryFrame.onload = function() { | 2369 galleryFrame.onload = function() { |
| 2370 self.document_.title = str('GALLERY'); | 2370 self.document_.title = str('GALLERY'); |
| 2371 galleryFrame.contentWindow.ImageUtil.metrics = metrics; |
| 2371 galleryFrame.contentWindow.Gallery.open( | 2372 galleryFrame.contentWindow.Gallery.open( |
| 2372 self.currentDirEntry_, | 2373 self.currentDirEntry_, |
| 2373 urls, | 2374 urls, |
| 2374 selectedUrl, | 2375 selectedUrl, |
| 2375 function () { | 2376 function () { |
| 2376 // TODO(kaznacheev): keep selection. | 2377 // TODO(kaznacheev): keep selection. |
| 2377 self.dialogDom_.removeChild(galleryFrame); | 2378 self.dialogDom_.removeChild(galleryFrame); |
| 2378 self.document_.title = self.currentDirEntry_.fullPath; | 2379 self.document_.title = self.currentDirEntry_.fullPath; |
| 2379 self.refocus(); | 2380 self.refocus(); |
| 2380 }, | 2381 }, |
| (...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3182 callbacks[i].onError(); | 3183 callbacks[i].onError(); |
| 3183 } catch (ex) { | 3184 } catch (ex) { |
| 3184 console.error('Caught exception while notifying about error: ' + | 3185 console.error('Caught exception while notifying about error: ' + |
| 3185 name, ex); | 3186 name, ex); |
| 3186 } | 3187 } |
| 3187 } | 3188 } |
| 3188 } | 3189 } |
| 3189 | 3190 |
| 3190 function onReadSome(entries) { | 3191 function onReadSome(entries) { |
| 3191 if (entries.length == 0) { | 3192 if (entries.length == 0) { |
| 3192 metrics.recordTime('DirectoryScan'); | 3193 metrics.recordInterval('DirectoryScan'); |
| 3193 if (self.currentDirEntry_.fullPath == DOWNLOADS_DIRECTORY) { | 3194 if (self.currentDirEntry_.fullPath == DOWNLOADS_DIRECTORY) { |
| 3194 metrics.reportCount("DownloadsCount", self.dataModel_.length); | 3195 metrics.recordMediumCount("DownloadsCount", self.dataModel_.length); |
| 3195 } | 3196 } |
| 3196 | 3197 |
| 3197 if (self.pendingRescanQueue_.length > 0) { | 3198 if (self.pendingRescanQueue_.length > 0) { |
| 3198 setTimeout(self.rescanDirectory_.bind(self), | 3199 setTimeout(self.rescanDirectory_.bind(self), |
| 3199 SIMULTANEOUS_RESCAN_INTERVAL); | 3200 SIMULTANEOUS_RESCAN_INTERVAL); |
| 3200 } | 3201 } |
| 3201 | 3202 |
| 3202 self.rescanRunning_ = false; | 3203 self.rescanRunning_ = false; |
| 3203 for (var i= 0; i < callbacks.length; i++) { | 3204 for (var i= 0; i < callbacks.length; i++) { |
| 3204 if (callbacks[i].onSuccess) | 3205 if (callbacks[i].onSuccess) |
| (...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3982 }); | 3983 }); |
| 3983 }, onError); | 3984 }, onError); |
| 3984 | 3985 |
| 3985 function onError(err) { | 3986 function onError(err) { |
| 3986 console.log('Error while checking free space: ' + err); | 3987 console.log('Error while checking free space: ' + err); |
| 3987 setTimeout(doCheck, 1000 * 60); | 3988 setTimeout(doCheck, 1000 * 60); |
| 3988 } | 3989 } |
| 3989 } | 3990 } |
| 3990 } | 3991 } |
| 3991 })(); | 3992 })(); |
| OLD | NEW |