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

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

Issue 2934143002: Move chrome.fileSystem implementation to //extensions (Closed)
Patch Set: . Created 3 years, 6 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: extensions/browser/api/file_system/file_system_api.h
diff --git a/chrome/browser/extensions/api/file_system/file_system_api.h b/extensions/browser/api/file_system/file_system_api.h
similarity index 86%
rename from chrome/browser/extensions/api/file_system/file_system_api.h
rename to extensions/browser/api/file_system/file_system_api.h
index f65f4183c3267efacc3c3a84a61ff4f836364c12..725876eefd6f647dec344fb49a88d5d8066cd6e0 100644
--- a/chrome/browser/extensions/api/file_system/file_system_api.h
+++ b/extensions/browser/api/file_system/file_system_api.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2017 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.
-#ifndef CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_
-#define CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_
+#ifndef EXTENSIONS_BROWSER_API_FILE_SYSTEM_FILE_SYSTEM_API_H_
+#define EXTENSIONS_BROWSER_API_FILE_SYSTEM_FILE_SYSTEM_API_H_
#include <memory>
#include <string>
@@ -12,19 +12,12 @@
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
#include "base/values.h"
#include "build/build_config.h"
-#include "chrome/browser/extensions/chrome_extension_function.h"
-#include "chrome/browser/extensions/chrome_extension_function_details.h"
-#include "chrome/common/extensions/api/file_system.h"
#include "extensions/browser/extension_function.h"
+#include "extensions/common/api/file_system.h"
#include "ui/shell_dialogs/select_file_dialog.h"
-#if defined(OS_CHROMEOS)
-#include "chrome/browser/extensions/api/file_system/consent_provider.h"
-#endif
-
namespace extensions {
class ExtensionPrefs;
@@ -42,12 +35,6 @@ void SetLastChooseEntryDirectory(ExtensionPrefs* prefs,
const std::string& extension_id,
const base::FilePath& path);
-#if defined(OS_CHROMEOS)
-// Dispatches an event about a mounted on unmounted volume in the system to
-// each extension which can request it.
-void DispatchVolumeListChangeEvent(Profile* profile);
-#endif
-
} // namespace file_system_api
class FileSystemGetDisplayPathFunction : public UIThreadExtensionFunction {
@@ -60,7 +47,7 @@ class FileSystemGetDisplayPathFunction : public UIThreadExtensionFunction {
ResponseAction Run() override;
};
-class FileSystemEntryFunction : public ChromeAsyncExtensionFunction {
+class FileSystemEntryFunction : public UIThreadExtensionFunction {
protected:
FileSystemEntryFunction();
@@ -103,7 +90,7 @@ class FileSystemGetWritableEntryFunction : public FileSystemEntryFunction {
protected:
~FileSystemGetWritableEntryFunction() override {}
- bool RunAsync() override;
+ ResponseAction Run() override;
private:
void CheckPermissionAndSendResponse();
@@ -158,7 +145,7 @@ class FileSystemChooseEntryFunction : public FileSystemEntryFunction {
class FilePicker;
~FileSystemChooseEntryFunction() override {}
- bool RunAsync() override;
+ ResponseAction Run() override;
void ShowPicker(const ui::SelectFileDialog::FileTypeInfo& file_type_info,
ui::SelectFileDialog::Type picker_type);
@@ -175,25 +162,29 @@ class FileSystemChooseEntryFunction : public FileSystemEntryFunction {
void FileSelectionCanceled();
// Check if the chosen directory is or is an ancestor of a sensitive
- // directory. If so, show a dialog to confirm that the user wants to open the
- // directory. Calls OnDirectoryAccessConfirmed if the directory isn't
- // sensitive or the user chooses to open it. Otherwise, calls
- // FileSelectionCanceled.
+ // directory. If so, calls ConfirmSensitiveDirectoryAccess. Otherwise, calls
+ // OnDirectoryAccessConfirmed.
void ConfirmDirectoryAccessAsync(bool non_native_path,
const std::vector<base::FilePath>& paths,
content::WebContents* web_contents);
+
+ // Shows a dialog to confirm whether the user wants to open the directory.
+ // Calls OnDirectoryAccessConfirmed or FileSelectionCanceled.
+ void ConfirmSensitiveDirectoryAccess(const std::vector<base::FilePath>& paths,
+ content::WebContents* web_contents);
+
void OnDirectoryAccessConfirmed(const std::vector<base::FilePath>& paths);
base::FilePath initial_path_;
};
-class FileSystemRetainEntryFunction : public ChromeAsyncExtensionFunction {
+class FileSystemRetainEntryFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("fileSystem.retainEntry", FILESYSTEM_RETAINENTRY)
protected:
~FileSystemRetainEntryFunction() override {}
- bool RunAsync() override;
+ ResponseAction Run() override;
private:
// Retains the file entry referenced by |entry_id| in apps::SavedFilesService.
@@ -220,7 +211,7 @@ class FileSystemRestoreEntryFunction : public FileSystemEntryFunction {
protected:
~FileSystemRestoreEntryFunction() override {}
- bool RunAsync() override;
+ ResponseAction Run() override;
};
class FileSystemObserveDirectoryFunction : public UIThreadExtensionFunction {
@@ -297,11 +288,8 @@ class FileSystemRequestFileSystemFunction : public UIThreadExtensionFunction {
private:
// Called when a user grants or rejects permissions for the file system
// access.
- void OnConsentReceived(const base::WeakPtr<file_manager::Volume>& volume,
- bool writable,
- file_system_api::ConsentProvider::Consent result);
-
- ChromeExtensionFunctionDetails chrome_details_;
+ void OnGotFileSystem(const std::string& id, const std::string& path);
+ void OnError(const std::string& error);
};
// Requests a list of available volumes.
@@ -318,10 +306,11 @@ class FileSystemGetVolumeListFunction : public UIThreadExtensionFunction {
ExtensionFunction::ResponseAction Run() override;
private:
- ChromeExtensionFunctionDetails chrome_details_;
+ void OnGotVolumeList(const std::vector<api::file_system::Volume>& volumes);
+ void OnError(const std::string& error);
};
#endif
} // namespace extensions
-#endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_
+#endif // EXTENSIONS_BROWSER_API_FILE_SYSTEM_FILE_SYSTEM_API_H_

Powered by Google App Engine
This is Rietveld 408576698