| Index: chrome/browser/chromeos/extensions/file_handler_util.cc
|
| diff --git a/chrome/browser/chromeos/extensions/file_handler_util.cc b/chrome/browser/chromeos/extensions/file_handler_util.cc
|
| index 08db70e8071fe9277c7b2c216a62ad115924204a..cb4c8e6081cd74ed180c9ddd86a1b863f99f010a 100644
|
| --- a/chrome/browser/chromeos/extensions/file_handler_util.cc
|
| +++ b/chrome/browser/chromeos/extensions/file_handler_util.cc
|
| @@ -359,10 +359,14 @@ class FileTaskExecutor::ExecuteTasksFileSystemCallbackDispatcher {
|
| base::Bind(
|
| &FileTaskExecutor::ExecuteFileActionsOnUIThread,
|
| executor_,
|
| - file_system_name,
|
| - file_system_root,
|
| file_list,
|
| - handler_pid_));
|
| + base::Bind(
|
| + &FileTaskExecutor::OnInitAccessForExecuteFileActionsOnUIThread,
|
| + executor_,
|
| + file_system_name,
|
| + file_system_root,
|
| + file_list,
|
| + handler_pid_)));
|
| }
|
|
|
| void DidFail(base::PlatformFileError error_code) {
|
| @@ -548,6 +552,27 @@ void FileTaskExecutor::ExecuteFailedOnUIThread() {
|
| }
|
|
|
| void FileTaskExecutor::ExecuteFileActionsOnUIThread(
|
| + const FileDefinitionList& file_list,
|
| + const base::Closure& callback) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| +
|
| + ExtensionService* service = profile_->GetExtensionService();
|
| + if (!service) {
|
| + Done(false);
|
| + return;
|
| + }
|
| +
|
| + const Extension* extension = service->GetExtensionById(extension_id_, false);
|
| + if (!extension) {
|
| + Done(false);
|
| + return;
|
| + }
|
| +
|
| + InitHandlerHostFileAccessPermissions(file_list, extension, action_id_,
|
| + callback);
|
| +}
|
| +
|
| +void FileTaskExecutor::OnInitAccessForExecuteFileActionsOnUIThread(
|
| const std::string& file_system_name,
|
| const GURL& file_system_root,
|
| const FileDefinitionList& file_list,
|
| @@ -566,8 +591,6 @@ void FileTaskExecutor::ExecuteFileActionsOnUIThread(
|
| return;
|
| }
|
|
|
| - InitHandlerHostFileAccessPermissions(file_list, extension, action_id_);
|
| -
|
| if (handler_pid > 0) {
|
| SetupPermissionsAndDispatchEvent(file_system_name, file_system_root,
|
| file_list, handler_pid, NULL);
|
| @@ -649,9 +672,11 @@ void FileTaskExecutor::SetupPermissionsAndDispatchEvent(
|
| void FileTaskExecutor::InitHandlerHostFileAccessPermissions(
|
| const FileDefinitionList& file_list,
|
| const Extension* handler_extension,
|
| - const std::string& action_id) {
|
| + const std::string& action_id,
|
| + const base::Closure& callback) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| + scoped_ptr<std::vector<FilePath> > gdata_paths(new std::vector<FilePath>);
|
| for (FileDefinitionList::const_iterator iter = file_list.begin();
|
| iter != file_list.end();
|
| ++iter) {
|
| @@ -660,15 +685,22 @@ void FileTaskExecutor::InitHandlerHostFileAccessPermissions(
|
| iter->absolute_path,
|
| GetAccessPermissionsForHandler(handler_extension, action_id)));
|
|
|
| - if (!gdata::util::IsUnderGDataMountPoint(iter->absolute_path))
|
| - continue;
|
| + if (gdata::util::IsUnderGDataMountPoint(iter->absolute_path))
|
| + gdata_paths->push_back(iter->virtual_path);
|
| + }
|
|
|
| - // If the file is on gdata mount point, we'll have to give handler host
|
| - // permissions for file's gdata cache paths.
|
| - // This has to be called on UI thread.
|
| - gdata::util::InsertGDataCachePathsPermissions(profile_, iter->virtual_path,
|
| - &handler_host_permissions_);
|
| + if (gdata_paths->empty()) {
|
| + // Invoke callback if none of the files are on gdata mount point.
|
| + callback.Run();
|
| + return;
|
| }
|
| +
|
| + // For files on gdata mount point, we'll have to give handler host permissions
|
| + // for their cache paths. This has to be called on UI thread.
|
| + gdata::util::InsertGDataCachePathsPermissions(profile_,
|
| + gdata_paths.Pass(),
|
| + &handler_host_permissions_,
|
| + callback);
|
| }
|
|
|
| void FileTaskExecutor::SetupHandlerHostFileAccessPermissions(int handler_pid) {
|
|
|