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 /** | 5 /** |
6 * TODO(dzvorygin): Here we use this hack, since 'hidden' is standard | 6 * TODO(dzvorygin): Here we use this hack, since 'hidden' is standard |
7 * attribute and we can't use it's setter as usual. | 7 * attribute and we can't use it's setter as usual. |
8 * @param {boolean} value New value of hidden property. | 8 * @param {boolean} value New value of hidden property. |
9 */ | 9 */ |
10 cr.ui.Command.prototype.setHidden = function(value) { | 10 cr.ui.Command.prototype.setHidden = function(value) { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 CommandUtil.getPinTargetEntries = function() { | 126 CommandUtil.getPinTargetEntries = function() { |
127 // If current directory is not on drive, no entry can be pinned. | 127 // If current directory is not on drive, no entry can be pinned. |
128 if (!fileManager.isOnDrive()) | 128 if (!fileManager.isOnDrive()) |
129 return []; | 129 return []; |
130 | 130 |
131 var hasDirectory = false; | 131 var hasDirectory = false; |
132 var results = fileManager.getSelection().entries.filter(function(entry) { | 132 var results = fileManager.getSelection().entries.filter(function(entry) { |
133 hasDirectory = hasDirectory || entry.isDirectory; | 133 hasDirectory = hasDirectory || entry.isDirectory; |
134 if (!entry || hasDirectory) | 134 if (!entry || hasDirectory) |
135 return false; | 135 return false; |
136 var metadata = fileManager.getFileSystemMetadata().getCache( | 136 var metadata = fileManager.getMetadataModel().getCache( |
137 [entry], ['hosted', 'pinned'])[0]; | 137 [entry], ['hosted', 'pinned'])[0]; |
138 if (metadata.hosted) | 138 if (metadata.hosted) |
139 return false; | 139 return false; |
140 entry.pinned = metadata.pinned; | 140 entry.pinned = metadata.pinned; |
141 return true; | 141 return true; |
142 }); | 142 }); |
143 return hasDirectory ? [] : results; | 143 return hasDirectory ? [] : results; |
144 }; | 144 }; |
145 | 145 |
146 /** | 146 /** |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 * @param {!FileManager} fileManager | 885 * @param {!FileManager} fileManager |
886 */ | 886 */ |
887 execute: function(event, fileManager) { | 887 execute: function(event, fileManager) { |
888 var pin = !event.command.checked; | 888 var pin = !event.command.checked; |
889 event.command.checked = pin; | 889 event.command.checked = pin; |
890 var entries = CommandUtil.getPinTargetEntries(); | 890 var entries = CommandUtil.getPinTargetEntries(); |
891 if (entries.length == 0) | 891 if (entries.length == 0) |
892 return; | 892 return; |
893 var currentEntry; | 893 var currentEntry; |
894 var error = false; | 894 var error = false; |
895 var fileSystemMetadata = fileManager.getFileSystemMetadata(); | 895 var metadataModel = fileManager.getMetadataModel(); |
896 var steps = { | 896 var steps = { |
897 // Pick an entry and pin it. | 897 // Pick an entry and pin it. |
898 start: function() { | 898 start: function() { |
899 // Check if all the entries are pinned or not. | 899 // Check if all the entries are pinned or not. |
900 if (entries.length == 0) | 900 if (entries.length == 0) |
901 return; | 901 return; |
902 currentEntry = entries.shift(); | 902 currentEntry = entries.shift(); |
903 chrome.fileManagerPrivate.pinDriveFile( | 903 chrome.fileManagerPrivate.pinDriveFile( |
904 currentEntry.toURL(), | 904 currentEntry.toURL(), |
905 pin, | 905 pin, |
906 steps.entryPinned); | 906 steps.entryPinned); |
907 }, | 907 }, |
908 | 908 |
909 // Check the result of pinning | 909 // Check the result of pinning |
910 entryPinned: function() { | 910 entryPinned: function() { |
911 // Convert to boolean. | 911 // Convert to boolean. |
912 error = !!chrome.runtime.lastError; | 912 error = !!chrome.runtime.lastError; |
913 if (error && pin) { | 913 if (error && pin) { |
914 fileSystemMetadata.get([currentEntry], ['size']).then( | 914 metadataModel.get([currentEntry], ['size']).then( |
915 function(results) { | 915 function(results) { |
916 steps.showError(results[0].size); | 916 steps.showError(results[0].size); |
917 }); | 917 }); |
918 return; | 918 return; |
919 } | 919 } |
920 fileSystemMetadata.notifyEntriesChanged([currentEntry]); | 920 metadataModel.notifyEntriesChanged([currentEntry]); |
921 fileSystemMetadata.get([currentEntry], ['pinned']).then(steps.updateUI); | 921 metadataModel.get([currentEntry], ['pinned']).then(steps.updateUI); |
922 }, | 922 }, |
923 | 923 |
924 // Update the user interface according to the cache state. | 924 // Update the user interface according to the cache state. |
925 updateUI: function() { | 925 updateUI: function() { |
926 fileManager.ui.listContainer.currentView.updateListItemsMetadata( | 926 fileManager.ui.listContainer.currentView.updateListItemsMetadata( |
927 'external', [currentEntry]); | 927 'external', [currentEntry]); |
928 if (!error) | 928 if (!error) |
929 steps.start(); | 929 steps.start(); |
930 }, | 930 }, |
931 | 931 |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 CommandHandler.COMMANDS_['inspect-background'] = /** @type {Command} */ ({ | 1215 CommandHandler.COMMANDS_['inspect-background'] = /** @type {Command} */ ({ |
1216 /** | 1216 /** |
1217 * @param {!Event} event Command event. | 1217 * @param {!Event} event Command event. |
1218 * @param {!FileManager} fileManager FileManager to use. | 1218 * @param {!FileManager} fileManager FileManager to use. |
1219 */ | 1219 */ |
1220 execute: function(event, fileManager) { | 1220 execute: function(event, fileManager) { |
1221 chrome.fileManagerPrivate.openInspector('background'); | 1221 chrome.fileManagerPrivate.openInspector('background'); |
1222 }, | 1222 }, |
1223 canExecute: CommandUtil.canExecuteAlways | 1223 canExecute: CommandUtil.canExecuteAlways |
1224 }); | 1224 }); |
OLD | NEW |