Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / extensions / file_manager / private_api_util.cc
index 98e5c8f..f24fdfa 100644 (file)
@@ -9,15 +9,18 @@
 #include "base/files/file_path.h"
 #include "base/message_loop/message_loop.h"
 #include "chrome/browser/chromeos/drive/drive.pb.h"
+#include "chrome/browser/chromeos/drive/drive_integration_service.h"
 #include "chrome/browser/chromeos/drive/file_errors.h"
 #include "chrome/browser/chromeos/drive/file_system_interface.h"
 #include "chrome/browser/chromeos/drive/file_system_util.h"
 #include "chrome/browser/chromeos/file_manager/app_id.h"
 #include "chrome/browser/chromeos/file_manager/fileapi_util.h"
+#include "chrome/browser/chromeos/file_manager/path_util.h"
 #include "chrome/browser/chromeos/file_manager/volume_manager.h"
 #include "chrome/browser/chromeos/fileapi/file_system_backend.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/common/extensions/api/file_browser_private.h"
+#include "content/public/browser/child_process_security_policy.h"
 #include "ui/shell_dialogs/selected_file_info.h"
 #include "webkit/browser/fileapi/file_system_context.h"
 #include "webkit/browser/fileapi/file_system_url.h"
@@ -262,5 +265,24 @@ void GetSelectedFileInfo(content::RenderViewHost* render_view_host,
       base::Bind(&GetSelectedFileInfoInternal, profile, base::Passed(&params)));
 }
 
+void SetupProfileFileAccessPermissions(int render_view_process_id,
+                                       Profile* profile) {
+  const base::FilePath paths[] = {
+    drive::util::GetDriveMountPointPath(profile),
+    util::GetDownloadsFolderForProfile(profile),
+  };
+  for (size_t i = 0; i < arraysize(paths); ++i) {
+    content::ChildProcessSecurityPolicy::GetInstance(
+        )->GrantCreateReadWriteFile(render_view_process_id, paths[i]);
+  }
+}
+
+drive::EventLogger* GetLogger(Profile* profile) {
+  drive::DriveIntegrationService* service =
+      drive::DriveIntegrationServiceFactory::FindForProfileRegardlessOfStates(
+          profile);
+  return service ? service->event_logger() : NULL;
+}
+
 }  // namespace util
 }  // namespace file_manager