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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 this.textContextMenu_ = | 547 this.textContextMenu_ = |
547 this.dialogDom_.querySelector('#text-context-menu'); | 548 this.dialogDom_.querySelector('#text-context-menu'); |
548 cr.ui.Menu.decorate(this.textContextMenu_); | 549 cr.ui.Menu.decorate(this.textContextMenu_); |
549 | 550 |
550 this.gearButton_ = this.dialogDom_.querySelector('#gear-button'); | 551 this.gearButton_ = this.dialogDom_.querySelector('#gear-button'); |
551 this.gearButton_.addEventListener('menushow', | 552 this.gearButton_.addEventListener('menushow', |
552 this.refreshRemainingSpace_.bind(this, | 553 this.refreshRemainingSpace_.bind(this, |
553 false /* Without loading caption. */)); | 554 false /* Without loading caption. */)); |
554 cr.ui.decorate(this.gearButton_, cr.ui.MenuButton); | 555 cr.ui.decorate(this.gearButton_, cr.ui.MenuButton); |
555 | 556 |
| 557 this.dialogDom_.querySelector('#gear-menu').menuItemSelector = |
| 558 'menuitem, hr'; |
| 559 |
556 this.syncButton.checkable = true; | 560 this.syncButton.checkable = true; |
557 this.hostedButton.checkable = true; | 561 this.hostedButton.checkable = true; |
558 }; | 562 }; |
559 | 563 |
560 /** | 564 /** |
561 * One-time initialization of commands. | 565 * One-time initialization of commands. |
562 * @private | 566 * @private |
563 */ | 567 */ |
564 FileManager.prototype.initCommands_ = function() { | 568 FileManager.prototype.initCommands_ = function() { |
565 var commandButtons = this.dialogDom_.querySelectorAll('button[command]'); | 569 var commandButtons = this.dialogDom_.querySelectorAll('button[command]'); |
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1625 /** | 1629 /** |
1626 * @return {boolean} True if the current directory content is from Google | 1630 * @return {boolean} True if the current directory content is from Google |
1627 * Drive. | 1631 * Drive. |
1628 */ | 1632 */ |
1629 FileManager.prototype.isOnDrive = function() { | 1633 FileManager.prototype.isOnDrive = function() { |
1630 return this.directoryModel_.getCurrentRootType() === RootType.DRIVE || | 1634 return this.directoryModel_.getCurrentRootType() === RootType.DRIVE || |
1631 this.directoryModel_.getCurrentRootType() === RootType.DRIVE_OFFLINE; | 1635 this.directoryModel_.getCurrentRootType() === RootType.DRIVE_OFFLINE; |
1632 }; | 1636 }; |
1633 | 1637 |
1634 /** | 1638 /** |
| 1639 * @return {boolean} True if the ctrl key is pressed now. |
| 1640 */ |
| 1641 FileManager.prototype.isCtrlKeyPressed = function() { |
| 1642 return this.ctrlKeyPressed_; |
| 1643 }; |
| 1644 |
| 1645 /** |
1635 * @return {boolean} True if the "Available offline" column should be shown in | 1646 * @return {boolean} True if the "Available offline" column should be shown in |
1636 * the table layout. | 1647 * the table layout. |
1637 */ | 1648 */ |
1638 FileManager.prototype.shouldShowOfflineColumn = function() { | 1649 FileManager.prototype.shouldShowOfflineColumn = function() { |
1639 return this.directoryModel_.getCurrentRootType() === RootType.DRIVE; | 1650 return this.directoryModel_.getCurrentRootType() === RootType.DRIVE; |
1640 }; | 1651 }; |
1641 | 1652 |
1642 /** | 1653 /** |
1643 * Overrides default handling for clicks on hyperlinks. | 1654 * Overrides default handling for clicks on hyperlinks. |
1644 * Opens them in a separate tab and if it's an open/save dialog | 1655 * Opens them in a separate tab and if it's an open/save dialog |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2043 this.searchBox_.value = ''; | 2054 this.searchBox_.value = ''; |
2044 }; | 2055 }; |
2045 | 2056 |
2046 /** | 2057 /** |
2047 * Update the gear menu. | 2058 * Update the gear menu. |
2048 * @private | 2059 * @private |
2049 */ | 2060 */ |
2050 FileManager.prototype.updateGearMenu_ = function() { | 2061 FileManager.prototype.updateGearMenu_ = function() { |
2051 this.syncButton.hidden = !this.isOnDrive(); | 2062 this.syncButton.hidden = !this.isOnDrive(); |
2052 this.hostedButton.hidden = !this.isOnDrive(); | 2063 this.hostedButton.hidden = !this.isOnDrive(); |
| 2064 this.document_.getElementById('drive-separator').hidden = |
| 2065 !this.isOnDrive(); |
2053 | 2066 |
2054 // If volume has changed, then fetch remaining space data. | 2067 // If volume has changed, then fetch remaining space data. |
2055 if (this.previousRootUrl_ != this.directoryModel_.getCurrentRootUrl()) | 2068 if (this.previousRootUrl_ != this.directoryModel_.getCurrentRootUrl()) |
2056 this.refreshRemainingSpace_(true); // Show loading caption. | 2069 this.refreshRemainingSpace_(true); // Show loading caption. |
2057 | 2070 |
2058 this.previousRootUrl_ = this.directoryModel_.getCurrentRootUrl(); | 2071 this.previousRootUrl_ = this.directoryModel_.getCurrentRootUrl(); |
2059 }; | 2072 }; |
2060 | 2073 |
2061 /** | 2074 /** |
2062 * Refreshes space info of the current volume. | 2075 * Refreshes space info of the current volume. |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2523 * @private | 2536 * @private |
2524 */ | 2537 */ |
2525 FileManager.prototype.onKeyDown_ = function(event) { | 2538 FileManager.prototype.onKeyDown_ = function(event) { |
2526 if (event.srcElement === this.renameInput_) { | 2539 if (event.srcElement === this.renameInput_) { |
2527 // Ignore keydown handler in the rename input box. | 2540 // Ignore keydown handler in the rename input box. |
2528 return; | 2541 return; |
2529 } | 2542 } |
2530 | 2543 |
2531 switch (util.getKeyModifiers(event) + event.keyCode) { | 2544 switch (util.getKeyModifiers(event) + event.keyCode) { |
2532 case 'Ctrl-17': // Ctrl => Show hidden setting | 2545 case 'Ctrl-17': // Ctrl => Show hidden setting |
2533 this.dialogDom_.setAttribute('ctrl-pressing', 'true'); | 2546 this.setCtrlKeyPressed_(true); |
2534 return; | 2547 return; |
2535 | 2548 |
2536 case 'Ctrl-190': // Ctrl-. => Toggle filter files. | 2549 case 'Ctrl-190': // Ctrl-. => Toggle filter files. |
2537 this.fileFilter_.setFilterHidden( | 2550 this.fileFilter_.setFilterHidden( |
2538 !this.fileFilter_.isFilterHiddenOn()); | 2551 !this.fileFilter_.isFilterHiddenOn()); |
2539 event.preventDefault(); | 2552 event.preventDefault(); |
2540 return; | 2553 return; |
2541 | 2554 |
2542 case '27': // Escape => Cancel dialog. | 2555 case '27': // Escape => Cancel dialog. |
2543 if (this.copyManager_ && | 2556 if (this.copyManager_ && |
(...skipping 24 matching lines...) Expand all Loading... |
2568 * @private | 2581 * @private |
2569 */ | 2582 */ |
2570 FileManager.prototype.onKeyUp_ = function(event) { | 2583 FileManager.prototype.onKeyUp_ = function(event) { |
2571 if (event.srcElement === this.renameInput_) { | 2584 if (event.srcElement === this.renameInput_) { |
2572 // Ignore keydown handler in the rename input box. | 2585 // Ignore keydown handler in the rename input box. |
2573 return; | 2586 return; |
2574 } | 2587 } |
2575 | 2588 |
2576 switch (util.getKeyModifiers(event) + event.keyCode) { | 2589 switch (util.getKeyModifiers(event) + event.keyCode) { |
2577 case '17': // Ctrl => Hide hidden setting | 2590 case '17': // Ctrl => Hide hidden setting |
2578 this.dialogDom_.removeAttribute('ctrl-pressing'); | 2591 this.setCtrlKeyPressed_(false); |
2579 return; | 2592 return; |
2580 } | 2593 } |
2581 }; | 2594 }; |
2582 | 2595 |
2583 /** | 2596 /** |
2584 * KeyDown event handler for the div#list-container element. | 2597 * KeyDown event handler for the div#list-container element. |
2585 * @param {Event} event Key event. | 2598 * @param {Event} event Key event. |
2586 * @private | 2599 * @private |
2587 */ | 2600 */ |
2588 FileManager.prototype.onListKeyDown_ = function(event) { | 2601 FileManager.prototype.onListKeyDown_ = function(event) { |
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3443 if (!opt_update && this.preferences_ !== undefined) { | 3456 if (!opt_update && this.preferences_ !== undefined) { |
3444 callback(this.preferences_); | 3457 callback(this.preferences_); |
3445 return; | 3458 return; |
3446 } | 3459 } |
3447 | 3460 |
3448 chrome.fileBrowserPrivate.getPreferences(function(prefs) { | 3461 chrome.fileBrowserPrivate.getPreferences(function(prefs) { |
3449 this.preferences_ = prefs; | 3462 this.preferences_ = prefs; |
3450 callback(prefs); | 3463 callback(prefs); |
3451 }.bind(this)); | 3464 }.bind(this)); |
3452 }; | 3465 }; |
| 3466 |
| 3467 /** |
| 3468 * Set the flag expressing whether the ctrl key is pressed or not. |
| 3469 * @param {boolean} flag New value of the flag |
| 3470 * @private |
| 3471 */ |
| 3472 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { |
| 3473 this.ctrlKeyPressed_ = flag; |
| 3474 this.document_.querySelector('#drive-clear-local-cache').canExecuteChange(); |
| 3475 this.document_.querySelector('#drive-reload').canExecuteChange(); |
| 3476 }; |
3453 })(); | 3477 })(); |
OLD | NEW |