Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Unified Diff: chrome/browser/extensions/api/file_system/file_system_api.cc

Issue 10692104: Add isWritableFileEntry to the fileSystem API (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: added presubmit fix Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/file_system/file_system_api.cc
diff --git a/chrome/browser/extensions/api/file_system/file_system_api.cc b/chrome/browser/extensions/api/file_system/file_system_api.cc
index 3288e8a9dbfccb1b06af938be06a5452b382ff32..c3c71250251315d4ac4dcef171458bd5ac568ac0 100644
--- a/chrome/browser/extensions/api/file_system/file_system_api.cc
+++ b/chrome/browser/extensions/api/file_system/file_system_api.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/file_path.h"
#include "base/file_util.h"
+#include "base/logging.h"
#include "base/path_service.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/extensions/shell_window_registry.h"
@@ -236,6 +237,28 @@ bool FileSystemGetWritableFileEntryFunction::RunImpl() {
return true;
}
+bool FileSystemIsWritableFileEntryFunction::RunImpl() {
+ std::string filesystem_name;
+ std::string filesystem_path;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &filesystem_name));
+ EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &filesystem_path));
+
+ std::string filesystem_id;
+ if (!fileapi::CrackIsolatedFileSystemName(filesystem_name, &filesystem_id)) {
+ error_ = kInvalidParameters;
+ return false;
+ }
+
+ content::ChildProcessSecurityPolicy* policy =
+ content::ChildProcessSecurityPolicy::GetInstance();
+ int renderer_id = render_view_host_->GetProcess()->GetID();
+ bool is_writable = policy->CanReadWriteFileSystem(renderer_id,
+ filesystem_id);
+
+ SetResult(base::Value::CreateBooleanValue(is_writable));
+ return true;
+}
+
// Handles showing a dialog to the user to ask for the filename for a file to
// save or open.
class FileSystemChooseFileFunction::FilePicker

Powered by Google App Engine
This is Rietveld 408576698