Chromium Code Reviews| 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 var group = new AsyncUtil.Group(); | 213 metrics.startInterval('Load.Preferences'); |
| 214 var group = new AsyncUtil.Group(); | |
|
hirono
2013/08/12 16:53:51
One more space is needed to indent?
mtomasz
2013/08/13 01:49:29
Done.
| |
| 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; |
| 223 this.startupPrefName_ = 'file-manager-' + this.dialogType; | 224 this.startupPrefName_ = 'file-manager-' + this.dialogType; |
| (...skipping 19 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 13 matching lines...) Expand all Loading... | |
| 277 this.volumeManager_.mountDrive(function() {}, function() {}); | 281 this.volumeManager_.mountDrive(function() {}, function() {}); |
| 278 }; | 282 }; |
| 279 | 283 |
| 280 /** | 284 /** |
| 281 * One time initialization for the file system and related things. | 285 * One time initialization for the file system and related things. |
| 282 * | 286 * |
| 283 * @param {function()} callback Completion callback. | 287 * @param {function()} callback Completion callback. |
| 284 * @private | 288 * @private |
| 285 */ | 289 */ |
| 286 FileManager.prototype.initFileSystemUI_ = function(callback) { | 290 FileManager.prototype.initFileSystemUI_ = function(callback) { |
| 291 metrics.startInterval('Load.FileSystemUI'); | |
| 287 this.table_.startBatchUpdates(); | 292 this.table_.startBatchUpdates(); |
| 288 this.grid_.startBatchUpdates(); | 293 this.grid_.startBatchUpdates(); |
| 289 | 294 |
| 290 this.initFileList_(); | 295 this.initFileList_(); |
| 291 this.setupCurrentDirectory_(true /* page loading */); | 296 this.setupCurrentDirectory_(true /* page loading */); |
| 292 | 297 |
| 293 // PyAuto tests monitor this state by polling this variable | 298 // PyAuto tests monitor this state by polling this variable |
| 294 this.__defineGetter__('workerInitialized_', function() { | 299 this.__defineGetter__('workerInitialized_', function() { |
| 295 return this.metadataCache_.isInitialized(); | 300 return this.metadataCache_.isInitialized(); |
| 296 }.bind(this)); | 301 }.bind(this)); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 401 this.initContextMenus_(); | 406 this.initContextMenus_(); |
| 402 this.initCommands_(); | 407 this.initCommands_(); |
| 403 | 408 |
| 404 this.updateFileTypeFilter_(); | 409 this.updateFileTypeFilter_(); |
| 405 | 410 |
| 406 this.selectionHandler_.onFileSelectionChanged(); | 411 this.selectionHandler_.onFileSelectionChanged(); |
| 407 | 412 |
| 408 this.table_.endBatchUpdates(); | 413 this.table_.endBatchUpdates(); |
| 409 this.grid_.endBatchUpdates(); | 414 this.grid_.endBatchUpdates(); |
| 410 | 415 |
| 416 metrics.recordInterval('Load.FileSystemUI'); | |
| 411 callback(); | 417 callback(); |
| 412 }; | 418 }; |
| 413 | 419 |
| 414 /** | 420 /** |
| 415 * @private | 421 * @private |
| 416 */ | 422 */ |
| 417 FileManager.prototype.initDateTimeFormatters_ = function() { | 423 FileManager.prototype.initDateTimeFormatters_ = function() { |
| 418 var use12hourClock = !this.preferences_['use24hourClock']; | 424 var use12hourClock = !this.preferences_['use24hourClock']; |
| 419 this.table_.setDateTimeFormat(use12hourClock); | 425 this.table_.setDateTimeFormat(use12hourClock); |
| 420 }; | 426 }; |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 709 }; | 715 }; |
| 710 | 716 |
| 711 /** | 717 /** |
| 712 * Initializes general purpose basic things, which are used by other | 718 * Initializes general purpose basic things, which are used by other |
| 713 * initializing methods. | 719 * initializing methods. |
| 714 * | 720 * |
| 715 * @param {function()} callback Completion callback. | 721 * @param {function()} callback Completion callback. |
| 716 * @private | 722 * @private |
| 717 */ | 723 */ |
| 718 FileManager.prototype.initGeneral_ = function(callback) { | 724 FileManager.prototype.initGeneral_ = function(callback) { |
| 725 metrics.startInterval('Load.General'); | |
| 719 this.volumeManager_ = VolumeManager.getInstance(); | 726 this.volumeManager_ = VolumeManager.getInstance(); |
| 720 if (window.appState) { | 727 if (window.appState) { |
| 721 this.params_ = window.appState.params || {}; | 728 this.params_ = window.appState.params || {}; |
| 722 this.defaultPath = window.appState.defaultPath; | 729 this.defaultPath = window.appState.defaultPath; |
| 723 } else { | 730 } else { |
| 724 this.params_ = location.search ? | 731 this.params_ = location.search ? |
| 725 JSON.parse(decodeURIComponent(location.search.substr(1))) : | 732 JSON.parse(decodeURIComponent(location.search.substr(1))) : |
| 726 {}; | 733 {}; |
| 727 this.defaultPath = this.params_.defaultPath; | 734 this.defaultPath = this.params_.defaultPath; |
| 728 } | 735 } |
| 736 metrics.recordInterval('Load.General'); | |
| 729 callback(); | 737 callback(); |
| 730 }; | 738 }; |
| 731 | 739 |
| 732 /** | 740 /** |
| 733 * One time initialization of strings (mostly i18n). | 741 * One time initialization of strings (mostly i18n). |
| 734 * | 742 * |
| 735 * @param {function()} callback Completion callback. | 743 * @param {function()} callback Completion callback. |
| 736 * @private | 744 * @private |
| 737 */ | 745 */ |
| 738 FileManager.prototype.initStrings_ = function(callback) { | 746 FileManager.prototype.initStrings_ = function(callback) { |
| 747 metrics.startInterval('Load.Strings'); | |
| 739 // Fetch the strings via the private api if running in the browser window. | 748 // Fetch the strings via the private api if running in the browser window. |
| 740 // Otherwise, read cached strings from the local storage. | 749 // Otherwise, read cached strings from the local storage. |
| 741 if (util.platform.runningInBrowser()) { | 750 if (util.platform.runningInBrowser()) { |
| 742 chrome.fileBrowserPrivate.getStrings(function(strings) { | 751 chrome.fileBrowserPrivate.getStrings(function(strings) { |
| 743 loadTimeData.data = strings; | 752 loadTimeData.data = strings; |
| 753 metrics.recordInterval('Load.Strings'); | |
| 744 callback(); | 754 callback(); |
| 745 }); | 755 }); |
| 746 } else { | 756 } else { |
| 747 chrome.storage.local.get('strings', function(items) { | 757 chrome.storage.local.get('strings', function(items) { |
| 748 loadTimeData.data = items['strings']; | 758 loadTimeData.data = items['strings']; |
| 759 metrics.recordInterval('Load.Strings'); | |
| 749 callback(); | 760 callback(); |
| 750 }); | 761 }); |
| 751 } | 762 } |
| 752 }; | 763 }; |
| 753 | 764 |
| 754 /** | 765 /** |
| 755 * One time initialization of the Files.app's essential UI elements. These | 766 * One time initialization of the Files.app's essential UI elements. These |
| 756 * elements will be shown to the user. Only visible elements should be | 767 * elements will be shown to the user. Only visible elements should be |
| 757 * initialized here. Any heavy operation should be avoided. Files.app's | 768 * initialized here. Any heavy operation should be avoided. Files.app's |
| 758 * window is shown at the end of this routine. | 769 * window is shown at the end of this routine. |
| 759 * | 770 * |
| 760 * @param {function()} callback Completion callback. | 771 * @param {function()} callback Completion callback. |
| 761 * @private | 772 * @private |
| 762 */ | 773 */ |
| 763 FileManager.prototype.initEssentialUI_ = function(callback) { | 774 FileManager.prototype.initEssentialUI_ = function(callback) { |
| 775 metrics.startInterval('Load.EssentialUI'); | |
| 764 this.listType_ = null; | 776 this.listType_ = null; |
| 765 | 777 |
| 766 this.filesystemObserverId_ = null; | 778 this.filesystemObserverId_ = null; |
| 767 this.driveObserverId_ = null; | 779 this.driveObserverId_ = null; |
| 768 | 780 |
| 769 this.document_ = this.dialogDom_.ownerDocument; | 781 this.document_ = this.dialogDom_.ownerDocument; |
| 770 this.dialogType = this.params_.type || DialogType.FULL_PAGE; | 782 this.dialogType = this.params_.type || DialogType.FULL_PAGE; |
| 771 this.startupPrefName_ = 'file-manager-' + this.dialogType; | 783 this.startupPrefName_ = 'file-manager-' + this.dialogType; |
| 772 | 784 |
| 773 // Used to filter out focusing by mouse. | 785 // Used to filter out focusing by mouse. |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 803 | 815 |
| 804 // Pre-populate the static localized strings. | 816 // Pre-populate the static localized strings. |
| 805 i18nTemplate.process(this.document_, loadTimeData); | 817 i18nTemplate.process(this.document_, loadTimeData); |
| 806 | 818 |
| 807 // Initialize the header. | 819 // Initialize the header. |
| 808 this.dialogDom_.querySelector('#app-name').innerText = | 820 this.dialogDom_.querySelector('#app-name').innerText = |
| 809 chrome.runtime.getManifest().name; | 821 chrome.runtime.getManifest().name; |
| 810 | 822 |
| 811 this.initDialogType_(); | 823 this.initDialogType_(); |
| 812 | 824 |
| 825 metrics.recordInterval('Load.Display'); | |
| 826 metrics.recordInterval('Load.EssentialUI'); | |
| 827 | |
| 813 // Show the window as soon as the UI pre-initialization is done. | 828 // Show the window as soon as the UI pre-initialization is done. |
| 814 if (this.dialogType == DialogType.FULL_PAGE && | 829 if (this.dialogType == DialogType.FULL_PAGE && |
| 815 !util.platform.runningInBrowser()) { | 830 !util.platform.runningInBrowser()) { |
| 816 chrome.app.window.current().show(); | 831 chrome.app.window.current().show(); |
| 817 setTimeout(callback, 100); // Wait until the animation is finished. | 832 setTimeout(callback, 100); // Wait until the animation is finished. |
| 818 } else { | 833 } else { |
| 819 callback(); | 834 callback(); |
| 820 } | 835 } |
| 821 }; | 836 }; |
| 822 | 837 |
| 823 /** | 838 /** |
| 824 * One-time initialization of dialogs. | 839 * One-time initialization of dialogs. |
| 825 * @private | 840 * @private |
| 826 */ | 841 */ |
| 827 FileManager.prototype.initDialogs_ = function() { | 842 FileManager.prototype.initDialogs_ = function() { |
| 828 var d = cr.ui.dialogs; | 843 var d = cr.ui.dialogs; |
| 829 d.BaseDialog.OK_LABEL = str('OK_LABEL'); | 844 d.BaseDialog.OK_LABEL = str('OK_LABEL'); |
| 830 d.BaseDialog.CANCEL_LABEL = str('CANCEL_LABEL'); | 845 d.BaseDialog.CANCEL_LABEL = str('CANCEL_LABEL'); |
| 831 this.error = new ErrorDialog(this.dialogDom_); | 846 this.error = new ErrorDialog(this.dialogDom_); |
| 832 this.alert = new d.AlertDialog(this.dialogDom_); | 847 this.alert = new d.AlertDialog(this.dialogDom_); |
| 833 this.confirm = new d.ConfirmDialog(this.dialogDom_); | 848 this.confirm = new d.ConfirmDialog(this.dialogDom_); |
| 834 this.prompt = new d.PromptDialog(this.dialogDom_); | 849 this.prompt = new d.PromptDialog(this.dialogDom_); |
| 835 this.shareDialog_ = new ShareDialog(this.dialogDom_); | 850 this.shareDialog_ = new ShareDialog(this.dialogDom_); |
| 836 this.defaultTaskPicker = | 851 this.defaultTaskPicker = |
| 837 new cr.filebrowser.DefaultActionDialog(this.dialogDom_); | 852 new cr.filebrowser.DefaultActionDialog(this.dialogDom_); |
| 838 }; | 853 }; |
| 839 | 854 |
| 840 /** | 855 /** |
| 841 * One-time initialization of various DOM nodes. Loads the additional DOM | 856 * One-time initialization of various DOM nodes. Loads the additional DOM |
| 842 * elements visible to the user. Initialize here elements, which are expensive | 857 * elements visible to the user. Initialize here elements, which are expensive |
| 843 * or hidden in the beginning. | 858 * or hidden in the beginning. |
| 844 * | 859 * |
| 845 * @param {function()} callback Completion callback. | 860 * @param {function()} callback Completion callback. |
| 846 * @private | 861 * @private |
| 847 */ | 862 */ |
| 848 FileManager.prototype.initAdditionalUI_ = function(callback) { | 863 FileManager.prototype.initAdditionalUI_ = function(callback) { |
| 864 metrics.startInterval('Load.AdditionalUI'); | |
| 849 this.initDialogs_(); | 865 this.initDialogs_(); |
| 850 | 866 |
| 851 this.dialogDom_.addEventListener('drop', function(e) { | 867 this.dialogDom_.addEventListener('drop', function(e) { |
| 852 // Prevent opening an URL by dropping it onto the page. | 868 // Prevent opening an URL by dropping it onto the page. |
| 853 e.preventDefault(); | 869 e.preventDefault(); |
| 854 }); | 870 }); |
| 855 | 871 |
| 856 this.dialogDom_.addEventListener('click', | 872 this.dialogDom_.addEventListener('click', |
| 857 this.onExternalLinkClick_.bind(this)); | 873 this.onExternalLinkClick_.bind(this)); |
| 858 // Cache nodes we'll be manipulating. | 874 // Cache nodes we'll be manipulating. |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1035 | 1051 |
| 1036 util.addIsFocusedMethod(); | 1052 util.addIsFocusedMethod(); |
| 1037 | 1053 |
| 1038 // Populate the static localized strings. | 1054 // Populate the static localized strings. |
| 1039 i18nTemplate.process(this.document_, loadTimeData); | 1055 i18nTemplate.process(this.document_, loadTimeData); |
| 1040 | 1056 |
| 1041 // Arrange the file list. | 1057 // Arrange the file list. |
| 1042 this.table_.normalizeColumns(); | 1058 this.table_.normalizeColumns(); |
| 1043 this.table_.redraw(); | 1059 this.table_.redraw(); |
| 1044 | 1060 |
| 1061 metrics.recordInterval('Load.AdditionalUI'); | |
| 1045 callback(); | 1062 callback(); |
| 1046 }; | 1063 }; |
| 1047 | 1064 |
| 1048 /** | 1065 /** |
| 1049 * @private | 1066 * @private |
| 1050 */ | 1067 */ |
| 1051 FileManager.prototype.onBreadcrumbClick_ = function(event) { | 1068 FileManager.prototype.onBreadcrumbClick_ = function(event) { |
| 1052 this.directoryModel_.changeDirectory(event.path); | 1069 this.directoryModel_.changeDirectory(event.path); |
| 1053 }; | 1070 }; |
| 1054 | 1071 |
| (...skipping 2819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3874 */ | 3891 */ |
| 3875 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { | 3892 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { |
| 3876 this.ctrlKeyPressed_ = flag; | 3893 this.ctrlKeyPressed_ = flag; |
| 3877 // Before the DOM is constructed, the key event can be handled. | 3894 // Before the DOM is constructed, the key event can be handled. |
| 3878 var cacheClearCommand = | 3895 var cacheClearCommand = |
| 3879 this.document_.querySelector('#drive-clear-local-cache'); | 3896 this.document_.querySelector('#drive-clear-local-cache'); |
| 3880 if (cacheClearCommand) | 3897 if (cacheClearCommand) |
| 3881 cacheClearCommand.canExecuteChange(); | 3898 cacheClearCommand.canExecuteChange(); |
| 3882 }; | 3899 }; |
| 3883 })(); | 3900 })(); |
| OLD | NEW |