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

Unified Diff: chrome/browser/extensions/extension_file_browser_private_api.h

Issue 6749021: Added new fileBrowserPrivate and fileHandler extension APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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/extension_file_browser_private_api.h
===================================================================
--- chrome/browser/extensions/extension_file_browser_private_api.h (revision 80410)
+++ chrome/browser/extensions/extension_file_browser_private_api.h (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,27 +10,65 @@
#include "base/file_path.h"
#include "chrome/browser/extensions/extension_function.h"
+#include "googleurl/src/url_util.h"
#include "webkit/fileapi/file_system_callback_dispatcher.h"
-// Implements the Chrome Extension local File API.
+// Implements the chrome.fileBrowserPrivate.requestLocalFileSystem method.
+class RequestLocalFileSystemFunctionBase : public AsyncExtensionFunction {
+ protected:
+ friend class LocalFileSystemCallbackDispatcher;
+ // AsyncExtensionFunction overrides.
+ virtual bool RunImpl() OVERRIDE;
+ void RespondSuccessOnUIThread(const std::string& name,
+ const FilePath& path,
+ const std::string& file_url);
+ void RespondFailedOnUIThread(base::PlatformFileError error_code);
+ void RequestOnFileThread(const GURL& source_url, const std::string& file_url);
+};
+
+// Implements the chrome.fileBrowserPrivate.requestLocalFileSystem method.
class RequestLocalFileSystemFunction
- : public AsyncExtensionFunction {
- public:
- RequestLocalFileSystemFunction();
+ : public RequestLocalFileSystemFunctionBase {
+ private:
+ DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.requestLocalFileSystem");
+};
+// Implements the chrome.fileBrowserPrivate.getFileTasks method.
+class GetFileTasksFileBrowserFunction : public AsyncExtensionFunction {
protected:
- virtual ~RequestLocalFileSystemFunction();
+ // AsyncExtensionFunction overrides.
+ virtual bool RunImpl() OVERRIDE;
+ private:
+
+ DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getFileTasks");
+};
+
+
+// Implements the chrome.fileBrowserPrivate.executeTask method.
+class ExecuteTasksFileBrowserFunction : public AsyncExtensionFunction {
+ protected:
// AsyncExtensionFunction overrides.
virtual bool RunImpl() OVERRIDE;
private:
- friend class LocalFileSystemCallbackDispatcher;
- void RespondSuccessOnUIThread(const std::string& name,
- const FilePath& path);
- void RespondFailedOnUIThread(base::PlatformFileError error_code);
+ // Converts |origin_file_url| to a url that is safe to be used within the
+ // context of targeted extension. First, this method removes the id of the
+ // file browser extension and replaces it with that of the handler extension
+ // we're invoking. Then it generates a hash code that
+ // this routine attached to it. The hash ensures that generated filesystem:
ericu 2011/04/06 03:50:09 The sentence that starts with "Then it generates"
zel 2011/04/06 05:25:17 Done.
+ // url can be safely used within the context of the handler extension and
ericu 2011/04/06 03:50:09 What the hash does is allow us to validate that th
zel 2011/04/06 05:25:17 Done.
+ // nowhere else. chrome.fileSystem.resolveFileSystemUrl function will verify
+ // correctness of the hash. Urls generated this way are safe to use by the
+ // handler extension only during the lifetime of the current browser process.
+ std::string MakeSafeFileUrl(const std::string& origin_file_url,
+ const std::string& extension_id);
- DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.requestLocalFileSystem");
+ // Executes context menu tasks for each element of |files_list|.
+ bool ExecuteContextMenuTasks(const std::string& extension_id,
+ const std::string& action_id,
+ ListValue* files_list);
+ DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.executeTask");
};
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FILE_BROWSER_PRIVATE_API_H_

Powered by Google App Engine
This is Rietveld 408576698