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

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

Issue 18627002: Change dialog texts for folder upload to explicitly indicate it's for 'Uploading' (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 (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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 /** 55 /**
56 * List of dialog types. 56 * List of dialog types.
57 * 57 *
58 * Keep this in sync with FileManagerDialog::GetDialogTypeAsString, except 58 * Keep this in sync with FileManagerDialog::GetDialogTypeAsString, except
59 * FULL_PAGE which is specific to this code. 59 * FULL_PAGE which is specific to this code.
60 * 60 *
61 * @enum {string} 61 * @enum {string}
62 */ 62 */
63 var DialogType = { 63 var DialogType = {
64 SELECT_FOLDER: 'folder', 64 SELECT_FOLDER: 'folder',
65 SELECT_UPLOAD_FOLDER: 'upload-folder',
65 SELECT_SAVEAS_FILE: 'saveas-file', 66 SELECT_SAVEAS_FILE: 'saveas-file',
66 SELECT_OPEN_FILE: 'open-file', 67 SELECT_OPEN_FILE: 'open-file',
67 SELECT_OPEN_MULTI_FILE: 'open-multi-file', 68 SELECT_OPEN_MULTI_FILE: 'open-multi-file',
68 FULL_PAGE: 'full-page' 69 FULL_PAGE: 'full-page'
69 }; 70 };
70 71
71 /** 72 /**
72 * TextMeasure constructor. 73 * TextMeasure constructor.
73 * 74 *
74 * TextMeasure is a measure for text that returns the width of text. This 75 * TextMeasure is a measure for text that returns the width of text. This
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 var rect = this.dummySpan_.getBoundingClientRect(); 112 var rect = this.dummySpan_.getBoundingClientRect();
112 return rect ? rect.width : 0; 113 return rect ? rect.width : 0;
113 }; 114 };
114 115
115 /** 116 /**
116 * @param {string} type Dialog type. 117 * @param {string} type Dialog type.
117 * @return {boolean} Whether the type is modal. 118 * @return {boolean} Whether the type is modal.
118 */ 119 */
119 DialogType.isModal = function(type) { 120 DialogType.isModal = function(type) {
120 return type == DialogType.SELECT_FOLDER || 121 return type == DialogType.SELECT_FOLDER ||
122 type == DialogType.SELECT_UPLOAD_FOLDER ||
121 type == DialogType.SELECT_SAVEAS_FILE || 123 type == DialogType.SELECT_SAVEAS_FILE ||
122 type == DialogType.SELECT_OPEN_FILE || 124 type == DialogType.SELECT_OPEN_FILE ||
123 type == DialogType.SELECT_OPEN_MULTI_FILE; 125 type == DialogType.SELECT_OPEN_MULTI_FILE;
124 }; 126 };
125 127
126 /** 128 /**
127 * Bottom magrin of the list and tree for transparent preview panel. 129 * Bottom magrin of the list and tree for transparent preview panel.
128 * @const 130 * @const
129 */ 131 */
130 var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; 132 var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 this.dialogType = this.params_.type || DialogType.FULL_PAGE; 834 this.dialogType = this.params_.type || DialogType.FULL_PAGE;
833 this.startupPrefName_ = 'file-manager-' + this.dialogType; 835 this.startupPrefName_ = 'file-manager-' + this.dialogType;
834 836
835 // Used to filter out focusing by mouse. 837 // Used to filter out focusing by mouse.
836 this.suppressFocus_ = false; 838 this.suppressFocus_ = false;
837 839
838 // Optional list of file types. 840 // Optional list of file types.
839 this.fileTypes_ = this.params_.typeList || []; 841 this.fileTypes_ = this.params_.typeList || [];
840 metrics.recordEnum('Create', this.dialogType, 842 metrics.recordEnum('Create', this.dialogType,
841 [DialogType.SELECT_FOLDER, 843 [DialogType.SELECT_FOLDER,
844 DialogType.SELECT_UPLOAD_FOLDER,
842 DialogType.SELECT_SAVEAS_FILE, 845 DialogType.SELECT_SAVEAS_FILE,
843 DialogType.SELECT_OPEN_FILE, 846 DialogType.SELECT_OPEN_FILE,
844 DialogType.SELECT_OPEN_MULTI_FILE, 847 DialogType.SELECT_OPEN_MULTI_FILE,
845 DialogType.FULL_PAGE]); 848 DialogType.FULL_PAGE]);
846 849
847 this.selectionHandler_ = null; 850 this.selectionHandler_ = null;
848 this.ctrlKeyPressed_ = false; 851 this.ctrlKeyPressed_ = false;
849 852
850 this.metadataCache_ = MetadataCache.createFull(); 853 this.metadataCache_ = MetadataCache.createFull();
851 854
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 FileManager.prototype.initFileList_ = function() { 1112 FileManager.prototype.initFileList_ = function() {
1110 // Always sharing the data model between the detail/thumb views confuses 1113 // Always sharing the data model between the detail/thumb views confuses
1111 // them. Instead we maintain this bogus data model, and hook it up to the 1114 // them. Instead we maintain this bogus data model, and hook it up to the
1112 // view that is not in use. 1115 // view that is not in use.
1113 this.emptyDataModel_ = new cr.ui.ArrayDataModel([]); 1116 this.emptyDataModel_ = new cr.ui.ArrayDataModel([]);
1114 this.emptySelectionModel_ = new cr.ui.ListSelectionModel(); 1117 this.emptySelectionModel_ = new cr.ui.ListSelectionModel();
1115 1118
1116 var singleSelection = 1119 var singleSelection =
1117 this.dialogType == DialogType.SELECT_OPEN_FILE || 1120 this.dialogType == DialogType.SELECT_OPEN_FILE ||
1118 this.dialogType == DialogType.SELECT_FOLDER || 1121 this.dialogType == DialogType.SELECT_FOLDER ||
1122 this.dialogType == DialogType.SELECT_UPLOAD_FOLDER ||
1119 this.dialogType == DialogType.SELECT_SAVEAS_FILE; 1123 this.dialogType == DialogType.SELECT_SAVEAS_FILE;
1120 1124
1121 var showSpecialSearchRoots = 1125 var showSpecialSearchRoots =
1122 this.dialogType == DialogType.SELECT_OPEN_FILE || 1126 this.dialogType == DialogType.SELECT_OPEN_FILE ||
1123 this.dialogType == DialogType.SELECT_OPEN_MULTI_FILE || 1127 this.dialogType == DialogType.SELECT_OPEN_MULTI_FILE ||
1124 this.dialogType == DialogType.FULL_PAGE; 1128 this.dialogType == DialogType.FULL_PAGE;
1125 1129
1126 this.fileFilter_ = new FileFilter( 1130 this.fileFilter_ = new FileFilter(
1127 this.metadataCache_, 1131 this.metadataCache_,
1128 false /* Don't show dot files by default. */); 1132 false /* Don't show dot files by default. */);
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1757 */ 1761 */
1758 FileManager.prototype.initDialogType_ = function() { 1762 FileManager.prototype.initDialogType_ = function() {
1759 var defaultTitle; 1763 var defaultTitle;
1760 var okLabel = str('OPEN_LABEL'); 1764 var okLabel = str('OPEN_LABEL');
1761 1765
1762 switch (this.dialogType) { 1766 switch (this.dialogType) {
1763 case DialogType.SELECT_FOLDER: 1767 case DialogType.SELECT_FOLDER:
1764 defaultTitle = str('SELECT_FOLDER_TITLE'); 1768 defaultTitle = str('SELECT_FOLDER_TITLE');
1765 break; 1769 break;
1766 1770
1771 case DialogType.SELECT_UPLOAD_FOLDER:
1772 defaultTitle = str('SELECT_UPLOAD_FOLDER_TITLE');
1773 okLabel = str('UPLOAD_LABEL');
1774 break;
1775
1767 case DialogType.SELECT_OPEN_FILE: 1776 case DialogType.SELECT_OPEN_FILE:
1768 defaultTitle = str('SELECT_OPEN_FILE_TITLE'); 1777 defaultTitle = str('SELECT_OPEN_FILE_TITLE');
1769 break; 1778 break;
1770 1779
1771 case DialogType.SELECT_OPEN_MULTI_FILE: 1780 case DialogType.SELECT_OPEN_MULTI_FILE:
1772 defaultTitle = str('SELECT_OPEN_MULTI_FILE_TITLE'); 1781 defaultTitle = str('SELECT_OPEN_MULTI_FILE_TITLE');
1773 break; 1782 break;
1774 1783
1775 case DialogType.SELECT_SAVEAS_FILE: 1784 case DialogType.SELECT_SAVEAS_FILE:
1776 defaultTitle = str('SELECT_SAVEAS_FILE_TITLE'); 1785 defaultTitle = str('SELECT_SAVEAS_FILE_TITLE');
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after
2929 var path = path.replace(/\/[^\/]+$/, ''); 2938 var path = path.replace(/\/[^\/]+$/, '');
2930 this.directoryModel_.changeDirectory(path); 2939 this.directoryModel_.changeDirectory(path);
2931 } 2940 }
2932 break; 2941 break;
2933 2942
2934 case '13': // Enter => Change directory or perform default action. 2943 case '13': // Enter => Change directory or perform default action.
2935 // TODO(dgozman): move directory action to dispatchSelectionAction. 2944 // TODO(dgozman): move directory action to dispatchSelectionAction.
2936 var selection = this.getSelection(); 2945 var selection = this.getSelection();
2937 if (selection.totalCount == 1 && 2946 if (selection.totalCount == 1 &&
2938 selection.entries[0].isDirectory && 2947 selection.entries[0].isDirectory &&
2939 this.dialogType != DialogType.SELECT_FOLDER) { 2948 this.dialogType != DialogType.SELECT_FOLDER &&
2949 this.dialogType != DialogType.SELECT_UPLOAD_FOLDER) {
2940 event.preventDefault(); 2950 event.preventDefault();
2941 this.onDirectoryAction(selection.entries[0]); 2951 this.onDirectoryAction(selection.entries[0]);
2942 } else if (this.dispatchSelectionAction_()) { 2952 } else if (this.dispatchSelectionAction_()) {
2943 event.preventDefault(); 2953 event.preventDefault();
2944 } 2954 }
2945 break; 2955 break;
2946 } 2956 }
2947 2957
2948 switch (event.keyIdentifier) { 2958 switch (event.keyIdentifier) {
2949 case 'Home': 2959 case 'Home':
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
3248 resolveSuccessCallback, resolveErrorCallback); 3258 resolveSuccessCallback, resolveErrorCallback);
3249 }; 3259 };
3250 3260
3251 this.validateFileName_(currentDirUrl, filename, checkOverwriteAndFinish); 3261 this.validateFileName_(currentDirUrl, filename, checkOverwriteAndFinish);
3252 return; 3262 return;
3253 } 3263 }
3254 3264
3255 var files = []; 3265 var files = [];
3256 var selectedIndexes = this.currentList_.selectionModel.selectedIndexes; 3266 var selectedIndexes = this.currentList_.selectionModel.selectedIndexes;
3257 3267
3258 if (this.dialogType == DialogType.SELECT_FOLDER && 3268 if ((this.dialogType == DialogType.SELECT_FOLDER ||
3269 this.dialogType == DialogType.SELECT_UPLOAD_FOLDER) &&
3259 selectedIndexes.length == 0) { 3270 selectedIndexes.length == 0) {
3260 var url = this.getCurrentDirectoryURL(); 3271 var url = this.getCurrentDirectoryURL();
3261 var singleSelection = { 3272 var singleSelection = {
3262 urls: [url], 3273 urls: [url],
3263 multiple: false, 3274 multiple: false,
3264 filterIndex: this.getSelectedFilterIndex_() 3275 filterIndex: this.getSelectedFilterIndex_()
3265 }; 3276 };
3266 this.selectFilesAndClose_(singleSelection); 3277 this.selectFilesAndClose_(singleSelection);
3267 return; 3278 return;
3268 } 3279 }
(...skipping 24 matching lines...) Expand all
3293 this.selectFilesAndClose_(multipleSelection); 3304 this.selectFilesAndClose_(multipleSelection);
3294 return; 3305 return;
3295 } 3306 }
3296 3307
3297 // Everything else must have exactly one. 3308 // Everything else must have exactly one.
3298 if (files.length > 1) 3309 if (files.length > 1)
3299 throw new Error('Too many files selected!'); 3310 throw new Error('Too many files selected!');
3300 3311
3301 var selectedEntry = dm.item(selectedIndexes[0]); 3312 var selectedEntry = dm.item(selectedIndexes[0]);
3302 3313
3303 if (this.dialogType == DialogType.SELECT_FOLDER) { 3314 if (this.dialogType == DialogType.SELECT_FOLDER ||
3315 this.dialogType == DialogType.SELECT_UPLOAD_FOLDER) {
3304 if (!selectedEntry.isDirectory) 3316 if (!selectedEntry.isDirectory)
3305 throw new Error('Selected entry is not a folder!'); 3317 throw new Error('Selected entry is not a folder!');
3306 } else if (this.dialogType == DialogType.SELECT_OPEN_FILE) { 3318 } else if (this.dialogType == DialogType.SELECT_OPEN_FILE) {
3307 if (!selectedEntry.isFile) 3319 if (!selectedEntry.isFile)
3308 throw new Error('Selected entry is not a file!'); 3320 throw new Error('Selected entry is not a file!');
3309 } 3321 }
3310 3322
3311 var singleSelection = { 3323 var singleSelection = {
3312 urls: [files[0]], 3324 urls: [files[0]],
3313 multiple: false, 3325 multiple: false,
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
3824 * Set the flag expressing whether the ctrl key is pressed or not. 3836 * Set the flag expressing whether the ctrl key is pressed or not.
3825 * @param {boolean} flag New value of the flag 3837 * @param {boolean} flag New value of the flag
3826 * @private 3838 * @private
3827 */ 3839 */
3828 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { 3840 FileManager.prototype.setCtrlKeyPressed_ = function(flag) {
3829 this.ctrlKeyPressed_ = flag; 3841 this.ctrlKeyPressed_ = flag;
3830 this.document_.querySelector('#drive-clear-local-cache').canExecuteChange(); 3842 this.document_.querySelector('#drive-clear-local-cache').canExecuteChange();
3831 this.document_.querySelector('#drive-reload').canExecuteChange(); 3843 this.document_.querySelector('#drive-reload').canExecuteChange();
3832 }; 3844 };
3833 })(); 3845 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698