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 6aab112b378d60b308f4cbfe0c54a7686e595035..c9d53937bc32d7eafe5aa3235720182e9a18af45 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) { |
@@ -549,6 +553,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); |
tbarzic
2012/06/08 17:59:13
this can be extracted to a separate function..
hshi1
2012/06/08 18:21:41
Done.
|
+ 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, |
@@ -567,8 +592,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); |
@@ -648,9 +671,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) { |
@@ -659,15 +684,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->absolute_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->absolute_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) { |