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

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

Issue 1029803004: Add chrome.fileSystem.GetVolumeList(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed chrome_extensions.js. Created 5 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/api/file_system/file_system_api.h
diff --git a/chrome/browser/extensions/api/file_system/file_system_api.h b/chrome/browser/extensions/api/file_system/file_system_api.h
index 2445c1957ce45151303a987a9da425122cd1d539..7ae7c386f28858da8f5a9e12593c7f97fc5a80b5 100644
--- a/chrome/browser/extensions/api/file_system/file_system_api.h
+++ b/chrome/browser/extensions/api/file_system/file_system_api.h
@@ -48,8 +48,8 @@ std::vector<base::FilePath> GetGrayListedDirectories();
#if defined(OS_CHROMEOS)
// Requests consent for the chrome.fileSystem.requestFileSystem() method.
// Interaction with UI and environmental checks (kiosk mode, whitelist) are
-// provided by a delegate: FileSystemRequestFileSystemFunction. For testing,
-// it is TestingConsentProviderDelegate.
+// provided by a delegate: ConsentProviderDelegate. For testing, it is
+// TestingConsentProviderDelegate.
class ConsentProvider {
public:
enum Consent { CONSENT_GRANTED, CONSENT_REJECTED, CONSENT_IMPOSSIBLE };
@@ -97,6 +97,35 @@ class ConsentProvider {
DISALLOW_COPY_AND_ASSIGN(ConsentProvider);
};
+
+// Handles interaction with user as well as environment checks (whitelists,
+// context of running extensions) for ConsentProvider.
+class ConsentProviderDelegate : public ConsentProvider::DelegateInterface {
+ public:
+ ConsentProviderDelegate(Profile* profile, content::RenderViewHost* host);
+ ~ConsentProviderDelegate();
+
+ private:
+ friend ScopedSkipRequestFileSystemDialog;
+
+ // Sets a fake result for the user consent dialog. If ui::DIALOG_BUTTON_NONE
+ // then disabled.
+ static void SetAutoDialogButtonForTest(ui::DialogButton button);
+
+ // ConsentProvider::DelegateInterface overrides:
+ void ShowDialog(const extensions::Extension& extension,
+ base::WeakPtr<file_manager::Volume> volume,
+ bool writable,
+ const file_system_api::ConsentProvider::ShowDialogCallback&
+ callback) override;
+ bool IsAutoLaunched(const extensions::Extension& extension) override;
+ bool IsWhitelistedComponent(const extensions::Extension& extension) override;
+
+ Profile* const profile_;
+ content::RenderViewHost* const host_;
+
+ DISALLOW_COPY_AND_ASSIGN(ConsentProviderDelegate);
+};
#endif
} // namespace file_system_api
@@ -315,15 +344,26 @@ class FileSystemRequestFileSystemFunction : public UIThreadExtensionFunction {
protected:
~FileSystemRequestFileSystemFunction() override {}
- // AsyncExtensionFunction overrides.
+ // UIThreadExtensionFunction overrides.
+ ExtensionFunction::ResponseAction Run() override;
+};
+
+// Stub for non Chrome OS operating systems.
+class FileSystemGetVolumeListFunction : public UIThreadExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("fileSystem.getVolumeList",
+ FILESYSTEM_GETVOLUMELIST);
+
+ protected:
+ ~FileSystemGetVolumeListFunction() override {}
+
+ // UIThreadExtensionFunction overrides.
ExtensionFunction::ResponseAction Run() override;
};
#else
// Requests a file system for the specified volume id.
-class FileSystemRequestFileSystemFunction
- : public UIThreadExtensionFunction,
- public file_system_api::ConsentProvider::DelegateInterface {
+class FileSystemRequestFileSystemFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("fileSystem.requestFileSystem",
FILESYSTEM_REQUESTFILESYSTEM)
@@ -332,25 +372,10 @@ class FileSystemRequestFileSystemFunction
protected:
~FileSystemRequestFileSystemFunction() override;
- // AsyncExtensionFunction overrides.
+ // UIThreadExtensionFunction overrides.
ExtensionFunction::ResponseAction Run() override;
private:
- friend ScopedSkipRequestFileSystemDialog;
-
- // Sets a fake result for the user consent dialog. If ui::DIALOG_BUTTON_NONE
- // then disabled.
- static void SetAutoDialogButtonForTest(ui::DialogButton button);
-
- // ConsentProvider::DelegateInterface overrides:
- void ShowDialog(const extensions::Extension& extension,
- base::WeakPtr<file_manager::Volume> volume,
- bool writable,
- const file_system_api::ConsentProvider::ShowDialogCallback&
- callback) override;
- bool IsAutoLaunched(const extensions::Extension& extension) override;
- bool IsWhitelistedComponent(const extensions::Extension& extension) override;
-
// Called when a user grants or rejects permissions for the file system
// access.
void OnConsentReceived(base::WeakPtr<file_manager::Volume> volume,
@@ -358,7 +383,23 @@ class FileSystemRequestFileSystemFunction
file_system_api::ConsentProvider::Consent result);
ChromeExtensionFunctionDetails chrome_details_;
- file_system_api::ConsentProvider consent_provider_;
+};
+
+// Requests a list of available volumes.
+class FileSystemGetVolumeListFunction : public UIThreadExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("fileSystem.getVolumeList",
+ FILESYSTEM_GETVOLUMELIST);
+ FileSystemGetVolumeListFunction();
+
+ protected:
+ ~FileSystemGetVolumeListFunction() override;
+
+ // UIThreadExtensionFunction overrides.
+ ExtensionFunction::ResponseAction Run() override;
+
+ private:
+ ChromeExtensionFunctionDetails chrome_details_;
};
#endif
« no previous file with comments | « chrome/browser/chromeos/login/kiosk_browsertest.cc ('k') | chrome/browser/extensions/api/file_system/file_system_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698