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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 // Optional list of file types. | 56 // Optional list of file types. |
| 57 this.fileTypes_ = this.params_.typeList || []; | 57 this.fileTypes_ = this.params_.typeList || []; |
| 58 metrics.recordEnum('Create', this.dialogType, | 58 metrics.recordEnum('Create', this.dialogType, |
| 59 [DialogType.SELECT_FOLDER, | 59 [DialogType.SELECT_FOLDER, |
| 60 DialogType.SELECT_SAVEAS_FILE, | 60 DialogType.SELECT_SAVEAS_FILE, |
| 61 DialogType.SELECT_OPEN_FILE, | 61 DialogType.SELECT_OPEN_FILE, |
| 62 DialogType.SELECT_OPEN_MULTI_FILE, | 62 DialogType.SELECT_OPEN_MULTI_FILE, |
| 63 DialogType.FULL_PAGE]); | 63 DialogType.FULL_PAGE]); |
| 64 | 64 |
| 65 this.selectionHandler_ = null; | 65 this.selectionHandler_ = null; |
| 66 this.ctrlKeyPressed_ = false; | |
| 66 | 67 |
| 67 this.metadataCache_ = MetadataCache.createFull(); | 68 this.metadataCache_ = MetadataCache.createFull(); |
| 68 this.volumeManager_ = VolumeManager.getInstance(); | 69 this.volumeManager_ = VolumeManager.getInstance(); |
| 69 this.initFileSystem_(); | 70 this.initFileSystem_(); |
| 70 this.initDom_(); | 71 this.initDom_(); |
| 71 this.initDialogType_(); | 72 this.initDialogType_(); |
| 72 } | 73 } |
| 73 | 74 |
| 74 /** | 75 /** |
| 75 * Maximum delay in milliseconds for updating thumbnails in the bottom panel | 76 * Maximum delay in milliseconds for updating thumbnails in the bottom panel |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 this.textContextMenu_ = | 541 this.textContextMenu_ = |
| 541 this.dialogDom_.querySelector('#text-context-menu'); | 542 this.dialogDom_.querySelector('#text-context-menu'); |
| 542 cr.ui.Menu.decorate(this.textContextMenu_); | 543 cr.ui.Menu.decorate(this.textContextMenu_); |
| 543 | 544 |
| 544 this.gearButton_ = this.dialogDom_.querySelector('#gear-button'); | 545 this.gearButton_ = this.dialogDom_.querySelector('#gear-button'); |
| 545 this.gearButton_.addEventListener('menushow', | 546 this.gearButton_.addEventListener('menushow', |
| 546 this.refreshRemainingSpace_.bind(this, | 547 this.refreshRemainingSpace_.bind(this, |
| 547 false /* Without loading caption. */)); | 548 false /* Without loading caption. */)); |
| 548 cr.ui.decorate(this.gearButton_, cr.ui.MenuButton); | 549 cr.ui.decorate(this.gearButton_, cr.ui.MenuButton); |
| 549 | 550 |
| 551 this.dialogDom_.querySelector('#gear-menu').menuItemSelector = | |
| 552 'menuitem, hr'; | |
| 553 | |
| 550 this.syncButton.checkable = true; | 554 this.syncButton.checkable = true; |
| 551 this.hostedButton.checkable = true; | 555 this.hostedButton.checkable = true; |
| 552 }; | 556 }; |
| 553 | 557 |
| 554 /** | 558 /** |
| 555 * One-time initialization of commands. | 559 * One-time initialization of commands. |
| 556 * @private | 560 * @private |
| 557 */ | 561 */ |
| 558 FileManager.prototype.initCommands_ = function() { | 562 FileManager.prototype.initCommands_ = function() { |
| 559 var commandButtons = this.dialogDom_.querySelectorAll('button[command]'); | 563 var commandButtons = this.dialogDom_.querySelectorAll('button[command]'); |
| (...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1611 /** | 1615 /** |
| 1612 * @return {boolean} True if the current directory content is from Google | 1616 * @return {boolean} True if the current directory content is from Google |
| 1613 * Drive. | 1617 * Drive. |
| 1614 */ | 1618 */ |
| 1615 FileManager.prototype.isOnDrive = function() { | 1619 FileManager.prototype.isOnDrive = function() { |
| 1616 return this.directoryModel_.getCurrentRootType() === RootType.DRIVE || | 1620 return this.directoryModel_.getCurrentRootType() === RootType.DRIVE || |
| 1617 this.directoryModel_.getCurrentRootType() === RootType.DRIVE_OFFLINE; | 1621 this.directoryModel_.getCurrentRootType() === RootType.DRIVE_OFFLINE; |
| 1618 }; | 1622 }; |
| 1619 | 1623 |
| 1620 /** | 1624 /** |
| 1625 * @return {boolean} True if the ctrl key is pressed now. | |
| 1626 */ | |
| 1627 FileManager.prototype.isCtrlKeyPressed = function() { | |
| 1628 return this.ctrlKeyPressed_; | |
| 1629 }; | |
| 1630 | |
| 1631 /** | |
| 1621 * @return {boolean} True if the "Available offline" column should be shown in | 1632 * @return {boolean} True if the "Available offline" column should be shown in |
| 1622 * the table layout. | 1633 * the table layout. |
| 1623 */ | 1634 */ |
| 1624 FileManager.prototype.shouldShowOfflineColumn = function() { | 1635 FileManager.prototype.shouldShowOfflineColumn = function() { |
| 1625 return this.directoryModel_.getCurrentRootType() === RootType.DRIVE; | 1636 return this.directoryModel_.getCurrentRootType() === RootType.DRIVE; |
| 1626 }; | 1637 }; |
| 1627 | 1638 |
| 1628 /** | 1639 /** |
| 1629 * Overrides default handling for clicks on hyperlinks. | 1640 * Overrides default handling for clicks on hyperlinks. |
| 1630 * Opens them in a separate tab and if it's an open/save dialog | 1641 * Opens them in a separate tab and if it's an open/save dialog |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2022 | 2033 |
| 2023 /** | 2034 /** |
| 2024 * Updates search box value when directory gets changed. | 2035 * Updates search box value when directory gets changed. |
| 2025 * @private | 2036 * @private |
| 2026 */ | 2037 */ |
| 2027 FileManager.prototype.updateSearchBoxOnDirChange_ = function() { | 2038 FileManager.prototype.updateSearchBoxOnDirChange_ = function() { |
| 2028 if (!this.searchBox_.disabled) | 2039 if (!this.searchBox_.disabled) |
| 2029 this.searchBox_.value = ''; | 2040 this.searchBox_.value = ''; |
| 2030 }; | 2041 }; |
| 2031 | 2042 |
| 2032 /** | 2043 /** |
|
mtomasz
2013/04/09 05:44:58
This seems to be unused.
hirono
2013/04/09 06:01:04
'updateGearMenu_' is used to update remaining spac
mtomasz
2013/04/09 06:11:39
You're right!
| |
| 2033 * Update the gear menu. | 2044 * Update the gear menu. |
| 2034 * @private | 2045 * @private |
| 2035 */ | 2046 */ |
| 2036 FileManager.prototype.updateGearMenu_ = function() { | 2047 FileManager.prototype.updateGearMenu_ = function() { |
| 2037 this.syncButton.hidden = !this.isOnDrive(); | 2048 this.syncButton.hidden = !this.isOnDrive(); |
| 2038 this.hostedButton.hidden = !this.isOnDrive(); | 2049 this.hostedButton.hidden = !this.isOnDrive(); |
| 2050 this.document_.getElementById('drive-separator').hidden = | |
| 2051 !this.isOnDrive(); | |
| 2039 | 2052 |
| 2040 // If volume has changed, then fetch remaining space data. | 2053 // If volume has changed, then fetch remaining space data. |
| 2041 if (this.previousRootUrl_ != this.directoryModel_.getCurrentRootUrl()) | 2054 if (this.previousRootUrl_ != this.directoryModel_.getCurrentRootUrl()) |
| 2042 this.refreshRemainingSpace_(true); // Show loading caption. | 2055 this.refreshRemainingSpace_(true); // Show loading caption. |
| 2043 | 2056 |
| 2044 this.previousRootUrl_ = this.directoryModel_.getCurrentRootUrl(); | 2057 this.previousRootUrl_ = this.directoryModel_.getCurrentRootUrl(); |
| 2045 }; | 2058 }; |
| 2046 | 2059 |
| 2047 /** | 2060 /** |
| 2048 * Refreshes space info of the current volume. | 2061 * Refreshes space info of the current volume. |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2509 * @private | 2522 * @private |
| 2510 */ | 2523 */ |
| 2511 FileManager.prototype.onKeyDown_ = function(event) { | 2524 FileManager.prototype.onKeyDown_ = function(event) { |
| 2512 if (event.srcElement === this.renameInput_) { | 2525 if (event.srcElement === this.renameInput_) { |
| 2513 // Ignore keydown handler in the rename input box. | 2526 // Ignore keydown handler in the rename input box. |
| 2514 return; | 2527 return; |
| 2515 } | 2528 } |
| 2516 | 2529 |
| 2517 switch (util.getKeyModifiers(event) + event.keyCode) { | 2530 switch (util.getKeyModifiers(event) + event.keyCode) { |
| 2518 case 'Ctrl-17': // Ctrl => Show hidden setting | 2531 case 'Ctrl-17': // Ctrl => Show hidden setting |
| 2519 this.dialogDom_.setAttribute('ctrl-pressing', 'true'); | 2532 this.setCtrlKeyPressed_(true); |
| 2520 return; | 2533 return; |
| 2521 | 2534 |
| 2522 case 'Ctrl-190': // Ctrl-. => Toggle filter files. | 2535 case 'Ctrl-190': // Ctrl-. => Toggle filter files. |
| 2523 this.fileFilter_.setFilterHidden( | 2536 this.fileFilter_.setFilterHidden( |
| 2524 !this.fileFilter_.isFilterHiddenOn()); | 2537 !this.fileFilter_.isFilterHiddenOn()); |
| 2525 event.preventDefault(); | 2538 event.preventDefault(); |
| 2526 return; | 2539 return; |
| 2527 | 2540 |
| 2528 case '27': // Escape => Cancel dialog. | 2541 case '27': // Escape => Cancel dialog. |
| 2529 if (this.copyManager_ && | 2542 if (this.copyManager_ && |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 2554 * @private | 2567 * @private |
| 2555 */ | 2568 */ |
| 2556 FileManager.prototype.onKeyUp_ = function(event) { | 2569 FileManager.prototype.onKeyUp_ = function(event) { |
| 2557 if (event.srcElement === this.renameInput_) { | 2570 if (event.srcElement === this.renameInput_) { |
| 2558 // Ignore keydown handler in the rename input box. | 2571 // Ignore keydown handler in the rename input box. |
| 2559 return; | 2572 return; |
| 2560 } | 2573 } |
| 2561 | 2574 |
| 2562 switch (util.getKeyModifiers(event) + event.keyCode) { | 2575 switch (util.getKeyModifiers(event) + event.keyCode) { |
| 2563 case '17': // Ctrl => Hide hidden setting | 2576 case '17': // Ctrl => Hide hidden setting |
| 2564 this.dialogDom_.removeAttribute('ctrl-pressing'); | 2577 this.setCtrlKeyPressed_(false); |
| 2565 return; | 2578 return; |
| 2566 } | 2579 } |
| 2567 }; | 2580 }; |
| 2568 | 2581 |
| 2569 /** | 2582 /** |
| 2570 * KeyDown event handler for the div#list-container element. | 2583 * KeyDown event handler for the div#list-container element. |
| 2571 * @param {Event} event Key event. | 2584 * @param {Event} event Key event. |
| 2572 * @private | 2585 * @private |
| 2573 */ | 2586 */ |
| 2574 FileManager.prototype.onListKeyDown_ = function(event) { | 2587 FileManager.prototype.onListKeyDown_ = function(event) { |
| (...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3402 if (!opt_update && this.preferences_ !== undefined) { | 3415 if (!opt_update && this.preferences_ !== undefined) { |
| 3403 callback(this.preferences_); | 3416 callback(this.preferences_); |
| 3404 return; | 3417 return; |
| 3405 } | 3418 } |
| 3406 | 3419 |
| 3407 chrome.fileBrowserPrivate.getPreferences(function(prefs) { | 3420 chrome.fileBrowserPrivate.getPreferences(function(prefs) { |
| 3408 this.preferences_ = prefs; | 3421 this.preferences_ = prefs; |
| 3409 callback(prefs); | 3422 callback(prefs); |
| 3410 }.bind(this)); | 3423 }.bind(this)); |
| 3411 }; | 3424 }; |
| 3425 | |
| 3426 /** | |
| 3427 * Set the flag expressing whether the ctrl key is pressed or not. | |
| 3428 * @param {boolean} flag New value of the flag | |
| 3429 * @private | |
| 3430 */ | |
| 3431 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { | |
| 3432 this.ctrlKeyPressed_ = flag; | |
|
mtomasz
2013/04/09 05:44:58
Can we use querySelector instead for consistency?
hirono
2013/04/09 06:01:04
I think getElementById is a little faster than que
mtomasz
2013/04/09 06:11:39
It is faster (http://jsperf.com/queryselector-vs-g
hirono
2013/04/09 06:43:13
Done.
| |
| 3433 this.document_.getElementById('drive-clear-local-cache').canExecuteChange(); | |
| 3434 this.document_.getElementById('drive-reload').canExecuteChange(); | |
| 3435 }; | |
| 3412 })(); | 3436 })(); |
| OLD | NEW |