Index: chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.cc |
diff --git a/chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.cc b/chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.cc |
index 4bb966f1aa6186d9bc845faef1f09a3a22d13e98..66f44a190c19214c72ca3c9f52569326a5f8a721 100644 |
--- a/chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.cc |
+++ b/chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.cc |
@@ -24,6 +24,13 @@ using chromeos::file_system_provider::RequestValue; |
using chromeos::file_system_provider::Service; |
namespace extensions { |
+namespace { |
+ |
+const char kNotifyFailedErrorMessage[] = |
+ "Sending a response for the request failed."; |
+const char kInvalidNotificationErrorMessage[] = "The notification is invalid."; |
+ |
+} // namespace |
bool FileSystemProviderMountFunction::RunSync() { |
using api::file_system_provider::Mount::Params; |
@@ -56,7 +63,8 @@ bool FileSystemProviderMountFunction::RunSync() { |
if (!service->MountFileSystem(extension_id(), |
params->options.file_system_id, |
params->options.display_name, |
- params->options.writable)) { |
+ params->options.writable, |
+ params->options.supports_notify_tag)) { |
base::ListValue* const result = new base::ListValue(); |
result->Append(CreateError(kSecurityErrorName, kMountFailedErrorMessage)); |
SetResult(result); |
@@ -118,6 +126,45 @@ bool FileSystemProviderGetAllFunction::RunSync() { |
return true; |
} |
+bool FileSystemProviderNotifyFunction::RunSync() { |
+ using api::file_system_provider::Notify::Params; |
+ scoped_ptr<Params> params(Params::Create(*args_)); |
+ EXTENSION_FUNCTION_VALIDATE(params); |
+ |
+ Service* const service = Service::Get(GetProfile()); |
+ DCHECK(service); |
+ if (!service) |
+ return false; |
+ |
+ ProvidedFileSystemInterface* const file_system = |
+ service->GetProvidedFileSystem(extension_id(), |
+ params->options.file_system_id); |
+ if (!file_system) { |
+ base::ListValue* const result = new base::ListValue(); |
+ result->Append(CreateError(kNotFoundErrorName, kNotifyFailedErrorMessage)); |
+ SetResult(result); |
+ return true; |
+ } |
+ |
+ // TODO(mtomasz): Pass real data to Notify() instead of fake ones. |
+ if (!file_system->Notify( |
+ base::FilePath::FromUTF8Unsafe(params->options.observed_path), |
+ chromeos::file_system_provider::ProvidedFileSystemObserver::CHANGED, |
+ chromeos::file_system_provider::ProvidedFileSystemObserver:: |
+ ChildChanges(), |
+ "todo-tag")) { |
+ base::ListValue* const result = new base::ListValue(); |
+ result->Append( |
+ CreateError(kSecurityErrorName, kInvalidNotificationErrorMessage)); |
+ SetResult(result); |
+ return true; |
+ } |
+ |
+ base::ListValue* const result = new base::ListValue(); |
+ SetResult(result); |
+ return true; |
+} |
+ |
bool FileSystemProviderInternalUnmountRequestedSuccessFunction::RunWhenValid() { |
using api::file_system_provider_internal::UnmountRequestedSuccess::Params; |
scoped_ptr<Params> params(Params::Create(*args_)); |