| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 * Provides drive search results to chrome launcher. | 6 * Provides drive search results to chrome launcher. |
| 7 * @constructor | 7 * @constructor |
| 8 * @struct | 8 * @struct |
| 9 */ | 9 */ |
| 10 function LauncherSearch() { | 10 function LauncherSearch() { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 */ | 110 */ |
| 111 LauncherSearch.prototype.onQueryStarted_ = function(queryId, query, limit) { | 111 LauncherSearch.prototype.onQueryStarted_ = function(queryId, query, limit) { |
| 112 this.queryId_ = queryId; | 112 this.queryId_ = queryId; |
| 113 | 113 |
| 114 // Request an instance of volume manager to ensure that all volumes are | 114 // Request an instance of volume manager to ensure that all volumes are |
| 115 // initialized. When user searches while background page of Files.app is not | 115 // initialized. When user searches while background page of Files.app is not |
| 116 // running, it happens that this method is executed before all volumes are | 116 // running, it happens that this method is executed before all volumes are |
| 117 // initialized. In this method, chrome.fileManagerPrivate.searchDriveMetadata | 117 // initialized. In this method, chrome.fileManagerPrivate.searchDriveMetadata |
| 118 // resolves url internally, and it fails if filesystem of the url is not | 118 // resolves url internally, and it fails if filesystem of the url is not |
| 119 // initialized. | 119 // initialized. |
| 120 VolumeManager.getInstance().then(function() { | 120 volumeManagerFactory.getInstance().then(function() { |
| 121 chrome.fileManagerPrivate.searchDriveMetadata( | 121 chrome.fileManagerPrivate.searchDriveMetadata( |
| 122 { | 122 { |
| 123 query: query, | 123 query: query, |
| 124 types: 'ALL', | 124 types: 'ALL', |
| 125 maxResults: limit | 125 maxResults: limit |
| 126 }, function(results) { | 126 }, function(results) { |
| 127 // If query is already changed, discard the results. | 127 // If query is already changed, discard the results. |
| 128 if (queryId !== this.queryId_ || results.length === 0) | 128 if (queryId !== this.queryId_ || results.length === 0) |
| 129 return; | 129 return; |
| 130 | 130 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 }; | 175 }; |
| 176 | 176 |
| 177 /** | 177 /** |
| 178 * Handles onOpenResult event. | 178 * Handles onOpenResult event. |
| 179 * @param {string} itemId | 179 * @param {string} itemId |
| 180 */ | 180 */ |
| 181 LauncherSearch.prototype.onOpenResult_ = function(itemId) { | 181 LauncherSearch.prototype.onOpenResult_ = function(itemId) { |
| 182 // Request an instance of volume manager to ensure that all volumes are | 182 // Request an instance of volume manager to ensure that all volumes are |
| 183 // initialized. webkitResolveLocalFileSystemURL in util.urlToEntry fails if | 183 // initialized. webkitResolveLocalFileSystemURL in util.urlToEntry fails if |
| 184 // filesystem of the url is not initialized. | 184 // filesystem of the url is not initialized. |
| 185 VolumeManager.getInstance().then(function() { | 185 volumeManagerFactory.getInstance().then(function() { |
| 186 util.urlToEntry(itemId).then(function(entry) { | 186 util.urlToEntry(itemId).then(function(entry) { |
| 187 if (entry.isDirectory) { | 187 if (entry.isDirectory) { |
| 188 // If it's directory, open the directory with file manager. | 188 // If it's directory, open the directory with file manager. |
| 189 launchFileManager( | 189 launchFileManager( |
| 190 { currentDirectoryURL: entry.toURL() }, | 190 { currentDirectoryURL: entry.toURL() }, |
| 191 undefined, /* App ID */ | 191 undefined, /* App ID */ |
| 192 LaunchType.FOCUS_SAME_OR_CREATE); | 192 LaunchType.FOCUS_SAME_OR_CREATE); |
| 193 } else { | 193 } else { |
| 194 // If the file is not directory, try to execute default task. | 194 // If the file is not directory, try to execute default task. |
| 195 chrome.fileManagerPrivate.getFileTasks([entry], function(tasks) { | 195 chrome.fileManagerPrivate.getFileTasks([entry], function(tasks) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 * @param {string} selectionURL A url to be selected. | 243 * @param {string} selectionURL A url to be selected. |
| 244 * @private | 244 * @private |
| 245 */ | 245 */ |
| 246 LauncherSearch.prototype.openFileManagerWithSelectionURL_ = function( | 246 LauncherSearch.prototype.openFileManagerWithSelectionURL_ = function( |
| 247 selectionURL) { | 247 selectionURL) { |
| 248 launchFileManager( | 248 launchFileManager( |
| 249 {selectionURL: selectionURL}, | 249 {selectionURL: selectionURL}, |
| 250 undefined, /* App ID */ | 250 undefined, /* App ID */ |
| 251 LaunchType.FOCUS_SAME_OR_CREATE); | 251 LaunchType.FOCUS_SAME_OR_CREATE); |
| 252 }; | 252 }; |
| OLD | NEW |