| 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 * Scanner of the entries. | 6 * Scanner of the entries. |
| 7 * @constructor | 7 * @constructor |
| 8 */ | 8 */ |
| 9 function ContentScanner() { | 9 function ContentScanner() { |
| 10 this.cancelled_ = false; | 10 this.cancelled_ = false; |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 | 250 |
| 251 var reader = entry.createReader(); | 251 var reader = entry.createReader(); |
| 252 reader.readEntries(onSuccess, onError); | 252 reader.readEntries(onSuccess, onError); |
| 253 }.bind(this); | 253 }.bind(this); |
| 254 | 254 |
| 255 processEntry(this.entry_); | 255 processEntry(this.entry_); |
| 256 }; | 256 }; |
| 257 | 257 |
| 258 /** | 258 /** |
| 259 * Scanner of the entries for the metadata search on Drive File System. | 259 * Scanner of the entries for the metadata search on Drive File System. |
| 260 * @param {!DriveMetadataSearchContentScanner.SearchType} searchType The option | 260 * @param {chrome.fileManagerPrivate.SearchType} searchType The option |
| 261 * of the search. | 261 * of the search. |
| 262 * @constructor | 262 * @constructor |
| 263 * @extends {ContentScanner} | 263 * @extends {ContentScanner} |
| 264 */ | 264 */ |
| 265 function DriveMetadataSearchContentScanner(searchType) { | 265 function DriveMetadataSearchContentScanner(searchType) { |
| 266 ContentScanner.call(this); | 266 ContentScanner.call(this); |
| 267 this.searchType_ = searchType; | 267 this.searchType_ = searchType; |
| 268 } | 268 } |
| 269 | 269 |
| 270 /** | 270 /** |
| 271 * Extends ContentScanner. | 271 * Extends ContentScanner. |
| 272 */ | 272 */ |
| 273 DriveMetadataSearchContentScanner.prototype.__proto__ = | 273 DriveMetadataSearchContentScanner.prototype.__proto__ = |
| 274 ContentScanner.prototype; | 274 ContentScanner.prototype; |
| 275 | 275 |
| 276 /** | 276 /** |
| 277 * The search types on the Drive File System. | |
| 278 * @enum {string} | |
| 279 */ | |
| 280 DriveMetadataSearchContentScanner.SearchType = { | |
| 281 SEARCH_ALL: 'ALL', | |
| 282 SEARCH_SHARED_WITH_ME: 'SHARED_WITH_ME', | |
| 283 SEARCH_RECENT_FILES: 'EXCLUDE_DIRECTORIES', | |
| 284 SEARCH_OFFLINE: 'OFFLINE' | |
| 285 }; | |
| 286 Object.freeze(DriveMetadataSearchContentScanner.SearchType); | |
| 287 | |
| 288 /** | |
| 289 * Starts to metadata-search on Drive File System. | 277 * Starts to metadata-search on Drive File System. |
| 290 * @override | 278 * @override |
| 291 */ | 279 */ |
| 292 DriveMetadataSearchContentScanner.prototype.scan = function( | 280 DriveMetadataSearchContentScanner.prototype.scan = function( |
| 293 entriesCallback, successCallback, errorCallback) { | 281 entriesCallback, successCallback, errorCallback) { |
| 294 chrome.fileManagerPrivate.searchDriveMetadata( | 282 chrome.fileManagerPrivate.searchDriveMetadata( |
| 295 {query: '', types: this.searchType_, maxResults: 500}, | 283 {query: '', types: this.searchType_, maxResults: 500}, |
| 296 function(results) { | 284 function(results) { |
| 297 if (this.cancelled_) { | 285 if (this.cancelled_) { |
| 298 errorCallback(util.createDOMError(util.FileError.ABORT_ERR)); | 286 errorCallback(util.createDOMError(util.FileError.ABORT_ERR)); |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 }); | 889 }); |
| 902 }; | 890 }; |
| 903 | 891 |
| 904 /** | 892 /** |
| 905 * Creates a DirectoryContents instance to show the result of metadata search | 893 * Creates a DirectoryContents instance to show the result of metadata search |
| 906 * on Drive File System. | 894 * on Drive File System. |
| 907 * | 895 * |
| 908 * @param {FileListContext} context File list context. | 896 * @param {FileListContext} context File list context. |
| 909 * @param {!FakeEntry} fakeDirectoryEntry Fake directory entry representing the | 897 * @param {!FakeEntry} fakeDirectoryEntry Fake directory entry representing the |
| 910 * set of result entries. This serves as a top directory for the search. | 898 * set of result entries. This serves as a top directory for the search. |
| 911 * @param {!DriveMetadataSearchContentScanner.SearchType} searchType The type of | 899 * @param {chrome.fileManagerPrivate.SearchType} searchType The type of |
| 912 * the search. The scanner will restricts the entries based on the given | 900 * the search. The scanner will restricts the entries based on the given |
| 913 * type. | 901 * type. |
| 914 * @return {DirectoryContents} Created DirectoryContents instance. | 902 * @return {DirectoryContents} Created DirectoryContents instance. |
| 915 */ | 903 */ |
| 916 DirectoryContents.createForDriveMetadataSearch = function( | 904 DirectoryContents.createForDriveMetadataSearch = function( |
| 917 context, fakeDirectoryEntry, searchType) { | 905 context, fakeDirectoryEntry, searchType) { |
| 918 return new DirectoryContents( | 906 return new DirectoryContents( |
| 919 context, | 907 context, |
| 920 true, // Search | 908 true, // Search |
| 921 fakeDirectoryEntry, | 909 fakeDirectoryEntry, |
| 922 function() { | 910 function() { |
| 923 return new DriveMetadataSearchContentScanner(searchType); | 911 return new DriveMetadataSearchContentScanner(searchType); |
| 924 }); | 912 }); |
| 925 }; | 913 }; |
| OLD | NEW |