Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_FILE_BROWSER_PRIVATE_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_FILE_BROWSER_PRIVATE_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FILE_BROWSER_PRIVATE_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FILE_BROWSER_PRIVATE_API_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "chrome/browser/extensions/extension_function.h" | 12 #include "chrome/browser/extensions/extension_function.h" |
| 13 #include "googleurl/src/url_util.h" | |
| 13 #include "webkit/fileapi/file_system_callback_dispatcher.h" | 14 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
| 14 | 15 |
| 15 // Implements the Chrome Extension local File API. | 16 // Implements the chrome.fileBrowserPrivate.requestLocalFileSystem method. |
| 17 class RequestLocalFileSystemFunctionBase : public AsyncExtensionFunction { | |
| 18 protected: | |
| 19 friend class LocalFileSystemCallbackDispatcher; | |
| 20 // AsyncExtensionFunction overrides. | |
| 21 virtual bool RunImpl() OVERRIDE; | |
| 22 void RespondSuccessOnUIThread(const std::string& name, | |
| 23 const FilePath& path, | |
| 24 const std::string& file_url); | |
| 25 void RespondFailedOnUIThread(base::PlatformFileError error_code); | |
| 26 void RequestOnFileThread(const GURL& source_url, const std::string& file_url); | |
| 27 }; | |
| 28 | |
| 29 // Implements the chrome.fileBrowserPrivate.requestLocalFileSystem method. | |
| 16 class RequestLocalFileSystemFunction | 30 class RequestLocalFileSystemFunction |
| 17 : public AsyncExtensionFunction { | 31 : public RequestLocalFileSystemFunctionBase { |
| 18 public: | 32 private: |
| 19 RequestLocalFileSystemFunction(); | 33 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.requestLocalFileSystem"); |
| 34 }; | |
| 20 | 35 |
| 36 // Implements the chrome.fileBrowserPrivate.getFileTasks method. | |
| 37 class GetFileTasksFileBrowserFunction : public AsyncExtensionFunction { | |
| 21 protected: | 38 protected: |
| 22 virtual ~RequestLocalFileSystemFunction(); | |
| 23 | |
| 24 // AsyncExtensionFunction overrides. | 39 // AsyncExtensionFunction overrides. |
| 25 virtual bool RunImpl() OVERRIDE; | 40 virtual bool RunImpl() OVERRIDE; |
| 26 | 41 |
| 27 private: | 42 private: |
| 28 friend class LocalFileSystemCallbackDispatcher; | |
| 29 void RespondSuccessOnUIThread(const std::string& name, | |
| 30 const FilePath& path); | |
| 31 void RespondFailedOnUIThread(base::PlatformFileError error_code); | |
| 32 | 43 |
| 33 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.requestLocalFileSystem"); | 44 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getFileTasks"); |
| 45 }; | |
| 46 | |
| 47 | |
| 48 // Implements the chrome.fileBrowserPrivate.executeTask method. | |
| 49 class ExecuteTasksFileBrowserFunction : public AsyncExtensionFunction { | |
| 50 protected: | |
| 51 // AsyncExtensionFunction overrides. | |
| 52 virtual bool RunImpl() OVERRIDE; | |
| 53 | |
| 54 private: | |
| 55 // Converts |origin_file_url| to a url that is safe to be used within the | |
| 56 // context of targeted extension. It does that by replacing soruce extension | |
|
ericu
2011/04/02 01:16:05
typo: source
zel
2011/04/06 00:06:33
Done.
| |
| 57 // id within the utl and attaching a hash to the url. The hash is used as | |
|
ericu
2011/04/02 01:16:05
typo: url
zel
2011/04/06 00:06:33
Done.
| |
| 58 // MAC here, ensures that generated filesystem: url can be safely used within | |
| 59 // the context of given target extension. | |
| 60 // chrome.fileSystem.resolveFileSystemUrl function handlers will verify the | |
| 61 // hash correctness. Urls generated this way are safe to use by the target | |
| 62 // extension only during the lifetime of the current browser process. | |
|
ericu
2011/04/02 01:16:05
It's still not at all clear what the hash is inten
zel
2011/04/06 00:06:33
Done.
| |
| 63 std::string MakeSafeFileUrl(const std::string& origin_file_url, | |
| 64 const std::string& extension_id); | |
| 65 | |
| 66 // Executes context menu tasks for each element of |files_list|. | |
| 67 bool ExecuteContextMenuTasks(const std::string& extension_id, | |
| 68 const std::string& action_id, | |
| 69 ListValue* files_list); | |
| 70 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.executeTask"); | |
| 34 }; | 71 }; |
| 35 | 72 |
| 36 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FILE_BROWSER_PRIVATE_API_H_ | 73 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FILE_BROWSER_PRIVATE_API_H_ |
| OLD | NEW |