Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / extensions / file_manager / private_api_drive.cc
index 139ca7e..f8d18b0 100644 (file)
@@ -5,12 +5,13 @@
 #include "chrome/browser/chromeos/extensions/file_manager/private_api_drive.h"
 
 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
-#include "chrome/browser/chromeos/drive/logging.h"
 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h"
 #include "chrome/browser/chromeos/file_manager/file_tasks.h"
+#include "chrome/browser/chromeos/file_manager/fileapi_util.h"
 #include "chrome/browser/chromeos/file_manager/url_util.h"
 #include "chrome/browser/chromeos/fileapi/file_system_backend.h"
 #include "chrome/browser/drive/drive_app_registry.h"
+#include "chrome/browser/drive/event_logger.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/common/extensions/api/file_browser_private.h"
 #include "content/public/browser/browser_thread.h"
@@ -227,7 +228,7 @@ void FileBrowserPrivatePinDriveFileFunction::
   if (error == drive::FILE_ERROR_OK) {
     SendResponse(true);
   } else {
-    error_ = drive::FileErrorToString(error);
+    SetError(drive::FileErrorToString(error));
     SendResponse(false);
   }
 }
@@ -294,12 +295,6 @@ void FileBrowserPrivateGetDriveFilesFunction::OnFileReady(
   if (error == drive::FILE_ERROR_OK) {
     local_paths_.push_back(local_path.AsUTF8Unsafe());
     DVLOG(1) << "Got " << drive_path.value() << " as " << local_path.value();
-
-    // TODO(benchan): If the file is a hosted document, a temporary JSON file
-    // is created to represent the document. The JSON file is not cached and
-    // should be deleted after use. We need to somehow communicate with
-    // file_manager.js to manage the lifetime of the temporary file.
-    // See crosbug.com/28058.
   } else {
     local_paths_.push_back("");
     DVLOG(1) << "Failed to get " << drive_path.value()
@@ -404,7 +399,10 @@ void FileBrowserPrivateSearchDriveFunction::OnSearch(
     base::DictionaryValue* entry = new base::DictionaryValue();
     entry->SetString("fileSystemName", info.name);
     entry->SetString("fileSystemRoot", info.root_url.spec());
-    entry->SetString("fileFullPath", "/" + results->at(i).path.value());
+    entry->SetString("fileFullPath",
+        "/" + file_manager::util::ConvertDrivePathToRelativeFileSystemPath(
+            GetProfile(), extension_->id(),
+            results->at(i).path).AsUTF8Unsafe());
     entry->SetBoolean("fileIsDirectory", results->at(i).is_directory);
     entries->Append(entry);
   }
@@ -422,13 +420,16 @@ bool FileBrowserPrivateSearchDriveMetadataFunction::RunImpl() {
   const scoped_ptr<Params> params(Params::Create(*args_));
   EXTENSION_FUNCTION_VALIDATE(params);
 
-  drive::util::Log(logging::LOG_INFO,
-                   "%s[%d] called. (types: '%s', maxResults: '%d')",
-                   name().c_str(),
-                   request_id(),
-                   api::file_browser_private::ToString(
-                       params->search_params.types).c_str(),
-                   params->search_params.max_results);
+  drive::EventLogger* logger = file_manager::util::GetLogger(GetProfile());
+  if (logger) {
+    logger->Log(logging::LOG_INFO,
+                "%s[%d] called. (types: '%s', maxResults: '%d')",
+                name().c_str(),
+                request_id(),
+                api::file_browser_private::ToString(
+                    params->search_params.types).c_str(),
+                params->search_params.max_results);
+  }
   set_log_on_completion(true);
 
   drive::FileSystemInterface* const file_system =
@@ -491,7 +492,10 @@ void FileBrowserPrivateSearchDriveMetadataFunction::OnSearchMetadata(
     base::DictionaryValue* entry = new base::DictionaryValue();
     entry->SetString("fileSystemName", info.name);
     entry->SetString("fileSystemRoot", info.root_url.spec());
-    entry->SetString("fileFullPath", "/" + results->at(i).path.value());
+    entry->SetString("fileFullPath",
+        "/" + file_manager::util::ConvertDrivePathToRelativeFileSystemPath(
+            GetProfile(), extension_->id(),
+            results->at(i).path).AsUTF8Unsafe());
     entry->SetBoolean("fileIsDirectory",
                       results->at(i).entry.file_info().is_directory());
 
@@ -532,7 +536,9 @@ bool FileBrowserPrivateGetDriveConnectionStateFunction::RunImpl() {
   results_ = api::file_browser_private::GetDriveConnectionState::Results::
       Create(result);
 
-  drive::util::Log(logging::LOG_INFO, "%s succeeded.", name().c_str());
+  drive::EventLogger* logger = file_manager::util::GetLogger(GetProfile());
+  if (logger)
+    logger->Log(logging::LOG_INFO, "%s succeeded.", name().c_str());
   return true;
 }
 
@@ -599,7 +605,7 @@ void FileBrowserPrivateGetShareUrlFunction::OnGetShareUrl(
     drive::FileError error,
     const GURL& share_url) {
   if (error != drive::FILE_ERROR_OK) {
-    error_ = "Share Url for this item is not available.";
+    SetError("Share Url for this item is not available.");
     SendResponse(false);
     return;
   }