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 * FileManager constructor. | 8 * FileManager constructor. |
| 9 * | 9 * |
| 10 * FileManager objects encapsulate the functionality of the file selector | 10 * FileManager objects encapsulate the functionality of the file selector |
| 11 * dialogs, as well as the full screen file manager application (though the | 11 * dialogs, as well as the full screen file manager application (though the |
| 12 * latter is not yet implemented). | 12 * latter is not yet implemented). |
| 13 * | 13 * |
| 14 * @constructor | 14 * @constructor |
| 15 */ | 15 */ |
| 16 function FileManager() { | 16 function FileManager() { |
| 17 this.initializeQueue_ = new AsyncUtil.Group(); | 17 |
|
hirono
2014/09/10 04:50:32
nit: May be we should remove the line because we d
fukino
2014/09/10 04:54:08
Done.
| |
| 18 // -------------------------------------------------------------------------- | |
| 19 // Services FileManager depends on. | |
| 20 | |
| 21 /** | |
| 22 * Volume manager. | |
| 23 * @type {VolumeManager} | |
| 24 * @private | |
| 25 */ | |
| 26 this.volumeManager_ = null; | |
| 27 | |
| 28 /** | |
| 29 * Metadata cache. | |
| 30 * @type {MetadataCache} | |
| 31 * @private | |
| 32 */ | |
| 33 this.metadataCache_ = null; | |
| 34 | |
| 35 /** | |
| 36 * File operation manager. | |
| 37 * @type {FileOperationManager} | |
| 38 * @private | |
| 39 */ | |
| 40 this.fileOperationManager_ = null; | |
| 41 | |
| 42 /** | |
| 43 * File transfer controller. | |
| 44 * @type {FileTransferController} | |
| 45 * @private | |
| 46 */ | |
| 47 this.fileTransferController_ = null; | |
| 48 | |
| 49 /** | |
| 50 * File filter. | |
| 51 * @type {FileFilter} | |
| 52 * @private | |
| 53 */ | |
| 54 this.fileFilter_ = null; | |
| 55 | |
| 56 /** | |
| 57 * File watcher. | |
| 58 * @type {FileWatcher} | |
| 59 * @private | |
| 60 */ | |
| 61 this.fileWatcher_ = null; | |
| 62 | |
| 63 /** | |
| 64 * Model of current directory. | |
| 65 * @type {DirectoryModel} | |
| 66 * @private | |
| 67 */ | |
| 68 this.directoryModel_ = null; | |
| 69 | |
| 70 /** | |
| 71 * Model of folder shortcuts. | |
| 72 * @type {FolderShortcutsDataModel} | |
| 73 * @private | |
| 74 */ | |
| 75 this.folderShortcutsModel_ = null; | |
| 76 | |
| 77 /** | |
| 78 * VolumeInfo of the current volume. | |
| 79 * @type {VolumeInfo} | |
| 80 * @private | |
| 81 */ | |
| 82 this.currentVolumeInfo_ = null; | |
| 83 | |
| 84 /** | |
| 85 * Handler for command events. | |
| 86 * @type {CommandHandler} | |
| 87 */ | |
| 88 this.commandHandler = null; | |
| 89 | |
| 90 /** | |
| 91 * Handler for the change of file selection. | |
| 92 * @type {SelectionHandler} | |
| 93 * @private | |
| 94 */ | |
| 95 this.selectionHandler_ = null; | |
| 96 | |
| 97 // -------------------------------------------------------------------------- | |
| 98 // Parameters determining the type of file manager. | |
| 99 | |
| 100 /** | |
| 101 * Dialog type of this window. | |
| 102 * @type {DialogType} | |
| 103 */ | |
| 104 this.dialogType = DialogType.FULL_PAGE; | |
| 18 | 105 |
| 19 /** | 106 /** |
| 20 * Current list type. | 107 * Current list type. |
| 21 * @type {ListType} | 108 * @type {ListType} |
| 22 * @private | 109 * @private |
| 23 */ | 110 */ |
| 24 this.listType_ = null; | 111 this.listType_ = null; |
| 25 | 112 |
| 26 /** | 113 /** |
| 114 * List of acceptable file types for open dialog. | |
| 115 * @type {Array.<Object>} | |
| 116 * @private | |
| 117 */ | |
| 118 this.fileTypes_ = []; | |
| 119 | |
| 120 /** | |
| 121 * Startup parameters for this application. | |
| 122 * @type {Object} | |
| 123 * @private | |
| 124 */ | |
| 125 this.params_ = null; | |
| 126 | |
| 127 /** | |
| 128 * Startup preference about the view. | |
| 129 * @type {Object} | |
| 130 * @private | |
| 131 */ | |
| 132 this.viewOptions_ = {}; | |
| 133 | |
| 134 /** | |
| 135 * The user preference. | |
| 136 * @type {Object} | |
| 137 * @private | |
| 138 */ | |
| 139 this.preferences_ = null; | |
| 140 | |
| 141 // -------------------------------------------------------------------------- | |
| 142 // UI components. | |
| 143 | |
| 144 /** | |
| 145 * UI management class of file manager. | |
| 146 * @type {FileManagerUI} | |
| 147 * @private | |
| 148 */ | |
| 149 this.ui_ = null; | |
| 150 | |
| 151 /** | |
| 152 * Preview panel. | |
| 153 * @type {PreviewPanel} | |
| 154 * @private | |
| 155 */ | |
| 156 this.previewPanel_ = null; | |
| 157 | |
| 158 /** | |
| 159 * Progress center panel. | |
| 160 * @type {ProgressCenterPanel} | |
| 161 * @private | |
| 162 */ | |
| 163 this.progressCenterPanel_ = null; | |
| 164 | |
| 165 /** | |
| 166 * Directory tree. | |
| 167 * @type {DirectoryTree} | |
| 168 * @private | |
| 169 */ | |
| 170 this.directoryTree_ = null; | |
| 171 | |
| 172 /** | |
| 173 * Auto-complete list. | |
| 174 * @type {AutocompleteList} | |
| 175 * @private | |
| 176 */ | |
| 177 this.autocompleteList_ = null; | |
| 178 | |
| 179 /** | |
| 180 * Banners in the file list. | |
| 181 * @type {FileListBannerController} | |
| 182 * @private | |
| 183 */ | |
| 184 this.bannersController_ = null; | |
| 185 | |
| 186 // -------------------------------------------------------------------------- | |
| 187 // Dialogs. | |
| 188 | |
| 189 /** | |
| 190 * Error dialog. | |
| 191 * @type {ErrorDialog} | |
| 192 */ | |
| 193 this.error = null; | |
| 194 | |
| 195 /** | |
| 196 * Alert dialog. | |
| 197 * @type {cr.ui.dialogs.AlertDialog} | |
| 198 */ | |
| 199 this.alert = null; | |
| 200 | |
| 201 /** | |
| 202 * Confirm dialog. | |
| 203 * @type {cr.ui.dialogs.ConfirmDialog} | |
| 204 */ | |
| 205 this.confirm = null; | |
| 206 | |
| 207 /** | |
| 208 * Prompt dialog. | |
| 209 * @type {cr.ui.dialogs.PromptDialog} | |
| 210 */ | |
| 211 this.prompt = null; | |
| 212 | |
| 213 /** | |
| 214 * Share dialog. | |
| 215 * @type {ShareDialog} | |
| 216 * @private | |
| 217 */ | |
| 218 this.shareDialog_ = null; | |
| 219 | |
| 220 /** | |
| 221 * Default task picker. | |
| 222 * @type {DefaultActionDialog} | |
| 223 */ | |
| 224 this.defaultTaskPicker = null; | |
| 225 | |
| 226 /** | |
| 227 * Suggest apps dialog. | |
| 228 * @type {SuggestAppsDialog} | |
| 229 */ | |
| 230 this.suggestAppsDialog = null; | |
| 231 | |
| 232 // -------------------------------------------------------------------------- | |
| 233 // Menus. | |
| 234 | |
| 235 /** | |
| 236 * Context menu for files. | |
| 237 * @type {HTMLMenuElement} | |
| 238 * @private | |
| 239 */ | |
| 240 this.fileContextMenu_ = null; | |
| 241 | |
| 242 /** | |
| 243 * Context menu for volumes or shortcuts displayed on left pane. | |
| 244 * @type {HTMLMenuElement} | |
| 245 * @private | |
| 246 */ | |
| 247 this.rootsContextMenu_ = null; | |
| 248 | |
| 249 /** | |
| 250 * Context menu for directory tree items. | |
| 251 * @type {HTMLMenuElement} | |
| 252 * @private | |
| 253 */ | |
| 254 this.directoryTreeContextMenu_ = null; | |
| 255 | |
| 256 /** | |
| 257 * Context menu for texts. | |
| 258 * @type {HTMLMenuElement} | |
| 259 * @private | |
| 260 */ | |
| 261 this.textContextMenu_ = null; | |
| 262 | |
| 263 // -------------------------------------------------------------------------- | |
| 264 // DOM elements. | |
| 265 | |
| 266 /** | |
| 267 * Background page. | |
| 268 * @type {Window} | |
| 269 * @private | |
| 270 */ | |
| 271 this.backgroundPage_ = null; | |
| 272 | |
| 273 /** | |
| 274 * The root DOM element of this app. | |
| 275 * @type {HTMLBodyElement} | |
| 276 * @private | |
| 277 */ | |
| 278 this.dialogDom_ = null; | |
| 279 | |
| 280 /** | |
| 281 * The document object of this app. | |
| 282 * @type {HTMLDocument} | |
| 283 * @private | |
| 284 */ | |
| 285 this.document_ = null; | |
| 286 | |
| 287 /** | |
| 288 * The menu item to toggle "Do not use mobile data for sync". | |
| 289 * @type {HTMLMenuItemElement} | |
| 290 */ | |
| 291 this.syncButton = null; | |
| 292 | |
| 293 /** | |
| 294 * The menu item to toggle "Show Google Docs files". | |
| 295 * @type {HTMLMenuItemElement} | |
| 296 */ | |
| 297 this.hostedButton = null; | |
| 298 | |
| 299 /** | |
| 300 * The menu item for doing default action. | |
| 301 * @type {HTMLMenuItemElement} | |
| 302 * @private | |
| 303 */ | |
| 304 this.defaultActionMenuItem_ = null; | |
| 305 | |
| 306 /** | |
| 307 * The button to open gear menu. | |
| 308 * @type {HTMLButtonElement} | |
| 309 * @private | |
| 310 */ | |
| 311 this.gearButton_ = null; | |
| 312 | |
| 313 /** | |
| 314 * The OK button. | |
| 315 * @type {HTMLButtonElement} | |
| 316 * @private | |
| 317 */ | |
| 318 this.okButton_ = null; | |
| 319 | |
| 320 /** | |
| 321 * The cancel button. | |
| 322 * @type {HTMLButtonElement} | |
| 323 * @private | |
| 324 */ | |
| 325 this.cancelButton_ = null; | |
| 326 | |
| 327 /** | |
| 328 * The combo button to specify the task. | |
| 329 * @type {HTMLButtonElement} | |
| 330 * @private | |
| 331 */ | |
| 332 this.taskItems_ = null; | |
| 333 | |
| 334 /** | |
| 335 * The input element to rename entry. | |
| 336 * @type {HTMLInputElement} | |
| 337 * @private | |
| 338 */ | |
| 339 this.renameInput_ = null; | |
| 340 | |
| 341 /** | |
| 342 * The input element to specify file name. | |
| 343 * @type {HTMLInputElement} | |
| 344 * @private | |
| 345 */ | |
| 346 this.filenameInput_ = null; | |
| 347 | |
| 348 /** | |
| 349 * The file table. | |
| 350 * @type {FileTable} | |
| 351 * @private | |
| 352 */ | |
| 353 this.table_ = null; | |
| 354 | |
| 355 /** | |
| 356 * The file grid. | |
| 357 * @type {FileGrid} | |
| 358 * @private | |
| 359 */ | |
| 360 this.grid_ = null; | |
| 361 | |
| 362 /** | |
| 363 * Current file list. | |
| 364 * @type {cr.ui.List} | |
| 365 * @private | |
| 366 */ | |
| 367 this.currentList_ = null; | |
| 368 | |
| 369 /** | |
| 370 * Spinner on file list which is shown while loading. | |
| 371 * @type {HTMLDivElement} | |
| 372 * @private | |
| 373 */ | |
| 374 this.spinner_ = null; | |
| 375 | |
| 376 /** | |
| 377 * The container element of the dialog. | |
| 378 * @type {HTMLDivElement} | |
| 379 * @private | |
| 380 */ | |
| 381 this.dialogContainer_ = null; | |
| 382 | |
| 383 /** | |
| 384 * The container element of the file list. | |
| 385 * @type {HTMLDivElement} | |
| 386 * @private | |
| 387 */ | |
| 388 this.listContainer_ = null; | |
| 389 | |
| 390 /** | |
| 391 * The input element in the search box. | |
| 392 * @type {HTMLInputElement} | |
| 393 * @private | |
| 394 */ | |
| 395 this.searchBox_ = null; | |
| 396 | |
| 397 /** | |
| 398 * The file type selector. | |
| 399 * @type {HTMLSelectElement} | |
| 400 * @private | |
| 401 */ | |
| 402 this.fileTypeSelector_ = null; | |
| 403 | |
| 404 /** | |
| 405 * Open-with command in the context menu. | |
| 406 * @type {cr.ui.Command} | |
| 407 * @private | |
| 408 */ | |
| 409 this.openWithCommand_ = null; | |
| 410 | |
| 411 // -------------------------------------------------------------------------- | |
| 412 // Bound functions. | |
| 413 | |
| 414 /** | |
| 415 * Bound function for onCopyProgress_. | |
| 416 * @type {this:FileManager, function(Event)} | |
| 417 * @private | |
| 418 */ | |
| 419 this.onCopyProgressBound_ = null; | |
| 420 | |
| 421 /** | |
| 422 * Bound function for onEntriesChanged_. | |
| 423 * @type {this:FileManager, function(Event)} | |
| 424 * @private | |
| 425 */ | |
| 426 this.onEntriesChangedBound_ = null; | |
| 427 | |
| 428 /** | |
| 429 * Bound function for onCancel_. | |
| 430 * @type {this:FileManager, function(Event)} | |
| 431 * @private | |
| 432 */ | |
| 433 this.onCancelBound_ = null; | |
| 434 | |
| 435 // -------------------------------------------------------------------------- | |
| 436 // Scan state. | |
| 437 | |
| 438 /** | |
| 439 * Whether a scan is in progress. | |
| 440 * @type {boolean} | |
| 441 * @private | |
| 442 */ | |
| 443 this.scanInProgress_ = false; | |
| 444 | |
| 445 /** | |
| 446 * Whether a scan is updated at least once. If true, spinner should disappear. | |
| 447 * @type {boolean} | |
| 448 * @private | |
| 449 */ | |
| 450 this.scanUpdatedAtLeastOnceOrCompleted_ = false; | |
| 451 | |
| 452 /** | |
| 453 * Timer ID to delay UI refresh after a scan is completed. | |
| 454 * @type {number} | |
| 455 * @private | |
| 456 */ | |
| 457 this.scanCompletedTimer_ = 0; | |
| 458 | |
| 459 /** | |
| 460 * Timer ID to delay UI refresh after a scan is updated. | |
| 461 * @type {number} | |
| 462 * @private | |
| 463 */ | |
| 464 this.scanUpdatedTimer_ = 0; | |
| 465 | |
| 466 /** | |
| 467 * Timer ID to delay showing spinner after a scan starts. | |
| 468 * @type {number} | |
| 469 * @private | |
| 470 */ | |
| 471 this.showSpinnerTimeout_ = 0; | |
| 472 | |
| 473 // -------------------------------------------------------------------------- | |
| 474 // Search states. | |
| 475 | |
| 476 /** | |
| 477 * The last search query. | |
| 478 * @type {string} | |
| 479 * @private | |
| 480 */ | |
| 481 this.lastSearchQuery_ = ''; | |
| 482 | |
| 483 /** | |
| 484 * The last auto-complete query. | |
| 485 * @type {string} | |
| 486 * @private | |
| 487 */ | |
| 488 this.lastAutocompleteQuery_ = ''; | |
| 489 | |
| 490 /** | |
| 491 * Whether auto-complete suggestion is busy to respond previous request. | |
| 492 * @type {boolean} | |
| 493 * @private | |
| 494 */ | |
| 495 this.autocompleteSuggestionsBusy_ = false; | |
| 496 | |
| 497 /** | |
| 498 * State of text-search, which is triggerd by keyboard input on file list. | |
| 499 * @type {Object} | |
| 500 * @private | |
| 501 */ | |
| 502 this.textSearchState_ = {text: '', date: new Date()}; | |
| 503 | |
| 504 // -------------------------------------------------------------------------- | |
| 505 // Miscellaneous FileManager's states. | |
| 506 | |
| 507 /** | |
| 508 * Queue for ordering FileManager's initialization process. | |
| 509 * @type {AsyncUtil.Group} | |
| 510 * @private | |
| 511 */ | |
| 512 this.initializeQueue_ = new AsyncUtil.Group(); | |
| 513 | |
| 514 /** | |
| 27 * True while a user is pressing <Tab>. | 515 * True while a user is pressing <Tab>. |
| 28 * This is used for identifying the trigger causing the filelist to | 516 * This is used for identifying the trigger causing the filelist to |
| 29 * be focused. | 517 * be focused. |
| 30 * @type {boolean} | 518 * @type {boolean} |
| 31 * @private | 519 * @private |
| 32 */ | 520 */ |
| 33 this.pressingTab_ = false; | 521 this.pressingTab_ = false; |
| 34 | 522 |
| 35 /** | 523 /** |
| 36 * True while a user is pressing <Ctrl>. | 524 * True while a user is pressing <Ctrl>. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 48 * | 536 * |
| 49 * TODO(fukino): The state of gear menu should be moved to GearMenu class. | 537 * TODO(fukino): The state of gear menu should be moved to GearMenu class. |
| 50 * crbug.com/366032. | 538 * crbug.com/366032. |
| 51 * | 539 * |
| 52 * @type {boolean} | 540 * @type {boolean} |
| 53 * @private | 541 * @private |
| 54 */ | 542 */ |
| 55 this.isSecretGearMenuShown_ = false; | 543 this.isSecretGearMenuShown_ = false; |
| 56 | 544 |
| 57 /** | 545 /** |
| 58 * SelectionHandler. | 546 * The last clicked item in the file list. |
| 59 * @type {SelectionHandler} | 547 * @type {HTMLLIElement} |
| 60 * @private | 548 * @private |
| 61 */ | 549 */ |
| 62 this.selectionHandler_ = null; | 550 this.lastClickedItem_ = null; |
| 63 | 551 |
| 64 /** | 552 /** |
| 65 * VolumeInfo of the current volume. | 553 * Count of the SourceNotFound error. |
| 66 * @type {VolumeInfo} | 554 * @type {number} |
| 67 * @private | 555 * @private |
| 68 */ | 556 */ |
| 69 this.currentVolumeInfo_ = null; | 557 this.sourceNotFoundErrorCount_ = 0; |
| 558 | |
| 559 /** | |
| 560 * Whether the app should be closed on unmount. | |
| 561 * @type {boolean} | |
| 562 * @private | |
| 563 */ | |
| 564 this.closeOnUnmount_ = false; | |
| 565 | |
| 566 /** | |
| 567 * The key for storing startup preference. | |
| 568 * @type {string} | |
| 569 * @private | |
| 570 */ | |
| 571 this.startupPrefName_ = ''; | |
| 572 | |
| 573 /** | |
| 574 * URL of directory which should be initial current directory. | |
| 575 * @type {string} | |
| 576 * @private | |
| 577 */ | |
| 578 this.initCurrentDirectoryURL_ = ''; | |
| 579 | |
| 580 /** | |
| 581 * URL of entry which should be initially selected. | |
| 582 * @type {string} | |
| 583 * @private | |
| 584 */ | |
| 585 this.initSelectionURL_ = ''; | |
| 586 | |
| 587 /** | |
| 588 * The name of target entry (not URL). | |
| 589 * @type {string} | |
| 590 * @private | |
| 591 */ | |
| 592 this.initTargetName_ = ''; | |
| 593 | |
| 594 /** | |
| 595 * Data model which is used as a placefolder in inactive file list. | |
| 596 * @type {cr.ui.ArrayDataModel} | |
| 597 * @private | |
| 598 */ | |
| 599 this.emptyDataModel_ = null; | |
| 600 | |
| 601 /** | |
| 602 * Selection model which is used as a placefolder in inactive file list. | |
| 603 * @type {cr.ui.ListSelectionModel} | |
| 604 * @private | |
| 605 */ | |
| 606 this.emptySelectionModel_ = null; | |
| 607 | |
| 608 // Object.seal() has big performance/memory overhead for now, so we use | |
| 609 // Object.preventExtensions() here. crbug.com/412239. | |
| 610 Object.preventExtensions(this); | |
| 70 } | 611 } |
| 71 | 612 |
| 72 FileManager.prototype = { | 613 FileManager.prototype = { |
| 73 __proto__: cr.EventTarget.prototype, | 614 __proto__: cr.EventTarget.prototype, |
| 74 get directoryModel() { | 615 get directoryModel() { |
| 75 return this.directoryModel_; | 616 return this.directoryModel_; |
| 76 }, | 617 }, |
| 77 get directoryTree() { | 618 get directoryTree() { |
| 78 return this.directoryTree_; | 619 return this.directoryTree_; |
| 79 }, | 620 }, |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 }; | 760 }; |
| 220 | 761 |
| 221 FileManager.prototype.initPreferences_ = function(callback) { | 762 FileManager.prototype.initPreferences_ = function(callback) { |
| 222 var group = new AsyncUtil.Group(); | 763 var group = new AsyncUtil.Group(); |
| 223 | 764 |
| 224 // DRIVE preferences should be initialized before creating DirectoryModel | 765 // DRIVE preferences should be initialized before creating DirectoryModel |
| 225 // to rebuild the roots list. | 766 // to rebuild the roots list. |
| 226 group.add(this.getPreferences_.bind(this)); | 767 group.add(this.getPreferences_.bind(this)); |
| 227 | 768 |
| 228 // Get startup preferences. | 769 // Get startup preferences. |
| 229 this.viewOptions_ = {}; | |
| 230 group.add(function(done) { | 770 group.add(function(done) { |
| 231 util.platform.getPreference(this.startupPrefName_, function(value) { | 771 util.platform.getPreference(this.startupPrefName_, function(value) { |
| 232 // Load the global default options. | 772 // Load the global default options. |
| 233 try { | 773 try { |
| 234 this.viewOptions_ = JSON.parse(value); | 774 this.viewOptions_ = JSON.parse(value); |
| 235 } catch (ignore) {} | 775 } catch (ignore) {} |
| 236 // Override with window-specific options. | 776 // Override with window-specific options. |
| 237 if (window.appState && window.appState.viewOptions) { | 777 if (window.appState && window.appState.viewOptions) { |
| 238 for (var key in window.appState.viewOptions) { | 778 for (var key in window.appState.viewOptions) { |
| 239 if (window.appState.viewOptions.hasOwnProperty(key)) | 779 if (window.appState.viewOptions.hasOwnProperty(key)) |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 this.blinkSelection.bind(this)); | 966 this.blinkSelection.bind(this)); |
| 427 controller.addEventListener('source-not-found', | 967 controller.addEventListener('source-not-found', |
| 428 this.onSourceNotFound_.bind(this)); | 968 this.onSourceNotFound_.bind(this)); |
| 429 }; | 969 }; |
| 430 | 970 |
| 431 /** | 971 /** |
| 432 * Handles an error that the source entry of file operation is not found. | 972 * Handles an error that the source entry of file operation is not found. |
| 433 * @private | 973 * @private |
| 434 */ | 974 */ |
| 435 FileManager.prototype.onSourceNotFound_ = function(event) { | 975 FileManager.prototype.onSourceNotFound_ = function(event) { |
| 436 // Ensure this.sourceNotFoundErrorCount_ is integer. | |
| 437 this.sourceNotFoundErrorCount_ = ~~this.sourceNotFoundErrorCount_; | |
| 438 var item = new ProgressCenterItem(); | 976 var item = new ProgressCenterItem(); |
| 439 item.id = 'source-not-found-' + this.sourceNotFoundErrorCount_; | 977 item.id = 'source-not-found-' + this.sourceNotFoundErrorCount_; |
| 440 if (event.progressType === ProgressItemType.COPY) | 978 if (event.progressType === ProgressItemType.COPY) |
| 441 item.message = strf('COPY_SOURCE_NOT_FOUND_ERROR', event.fileName); | 979 item.message = strf('COPY_SOURCE_NOT_FOUND_ERROR', event.fileName); |
| 442 else if (event.progressType === ProgressItemType.MOVE) | 980 else if (event.progressType === ProgressItemType.MOVE) |
| 443 item.message = strf('MOVE_SOURCE_NOT_FOUND_ERROR', event.fileName); | 981 item.message = strf('MOVE_SOURCE_NOT_FOUND_ERROR', event.fileName); |
| 444 item.state = ProgressItemState.ERROR; | 982 item.state = ProgressItemState.ERROR; |
| 445 this.backgroundPage_.background.progressCenter.updateItem(item); | 983 this.backgroundPage_.background.progressCenter.updateItem(item); |
| 446 this.sourceNotFoundErrorCount_++; | 984 this.sourceNotFoundErrorCount_++; |
| 447 }; | 985 }; |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 846 if (!this.menu.length) | 1384 if (!this.menu.length) |
| 847 return; | 1385 return; |
| 848 cr.ui.ComboButton.prototype.showMenu.call(this, shouldSetFocus); | 1386 cr.ui.ComboButton.prototype.showMenu.call(this, shouldSetFocus); |
| 849 }; | 1387 }; |
| 850 this.taskItems_.addEventListener('select', | 1388 this.taskItems_.addEventListener('select', |
| 851 this.onTaskItemClicked_.bind(this)); | 1389 this.onTaskItemClicked_.bind(this)); |
| 852 | 1390 |
| 853 this.dialogDom_.ownerDocument.defaultView.addEventListener( | 1391 this.dialogDom_.ownerDocument.defaultView.addEventListener( |
| 854 'resize', this.onResize_.bind(this)); | 1392 'resize', this.onResize_.bind(this)); |
| 855 | 1393 |
| 856 this.searchBoxWrapper_ = this.ui_.searchBox.element; | |
| 857 this.searchBox_ = this.ui_.searchBox.inputElement; | 1394 this.searchBox_ = this.ui_.searchBox.inputElement; |
| 858 this.searchBox_.addEventListener( | 1395 this.searchBox_.addEventListener( |
| 859 'input', this.onSearchBoxUpdate_.bind(this)); | 1396 'input', this.onSearchBoxUpdate_.bind(this)); |
| 860 this.ui_.searchBox.clearButton.addEventListener( | 1397 this.ui_.searchBox.clearButton.addEventListener( |
| 861 'click', this.onSearchClearButtonClick_.bind(this)); | 1398 'click', this.onSearchClearButtonClick_.bind(this)); |
| 862 | 1399 |
| 863 this.lastSearchQuery_ = ''; | |
| 864 | |
| 865 this.autocompleteList_ = this.ui_.searchBox.autocompleteList; | 1400 this.autocompleteList_ = this.ui_.searchBox.autocompleteList; |
| 866 this.autocompleteList_.requestSuggestions = | 1401 this.autocompleteList_.requestSuggestions = |
| 867 this.requestAutocompleteSuggestions_.bind(this); | 1402 this.requestAutocompleteSuggestions_.bind(this); |
| 868 | 1403 |
| 869 // Instead, open the suggested item when Enter key is pressed or | 1404 // Instead, open the suggested item when Enter key is pressed or |
| 870 // mouse-clicked. | 1405 // mouse-clicked. |
| 871 this.autocompleteList_.handleEnterKeydown = function(event) { | 1406 this.autocompleteList_.handleEnterKeydown = function(event) { |
| 872 this.openAutocompleteSuggestion_(); | 1407 this.openAutocompleteSuggestion_(); |
| 873 this.lastAutocompleteQuery_ = ''; | 1408 this.lastAutocompleteQuery_ = ''; |
| 874 this.autocompleteList_.suggestions = []; | 1409 this.autocompleteList_.suggestions = []; |
| 875 }.bind(this); | 1410 }.bind(this); |
| 876 this.autocompleteList_.addEventListener('mousedown', function(event) { | 1411 this.autocompleteList_.addEventListener('mousedown', function(event) { |
| 877 this.openAutocompleteSuggestion_(); | 1412 this.openAutocompleteSuggestion_(); |
| 878 this.lastAutocompleteQuery_ = ''; | 1413 this.lastAutocompleteQuery_ = ''; |
| 879 this.autocompleteList_.suggestions = []; | 1414 this.autocompleteList_.suggestions = []; |
| 880 }.bind(this)); | 1415 }.bind(this)); |
| 881 | 1416 |
| 882 this.defaultActionMenuItem_ = | 1417 this.defaultActionMenuItem_ = |
| 883 this.dialogDom_.querySelector('#default-action'); | 1418 this.dialogDom_.querySelector('#default-action'); |
| 884 | 1419 |
| 885 this.openWithCommand_ = | 1420 this.openWithCommand_ = |
| 886 this.dialogDom_.querySelector('#open-with'); | 1421 this.dialogDom_.querySelector('#open-with'); |
| 887 | 1422 |
| 888 this.driveBuyMoreStorageCommand_ = | |
| 889 this.dialogDom_.querySelector('#drive-buy-more-space'); | |
| 890 | |
| 891 this.defaultActionMenuItem_.addEventListener('activate', | 1423 this.defaultActionMenuItem_.addEventListener('activate', |
| 892 this.dispatchSelectionAction_.bind(this)); | 1424 this.dispatchSelectionAction_.bind(this)); |
| 893 | 1425 |
| 894 this.initFileTypeFilter_(); | 1426 this.initFileTypeFilter_(); |
| 895 | 1427 |
| 896 util.addIsFocusedMethod(); | 1428 util.addIsFocusedMethod(); |
| 897 | 1429 |
| 898 // Populate the static localized strings. | 1430 // Populate the static localized strings. |
| 899 i18nTemplate.process(this.document_, loadTimeData); | 1431 i18nTemplate.process(this.document_, loadTimeData); |
| 900 | 1432 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 997 this.viewOptions_.sortDirection || 'desc'); | 1529 this.viewOptions_.sortDirection || 'desc'); |
| 998 if (this.viewOptions_.columns) { | 1530 if (this.viewOptions_.columns) { |
| 999 var cm = this.table_.columnModel; | 1531 var cm = this.table_.columnModel; |
| 1000 for (var i = 0; i < cm.totalSize; i++) { | 1532 for (var i = 0; i < cm.totalSize; i++) { |
| 1001 if (this.viewOptions_.columns[i] > 0) | 1533 if (this.viewOptions_.columns[i] > 0) |
| 1002 cm.setWidth(i, this.viewOptions_.columns[i]); | 1534 cm.setWidth(i, this.viewOptions_.columns[i]); |
| 1003 } | 1535 } |
| 1004 } | 1536 } |
| 1005 this.setListType(this.viewOptions_.listType || FileManager.ListType.DETAIL); | 1537 this.setListType(this.viewOptions_.listType || FileManager.ListType.DETAIL); |
| 1006 | 1538 |
| 1007 this.textSearchState_ = {text: '', date: new Date()}; | |
| 1008 this.closeOnUnmount_ = (this.params_.action == 'auto-open'); | 1539 this.closeOnUnmount_ = (this.params_.action == 'auto-open'); |
| 1009 | 1540 |
| 1010 if (this.closeOnUnmount_) { | 1541 if (this.closeOnUnmount_) { |
| 1011 this.volumeManager_.addEventListener('externally-unmounted', | 1542 this.volumeManager_.addEventListener('externally-unmounted', |
| 1012 this.onExternallyUnmounted_.bind(this)); | 1543 this.onExternallyUnmounted_.bind(this)); |
| 1013 } | 1544 } |
| 1014 | 1545 |
| 1015 // Update metadata to change 'Today' and 'Yesterday' dates. | 1546 // Update metadata to change 'Today' and 'Yesterday' dates. |
| 1016 var today = new Date(); | 1547 var today = new Date(); |
| 1017 today.setHours(0); | 1548 today.setHours(0); |
| (...skipping 1511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2529 | 3060 |
| 2530 if (this.commandHandler) | 3061 if (this.commandHandler) |
| 2531 this.commandHandler.updateAvailability(); | 3062 this.commandHandler.updateAvailability(); |
| 2532 this.table_.list.startBatchUpdates(); | 3063 this.table_.list.startBatchUpdates(); |
| 2533 this.grid_.startBatchUpdates(); | 3064 this.grid_.startBatchUpdates(); |
| 2534 this.scanInProgress_ = true; | 3065 this.scanInProgress_ = true; |
| 2535 | 3066 |
| 2536 this.scanUpdatedAtLeastOnceOrCompleted_ = false; | 3067 this.scanUpdatedAtLeastOnceOrCompleted_ = false; |
| 2537 if (this.scanCompletedTimer_) { | 3068 if (this.scanCompletedTimer_) { |
| 2538 clearTimeout(this.scanCompletedTimer_); | 3069 clearTimeout(this.scanCompletedTimer_); |
| 2539 this.scanCompletedTimer_ = null; | 3070 this.scanCompletedTimer_ = 0; |
| 2540 } | 3071 } |
| 2541 | 3072 |
| 2542 if (this.scanUpdatedTimer_) { | 3073 if (this.scanUpdatedTimer_) { |
| 2543 clearTimeout(this.scanUpdatedTimer_); | 3074 clearTimeout(this.scanUpdatedTimer_); |
| 2544 this.scanUpdatedTimer_ = null; | 3075 this.scanUpdatedTimer_ = 0; |
| 2545 } | 3076 } |
| 2546 | 3077 |
| 2547 if (this.spinner_.hidden) { | 3078 if (this.spinner_.hidden) { |
| 2548 this.cancelSpinnerTimeout_(); | 3079 this.cancelSpinnerTimeout_(); |
| 2549 this.showSpinnerTimeout_ = | 3080 this.showSpinnerTimeout_ = |
| 2550 setTimeout(this.showSpinner_.bind(this, true), 500); | 3081 setTimeout(this.showSpinner_.bind(this, true), 500); |
| 2551 } | 3082 } |
| 2552 }; | 3083 }; |
| 2553 | 3084 |
| 2554 /** | 3085 /** |
| 2555 * @private | 3086 * @private |
| 2556 */ | 3087 */ |
| 2557 FileManager.prototype.onScanCompleted_ = function() { | 3088 FileManager.prototype.onScanCompleted_ = function() { |
| 2558 if (!this.scanInProgress_) { | 3089 if (!this.scanInProgress_) { |
| 2559 console.error('Scan-completed event recieved. But scan is not started.'); | 3090 console.error('Scan-completed event recieved. But scan is not started.'); |
| 2560 return; | 3091 return; |
| 2561 } | 3092 } |
| 2562 | 3093 |
| 2563 if (this.commandHandler) | 3094 if (this.commandHandler) |
| 2564 this.commandHandler.updateAvailability(); | 3095 this.commandHandler.updateAvailability(); |
| 2565 this.hideSpinnerLater_(); | 3096 this.hideSpinnerLater_(); |
| 2566 | 3097 |
| 2567 if (this.scanUpdatedTimer_) { | 3098 if (this.scanUpdatedTimer_) { |
| 2568 clearTimeout(this.scanUpdatedTimer_); | 3099 clearTimeout(this.scanUpdatedTimer_); |
| 2569 this.scanUpdatedTimer_ = null; | 3100 this.scanUpdatedTimer_ = 0; |
| 2570 } | 3101 } |
| 2571 | 3102 |
| 2572 // To avoid flickering postpone updating the ui by a small amount of time. | 3103 // To avoid flickering postpone updating the ui by a small amount of time. |
| 2573 // There is a high chance, that metadata will be received within 50 ms. | 3104 // There is a high chance, that metadata will be received within 50 ms. |
| 2574 this.scanCompletedTimer_ = setTimeout(function() { | 3105 this.scanCompletedTimer_ = setTimeout(function() { |
| 2575 // Check if batch updates are already finished by onScanUpdated_(). | 3106 // Check if batch updates are already finished by onScanUpdated_(). |
| 2576 if (!this.scanUpdatedAtLeastOnceOrCompleted_) { | 3107 if (!this.scanUpdatedAtLeastOnceOrCompleted_) { |
| 2577 this.scanUpdatedAtLeastOnceOrCompleted_ = true; | 3108 this.scanUpdatedAtLeastOnceOrCompleted_ = true; |
| 2578 } | 3109 } |
| 2579 | 3110 |
| 2580 this.scanInProgress_ = false; | 3111 this.scanInProgress_ = false; |
| 2581 this.table_.list.endBatchUpdates(); | 3112 this.table_.list.endBatchUpdates(); |
| 2582 this.grid_.endBatchUpdates(); | 3113 this.grid_.endBatchUpdates(); |
| 2583 this.scanCompletedTimer_ = null; | 3114 this.scanCompletedTimer_ = 0; |
| 2584 }.bind(this), 50); | 3115 }.bind(this), 50); |
| 2585 }; | 3116 }; |
| 2586 | 3117 |
| 2587 /** | 3118 /** |
| 2588 * @private | 3119 * @private |
| 2589 */ | 3120 */ |
| 2590 FileManager.prototype.onScanUpdated_ = function() { | 3121 FileManager.prototype.onScanUpdated_ = function() { |
| 2591 if (!this.scanInProgress_) { | 3122 if (!this.scanInProgress_) { |
| 2592 console.error('Scan-updated event recieved. But scan is not started.'); | 3123 console.error('Scan-updated event recieved. But scan is not started.'); |
| 2593 return; | 3124 return; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 2605 this.hideSpinnerLater_(); | 3136 this.hideSpinnerLater_(); |
| 2606 } | 3137 } |
| 2607 | 3138 |
| 2608 // Update the UI. | 3139 // Update the UI. |
| 2609 if (this.scanInProgress_) { | 3140 if (this.scanInProgress_) { |
| 2610 this.table_.list.endBatchUpdates(); | 3141 this.table_.list.endBatchUpdates(); |
| 2611 this.grid_.endBatchUpdates(); | 3142 this.grid_.endBatchUpdates(); |
| 2612 this.table_.list.startBatchUpdates(); | 3143 this.table_.list.startBatchUpdates(); |
| 2613 this.grid_.startBatchUpdates(); | 3144 this.grid_.startBatchUpdates(); |
| 2614 } | 3145 } |
| 2615 this.scanUpdatedTimer_ = null; | 3146 this.scanUpdatedTimer_ = 0; |
| 2616 }.bind(this), 200); | 3147 }.bind(this), 200); |
| 2617 }; | 3148 }; |
| 2618 | 3149 |
| 2619 /** | 3150 /** |
| 2620 * @private | 3151 * @private |
| 2621 */ | 3152 */ |
| 2622 FileManager.prototype.onScanCancelled_ = function() { | 3153 FileManager.prototype.onScanCancelled_ = function() { |
| 2623 if (!this.scanInProgress_) { | 3154 if (!this.scanInProgress_) { |
| 2624 console.error('Scan-cancelled event recieved. But scan is not started.'); | 3155 console.error('Scan-cancelled event recieved. But scan is not started.'); |
| 2625 return; | 3156 return; |
| 2626 } | 3157 } |
| 2627 | 3158 |
| 2628 if (this.commandHandler) | 3159 if (this.commandHandler) |
| 2629 this.commandHandler.updateAvailability(); | 3160 this.commandHandler.updateAvailability(); |
| 2630 this.hideSpinnerLater_(); | 3161 this.hideSpinnerLater_(); |
| 2631 if (this.scanCompletedTimer_) { | 3162 if (this.scanCompletedTimer_) { |
| 2632 clearTimeout(this.scanCompletedTimer_); | 3163 clearTimeout(this.scanCompletedTimer_); |
| 2633 this.scanCompletedTimer_ = null; | 3164 this.scanCompletedTimer_ = 0; |
| 2634 } | 3165 } |
| 2635 if (this.scanUpdatedTimer_) { | 3166 if (this.scanUpdatedTimer_) { |
| 2636 clearTimeout(this.scanUpdatedTimer_); | 3167 clearTimeout(this.scanUpdatedTimer_); |
| 2637 this.scanUpdatedTimer_ = null; | 3168 this.scanUpdatedTimer_ = 0; |
| 2638 } | 3169 } |
| 2639 // Finish unfinished batch updates. | 3170 // Finish unfinished batch updates. |
| 2640 if (!this.scanUpdatedAtLeastOnceOrCompleted_) { | 3171 if (!this.scanUpdatedAtLeastOnceOrCompleted_) { |
| 2641 this.scanUpdatedAtLeastOnceOrCompleted_ = true; | 3172 this.scanUpdatedAtLeastOnceOrCompleted_ = true; |
| 2642 } | 3173 } |
| 2643 | 3174 |
| 2644 this.scanInProgress_ = false; | 3175 this.scanInProgress_ = false; |
| 2645 this.table_.list.endBatchUpdates(); | 3176 this.table_.list.endBatchUpdates(); |
| 2646 this.grid_.endBatchUpdates(); | 3177 this.grid_.endBatchUpdates(); |
| 2647 }; | 3178 }; |
| 2648 | 3179 |
| 2649 /** | 3180 /** |
| 2650 * Handle the 'rescan-completed' from the DirectoryModel. | 3181 * Handle the 'rescan-completed' from the DirectoryModel. |
| 2651 * @private | 3182 * @private |
| 2652 */ | 3183 */ |
| 2653 FileManager.prototype.onRescanCompleted_ = function() { | 3184 FileManager.prototype.onRescanCompleted_ = function() { |
| 2654 this.selectionHandler_.onFileSelectionChanged(); | 3185 this.selectionHandler_.onFileSelectionChanged(); |
| 2655 }; | 3186 }; |
| 2656 | 3187 |
| 2657 /** | 3188 /** |
| 2658 * @private | 3189 * @private |
| 2659 */ | 3190 */ |
| 2660 FileManager.prototype.cancelSpinnerTimeout_ = function() { | 3191 FileManager.prototype.cancelSpinnerTimeout_ = function() { |
| 2661 if (this.showSpinnerTimeout_) { | 3192 if (this.showSpinnerTimeout_) { |
| 2662 clearTimeout(this.showSpinnerTimeout_); | 3193 clearTimeout(this.showSpinnerTimeout_); |
| 2663 this.showSpinnerTimeout_ = null; | 3194 this.showSpinnerTimeout_ = 0; |
| 2664 } | 3195 } |
| 2665 }; | 3196 }; |
| 2666 | 3197 |
| 2667 /** | 3198 /** |
| 2668 * @private | 3199 * @private |
| 2669 */ | 3200 */ |
| 2670 FileManager.prototype.hideSpinnerLater_ = function() { | 3201 FileManager.prototype.hideSpinnerLater_ = function() { |
| 2671 this.cancelSpinnerTimeout_(); | 3202 this.cancelSpinnerTimeout_(); |
| 2672 this.showSpinner_(false); | 3203 this.showSpinner_(false); |
| 2673 }; | 3204 }; |
| (...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3603 /** | 4134 /** |
| 3604 * Retrieve the preferences of the files.app. This method caches the result | 4135 * Retrieve the preferences of the files.app. This method caches the result |
| 3605 * and returns it unless opt_update is true. | 4136 * and returns it unless opt_update is true. |
| 3606 * @param {function(Object.<string, *>)} callback Callback to get the | 4137 * @param {function(Object.<string, *>)} callback Callback to get the |
| 3607 * preference. | 4138 * preference. |
| 3608 * @param {boolean=} opt_update If is's true, don't use the cache and | 4139 * @param {boolean=} opt_update If is's true, don't use the cache and |
| 3609 * retrieve latest preference. Default is false. | 4140 * retrieve latest preference. Default is false. |
| 3610 * @private | 4141 * @private |
| 3611 */ | 4142 */ |
| 3612 FileManager.prototype.getPreferences_ = function(callback, opt_update) { | 4143 FileManager.prototype.getPreferences_ = function(callback, opt_update) { |
| 3613 if (!opt_update && this.preferences_ !== undefined) { | 4144 if (!opt_update && this.preferences_ !== null) { |
| 3614 callback(this.preferences_); | 4145 callback(this.preferences_); |
| 3615 return; | 4146 return; |
| 3616 } | 4147 } |
| 3617 | 4148 |
| 3618 chrome.fileBrowserPrivate.getPreferences(function(prefs) { | 4149 chrome.fileBrowserPrivate.getPreferences(function(prefs) { |
| 3619 this.preferences_ = prefs; | 4150 this.preferences_ = prefs; |
| 3620 callback(prefs); | 4151 callback(prefs); |
| 3621 }.bind(this)); | 4152 }.bind(this)); |
| 3622 }; | 4153 }; |
| 3623 })(); | 4154 })(); |
| OLD | NEW |