| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * This variable is checked in SelectFileDialogExtensionBrowserTest. | 8 * This variable is checked in SelectFileDialogExtensionBrowserTest. |
| 9 * @type {number} | 9 * @type {number} |
| 10 */ | 10 */ |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 }; | 203 }; |
| 204 | 204 |
| 205 // Public statics. | 205 // Public statics. |
| 206 | 206 |
| 207 FileManager.ListType = { | 207 FileManager.ListType = { |
| 208 DETAIL: 'detail', | 208 DETAIL: 'detail', |
| 209 THUMBNAIL: 'thumb' | 209 THUMBNAIL: 'thumb' |
| 210 }; | 210 }; |
| 211 | 211 |
| 212 FileManager.prototype.initPreferences_ = function(callback) { | 212 FileManager.prototype.initPreferences_ = function(callback) { |
| 213 metrics.startInterval('Load.Preferences'); |
| 213 var group = new AsyncUtil.Group(); | 214 var group = new AsyncUtil.Group(); |
| 214 | 215 |
| 215 // DRIVE preferences should be initialized before creating DirectoryModel | 216 // DRIVE preferences should be initialized before creating DirectoryModel |
| 216 // to rebuild the roots list. | 217 // to rebuild the roots list. |
| 217 group.add(this.getPreferences_.bind(this)); | 218 group.add(this.getPreferences_.bind(this)); |
| 218 | 219 |
| 219 // Get startup preferences. | 220 // Get startup preferences. |
| 220 this.viewOptions_ = {}; | 221 this.viewOptions_ = {}; |
| 221 group.add(function(done) { | 222 group.add(function(done) { |
| 222 this.dialogType = this.params_.type || DialogType.FULL_PAGE; | 223 this.dialogType = this.params_.type || DialogType.FULL_PAGE; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 243 'file-manager-show-checkboxes', function(flag) { | 244 'file-manager-show-checkboxes', function(flag) { |
| 244 this.showCheckboxes_ = flag; | 245 this.showCheckboxes_ = flag; |
| 245 done(); | 246 done(); |
| 246 }.bind(this)); | 247 }.bind(this)); |
| 247 }.bind(this)); | 248 }.bind(this)); |
| 248 | 249 |
| 249 // Removes the user data which is no longer used. | 250 // Removes the user data which is no longer used. |
| 250 // TODO(yoshiki): Remove this in M31 http://crbug.com/268784/ | 251 // TODO(yoshiki): Remove this in M31 http://crbug.com/268784/ |
| 251 chrome.storage.local.remove('folder-shortcuts-list'); | 252 chrome.storage.local.remove('folder-shortcuts-list'); |
| 252 | 253 |
| 253 group.run(callback); | 254 group.run(function() { |
| 255 metrics.recordInterval('Load.Preferences'); |
| 256 callback(); |
| 257 }); |
| 254 }; | 258 }; |
| 255 | 259 |
| 256 /** | 260 /** |
| 257 * Request local file system, resolve roots and init_ after that. | 261 * Request local file system, resolve roots and init_ after that. |
| 258 * Warning, you can't use DOM nor any external scripts here, since it may not | 262 * Warning, you can't use DOM nor any external scripts here, since it may not |
| 259 * be loaded yet. Functions in util.* and metrics.* are available and can | 263 * be loaded yet. Functions in util.* and metrics.* are available and can |
| 260 * be used. | 264 * be used. |
| 261 * | 265 * |
| 262 * @param {function()} callback Completion callback. | 266 * @param {function()} callback Completion callback. |
| 263 * @private | 267 * @private |
| (...skipping 15 matching lines...) Expand all Loading... |
| 279 this.volumeManager_.mountDrive(function() {}, function() {}); | 283 this.volumeManager_.mountDrive(function() {}, function() {}); |
| 280 }; | 284 }; |
| 281 | 285 |
| 282 /** | 286 /** |
| 283 * One time initialization for the file system and related things. | 287 * One time initialization for the file system and related things. |
| 284 * | 288 * |
| 285 * @param {function()} callback Completion callback. | 289 * @param {function()} callback Completion callback. |
| 286 * @private | 290 * @private |
| 287 */ | 291 */ |
| 288 FileManager.prototype.initFileSystemUI_ = function(callback) { | 292 FileManager.prototype.initFileSystemUI_ = function(callback) { |
| 293 metrics.startInterval('Load.FileSystemUI'); |
| 289 this.table_.startBatchUpdates(); | 294 this.table_.startBatchUpdates(); |
| 290 this.grid_.startBatchUpdates(); | 295 this.grid_.startBatchUpdates(); |
| 291 | 296 |
| 292 this.initFileList_(); | 297 this.initFileList_(); |
| 293 this.setupCurrentDirectory_(); | 298 this.setupCurrentDirectory_(); |
| 294 | 299 |
| 295 // PyAuto tests monitor this state by polling this variable | 300 // PyAuto tests monitor this state by polling this variable |
| 296 this.__defineGetter__('workerInitialized_', function() { | 301 this.__defineGetter__('workerInitialized_', function() { |
| 297 return this.metadataCache_.isInitialized(); | 302 return this.metadataCache_.isInitialized(); |
| 298 }.bind(this)); | 303 }.bind(this)); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 this.initContextMenus_(); | 408 this.initContextMenus_(); |
| 404 this.initCommands_(); | 409 this.initCommands_(); |
| 405 | 410 |
| 406 this.updateFileTypeFilter_(); | 411 this.updateFileTypeFilter_(); |
| 407 | 412 |
| 408 this.selectionHandler_.onFileSelectionChanged(); | 413 this.selectionHandler_.onFileSelectionChanged(); |
| 409 | 414 |
| 410 this.table_.endBatchUpdates(); | 415 this.table_.endBatchUpdates(); |
| 411 this.grid_.endBatchUpdates(); | 416 this.grid_.endBatchUpdates(); |
| 412 | 417 |
| 418 metrics.recordInterval('Load.FileSystemUI'); |
| 413 callback(); | 419 callback(); |
| 414 }; | 420 }; |
| 415 | 421 |
| 416 /** | 422 /** |
| 417 * @private | 423 * @private |
| 418 */ | 424 */ |
| 419 FileManager.prototype.initDateTimeFormatters_ = function() { | 425 FileManager.prototype.initDateTimeFormatters_ = function() { |
| 420 var use12hourClock = !this.preferences_['use24hourClock']; | 426 var use12hourClock = !this.preferences_['use24hourClock']; |
| 421 this.table_.setDateTimeFormat(use12hourClock); | 427 this.table_.setDateTimeFormat(use12hourClock); |
| 422 }; | 428 }; |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 }; | 720 }; |
| 715 | 721 |
| 716 /** | 722 /** |
| 717 * Initializes general purpose basic things, which are used by other | 723 * Initializes general purpose basic things, which are used by other |
| 718 * initializing methods. | 724 * initializing methods. |
| 719 * | 725 * |
| 720 * @param {function()} callback Completion callback. | 726 * @param {function()} callback Completion callback. |
| 721 * @private | 727 * @private |
| 722 */ | 728 */ |
| 723 FileManager.prototype.initGeneral_ = function(callback) { | 729 FileManager.prototype.initGeneral_ = function(callback) { |
| 730 metrics.startInterval('Load.General'); |
| 724 if (window.appState) { | 731 if (window.appState) { |
| 725 this.params_ = window.appState.params || {}; | 732 this.params_ = window.appState.params || {}; |
| 726 this.defaultPath = window.appState.defaultPath; | 733 this.defaultPath = window.appState.defaultPath; |
| 727 } else { | 734 } else { |
| 728 this.params_ = location.search ? | 735 this.params_ = location.search ? |
| 729 JSON.parse(decodeURIComponent(location.search.substr(1))) : | 736 JSON.parse(decodeURIComponent(location.search.substr(1))) : |
| 730 {}; | 737 {}; |
| 731 this.defaultPath = this.params_.defaultPath; | 738 this.defaultPath = this.params_.defaultPath; |
| 732 } | 739 } |
| 740 metrics.recordInterval('Load.General'); |
| 733 callback(); | 741 callback(); |
| 734 }; | 742 }; |
| 735 | 743 |
| 736 /** | 744 /** |
| 737 * One time initialization of strings (mostly i18n). | 745 * One time initialization of strings (mostly i18n). |
| 738 * | 746 * |
| 739 * @param {function()} callback Completion callback. | 747 * @param {function()} callback Completion callback. |
| 740 * @private | 748 * @private |
| 741 */ | 749 */ |
| 742 FileManager.prototype.initStrings_ = function(callback) { | 750 FileManager.prototype.initStrings_ = function(callback) { |
| 751 metrics.startInterval('Load.Strings'); |
| 743 // Fetch the strings via the private api if running in the browser window. | 752 // Fetch the strings via the private api if running in the browser window. |
| 744 // Otherwise, read cached strings from the local storage. | 753 // Otherwise, read cached strings from the local storage. |
| 745 if (util.platform.runningInBrowser()) { | 754 if (util.platform.runningInBrowser()) { |
| 746 chrome.fileBrowserPrivate.getStrings(function(strings) { | 755 chrome.fileBrowserPrivate.getStrings(function(strings) { |
| 747 loadTimeData.data = strings; | 756 loadTimeData.data = strings; |
| 757 metrics.recordInterval('Load.Strings'); |
| 748 callback(); | 758 callback(); |
| 749 }); | 759 }); |
| 750 } else { | 760 } else { |
| 751 chrome.storage.local.get('strings', function(items) { | 761 chrome.storage.local.get('strings', function(items) { |
| 752 loadTimeData.data = items['strings']; | 762 loadTimeData.data = items['strings']; |
| 763 metrics.recordInterval('Load.Strings'); |
| 753 callback(); | 764 callback(); |
| 754 }); | 765 }); |
| 755 } | 766 } |
| 756 }; | 767 }; |
| 757 | 768 |
| 758 /** | 769 /** |
| 759 * Initializes the VolumeManager instance. | 770 * Initializes the VolumeManager instance. |
| 760 * @param {function()} callback Completion callback. | 771 * @param {function()} callback Completion callback. |
| 761 * @private | 772 * @private |
| 762 */ | 773 */ |
| 763 FileManager.prototype.initVolumeManager_ = function(callback) { | 774 FileManager.prototype.initVolumeManager_ = function(callback) { |
| 764 VolumeManager.getInstance(function(volumeManager) { | 775 VolumeManager.getInstance(function(volumeManager) { |
| 765 this.volumeManager_ = volumeManager; | 776 this.volumeManager_ = volumeManager; |
| 766 callback(); | 777 callback(); |
| 767 }.bind(this)); | 778 }.bind(this)); |
| 768 }; | 779 }; |
| 769 | 780 |
| 770 /** | 781 /** |
| 771 * One time initialization of the Files.app's essential UI elements. These | 782 * One time initialization of the Files.app's essential UI elements. These |
| 772 * elements will be shown to the user. Only visible elements should be | 783 * elements will be shown to the user. Only visible elements should be |
| 773 * initialized here. Any heavy operation should be avoided. Files.app's | 784 * initialized here. Any heavy operation should be avoided. Files.app's |
| 774 * window is shown at the end of this routine. | 785 * window is shown at the end of this routine. |
| 775 * | 786 * |
| 776 * @param {function()} callback Completion callback. | 787 * @param {function()} callback Completion callback. |
| 777 * @private | 788 * @private |
| 778 */ | 789 */ |
| 779 FileManager.prototype.initEssentialUI_ = function(callback) { | 790 FileManager.prototype.initEssentialUI_ = function(callback) { |
| 791 metrics.startInterval('Load.EssentialUI'); |
| 780 this.listType_ = null; | 792 this.listType_ = null; |
| 781 | 793 |
| 782 this.filesystemObserverId_ = null; | 794 this.filesystemObserverId_ = null; |
| 783 this.driveObserverId_ = null; | 795 this.driveObserverId_ = null; |
| 784 | 796 |
| 785 this.document_ = this.dialogDom_.ownerDocument; | 797 this.document_ = this.dialogDom_.ownerDocument; |
| 786 this.dialogType = this.params_.type || DialogType.FULL_PAGE; | 798 this.dialogType = this.params_.type || DialogType.FULL_PAGE; |
| 787 this.startupPrefName_ = 'file-manager-' + this.dialogType; | 799 this.startupPrefName_ = 'file-manager-' + this.dialogType; |
| 788 | 800 |
| 789 // Used to filter out focusing by mouse. | 801 // Used to filter out focusing by mouse. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 819 | 831 |
| 820 // Pre-populate the static localized strings. | 832 // Pre-populate the static localized strings. |
| 821 i18nTemplate.process(this.document_, loadTimeData); | 833 i18nTemplate.process(this.document_, loadTimeData); |
| 822 | 834 |
| 823 // Initialize the header. | 835 // Initialize the header. |
| 824 this.dialogDom_.querySelector('#app-name').innerText = | 836 this.dialogDom_.querySelector('#app-name').innerText = |
| 825 chrome.runtime.getManifest().name; | 837 chrome.runtime.getManifest().name; |
| 826 | 838 |
| 827 this.initDialogType_(); | 839 this.initDialogType_(); |
| 828 | 840 |
| 841 metrics.recordInterval('Load.Display'); |
| 842 metrics.recordInterval('Load.EssentialUI'); |
| 843 |
| 829 // Show the window as soon as the UI pre-initialization is done. | 844 // Show the window as soon as the UI pre-initialization is done. |
| 830 if (this.dialogType == DialogType.FULL_PAGE && | 845 if (this.dialogType == DialogType.FULL_PAGE && |
| 831 !util.platform.runningInBrowser()) { | 846 !util.platform.runningInBrowser()) { |
| 832 chrome.app.window.current().show(); | 847 chrome.app.window.current().show(); |
| 833 setTimeout(callback, 100); // Wait until the animation is finished. | 848 setTimeout(callback, 100); // Wait until the animation is finished. |
| 834 } else { | 849 } else { |
| 835 callback(); | 850 callback(); |
| 836 } | 851 } |
| 837 }; | 852 }; |
| 838 | 853 |
| 839 /** | 854 /** |
| 840 * One-time initialization of dialogs. | 855 * One-time initialization of dialogs. |
| 841 * @private | 856 * @private |
| 842 */ | 857 */ |
| 843 FileManager.prototype.initDialogs_ = function() { | 858 FileManager.prototype.initDialogs_ = function() { |
| 844 var d = cr.ui.dialogs; | 859 var d = cr.ui.dialogs; |
| 845 d.BaseDialog.OK_LABEL = str('OK_LABEL'); | 860 d.BaseDialog.OK_LABEL = str('OK_LABEL'); |
| 846 d.BaseDialog.CANCEL_LABEL = str('CANCEL_LABEL'); | 861 d.BaseDialog.CANCEL_LABEL = str('CANCEL_LABEL'); |
| 847 this.error = new ErrorDialog(this.dialogDom_); | 862 this.error = new ErrorDialog(this.dialogDom_); |
| 848 this.alert = new d.AlertDialog(this.dialogDom_); | 863 this.alert = new d.AlertDialog(this.dialogDom_); |
| 849 this.confirm = new d.ConfirmDialog(this.dialogDom_); | 864 this.confirm = new d.ConfirmDialog(this.dialogDom_); |
| 850 this.prompt = new d.PromptDialog(this.dialogDom_); | 865 this.prompt = new d.PromptDialog(this.dialogDom_); |
| 851 this.shareDialog_ = new ShareDialog(this.dialogDom_); | 866 this.shareDialog_ = new ShareDialog(this.dialogDom_); |
| 852 this.defaultTaskPicker = | 867 this.defaultTaskPicker = |
| 853 new cr.filebrowser.DefaultActionDialog(this.dialogDom_); | 868 new cr.filebrowser.DefaultActionDialog(this.dialogDom_); |
| 854 }; | 869 }; |
| 855 | 870 |
| 856 /** | 871 /** |
| 857 * One-time initialization of various DOM nodes. Loads the additional DOM | 872 * One-time initialization of various DOM nodes. Loads the additional DOM |
| 858 * elements visible to the user. Initialize here elements, which are expensive | 873 * elements visible to the user. Initialize here elements, which are expensive |
| 859 * or hidden in the beginning. | 874 * or hidden in the beginning. |
| 860 * | 875 * |
| 861 * @param {function()} callback Completion callback. | 876 * @param {function()} callback Completion callback. |
| 862 * @private | 877 * @private |
| 863 */ | 878 */ |
| 864 FileManager.prototype.initAdditionalUI_ = function(callback) { | 879 FileManager.prototype.initAdditionalUI_ = function(callback) { |
| 880 metrics.startInterval('Load.AdditionalUI'); |
| 865 this.initDialogs_(); | 881 this.initDialogs_(); |
| 866 | 882 |
| 867 this.dialogDom_.addEventListener('drop', function(e) { | 883 this.dialogDom_.addEventListener('drop', function(e) { |
| 868 // Prevent opening an URL by dropping it onto the page. | 884 // Prevent opening an URL by dropping it onto the page. |
| 869 e.preventDefault(); | 885 e.preventDefault(); |
| 870 }); | 886 }); |
| 871 | 887 |
| 872 this.dialogDom_.addEventListener('click', | 888 this.dialogDom_.addEventListener('click', |
| 873 this.onExternalLinkClick_.bind(this)); | 889 this.onExternalLinkClick_.bind(this)); |
| 874 // Cache nodes we'll be manipulating. | 890 // Cache nodes we'll be manipulating. |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 | 1067 |
| 1052 util.addIsFocusedMethod(); | 1068 util.addIsFocusedMethod(); |
| 1053 | 1069 |
| 1054 // Populate the static localized strings. | 1070 // Populate the static localized strings. |
| 1055 i18nTemplate.process(this.document_, loadTimeData); | 1071 i18nTemplate.process(this.document_, loadTimeData); |
| 1056 | 1072 |
| 1057 // Arrange the file list. | 1073 // Arrange the file list. |
| 1058 this.table_.normalizeColumns(); | 1074 this.table_.normalizeColumns(); |
| 1059 this.table_.redraw(); | 1075 this.table_.redraw(); |
| 1060 | 1076 |
| 1077 metrics.recordInterval('Load.AdditionalUI'); |
| 1061 callback(); | 1078 callback(); |
| 1062 }; | 1079 }; |
| 1063 | 1080 |
| 1064 /** | 1081 /** |
| 1065 * @private | 1082 * @private |
| 1066 */ | 1083 */ |
| 1067 FileManager.prototype.onBreadcrumbClick_ = function(event) { | 1084 FileManager.prototype.onBreadcrumbClick_ = function(event) { |
| 1068 this.directoryModel_.changeDirectory(event.path); | 1085 this.directoryModel_.changeDirectory(event.path); |
| 1069 }; | 1086 }; |
| 1070 | 1087 |
| (...skipping 2824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3895 */ | 3912 */ |
| 3896 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { | 3913 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { |
| 3897 this.ctrlKeyPressed_ = flag; | 3914 this.ctrlKeyPressed_ = flag; |
| 3898 // Before the DOM is constructed, the key event can be handled. | 3915 // Before the DOM is constructed, the key event can be handled. |
| 3899 var cacheClearCommand = | 3916 var cacheClearCommand = |
| 3900 this.document_.querySelector('#drive-clear-local-cache'); | 3917 this.document_.querySelector('#drive-clear-local-cache'); |
| 3901 if (cacheClearCommand) | 3918 if (cacheClearCommand) |
| 3902 cacheClearCommand.canExecuteChange(); | 3919 cacheClearCommand.canExecuteChange(); |
| 3903 }; | 3920 }; |
| 3904 })(); | 3921 })(); |
| OLD | NEW |