| Index: chrome/browser/extensions/api/file_system/chrome_file_system_delegate.h
|
| diff --git a/chrome/browser/extensions/api/file_system/consent_provider.h b/chrome/browser/extensions/api/file_system/chrome_file_system_delegate.h
|
| similarity index 10%
|
| copy from chrome/browser/extensions/api/file_system/consent_provider.h
|
| copy to chrome/browser/extensions/api/file_system/chrome_file_system_delegate.h
|
| index 3a517b6f68d8296547812c32ab50f57d2c7d023f..938ec2ba74971b25ff198c561ac8e826d21e1a3e 100644
|
| --- a/chrome/browser/extensions/api/file_system/consent_provider.h
|
| +++ b/chrome/browser/extensions/api/file_system/chrome_file_system_delegate.h
|
| @@ -2,116 +2,94 @@
|
| // 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_CONSENT_PROVIDER_H_
|
| -#define CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_CONSENT_PROVIDER_H_
|
| +#ifndef CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_CHROME_FILE_SYSTEM_DELEGATE_H_
|
| +#define CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_CHROME_FILE_SYSTEM_DELEGATE_H_
|
| +
|
| +#include "extensions/browser/api/file_system/file_system_delegate.h"
|
|
|
| -#include "base/callback_forward.h"
|
| #include "base/macros.h"
|
| #include "base/memory/weak_ptr.h"
|
| #include "build/build_config.h"
|
| -#include "ui/base/ui_base_types.h"
|
| -
|
| -class Profile;
|
|
|
| -namespace content {
|
| -class RenderFrameHost;
|
| -} // content
|
| +#if defined(OS_CHROMEOS)
|
| +#include "chrome/browser/extensions/api/file_system/consent_provider.h"
|
| +#endif
|
|
|
| namespace file_manager {
|
| class Volume;
|
| -} // namespace file_manager
|
| +}
|
|
|
| namespace extensions {
|
| -class Extension;
|
| -class ScopedSkipRequestFileSystemDialog;
|
|
|
| +#if defined(OS_CHROMEOS)
|
| namespace file_system_api {
|
|
|
| -// Requests consent for the chrome.fileSystem.requestFileSystem() method.
|
| -// Interaction with UI and environmental checks (kiosk mode, whitelist) are
|
| -// provided by a delegate: ConsentProviderDelegate. For testing, it is
|
| -// TestingConsentProviderDelegate.
|
| -class ConsentProvider {
|
| - public:
|
| - enum Consent { CONSENT_GRANTED, CONSENT_REJECTED, CONSENT_IMPOSSIBLE };
|
| - typedef base::Callback<void(Consent)> ConsentCallback;
|
| - typedef base::Callback<void(ui::DialogButton)> ShowDialogCallback;
|
| -
|
| - // Interface for delegating user interaction for granting permissions.
|
| - class DelegateInterface {
|
| - public:
|
| - // Shows a dialog for granting permissions.
|
| - virtual void ShowDialog(const Extension& extension,
|
| - const base::WeakPtr<file_manager::Volume>& volume,
|
| - bool writable,
|
| - const ShowDialogCallback& callback) = 0;
|
| -
|
| - // Shows a notification about permissions automatically granted access.
|
| - virtual void ShowNotification(
|
| - const Extension& extension,
|
| - const base::WeakPtr<file_manager::Volume>& volume,
|
| - bool writable) = 0;
|
| -
|
| - // Checks if the extension was launched in auto-launch kiosk mode.
|
| - virtual bool IsAutoLaunched(const Extension& extension) = 0;
|
| -
|
| - // Checks if the extension is a whitelisted component extension or app.
|
| - virtual bool IsWhitelistedComponent(const Extension& extension) = 0;
|
| - };
|
| -
|
| - explicit ConsentProvider(DelegateInterface* delegate);
|
| - ~ConsentProvider();
|
| -
|
| - // Requests consent for granting |writable| permissions to the |volume|
|
| - // volume by the |extension|. Must be called only if the extension is
|
| - // grantable, which can be checked with IsGrantable().
|
| - void RequestConsent(const Extension& extension,
|
| - const base::WeakPtr<file_manager::Volume>& volume,
|
| - bool writable,
|
| - const ConsentCallback& callback);
|
| -
|
| - // Checks whether the |extension| can be granted access.
|
| - bool IsGrantable(const Extension& extension);
|
| +// Dispatches an event about a mounted or unmounted volume in the system to
|
| +// each extension which can request it.
|
| +void DispatchVolumeListChangeEvent(content::BrowserContext* browser_context);
|
|
|
| - private:
|
| - DelegateInterface* const delegate_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(ConsentProvider);
|
| -};
|
| +} // namespace file_system_api
|
| +#endif // defined(OS_CHROMEOS)
|
|
|
| -// Handles interaction with user as well as environment checks (whitelists,
|
| -// context of running extensions) for ConsentProvider.
|
| -class ConsentProviderDelegate : public ConsentProvider::DelegateInterface {
|
| +class ChromeFileSystemDelegate : public FileSystemDelegate {
|
| public:
|
| - ConsentProviderDelegate(Profile* profile, content::RenderFrameHost* host);
|
| - ~ConsentProviderDelegate();
|
| + ChromeFileSystemDelegate();
|
| + ~ChromeFileSystemDelegate() override;
|
| +
|
| + // FileSystemDelegate:
|
| + base::FilePath GetDefaultDirectory() override;
|
| + std::unique_ptr<ui::SelectFilePolicy> CreateSelectFilePolicy(
|
| + content::WebContents* web_contents) override;
|
| + scoped_refptr<ui::SelectFileDialog> CreateSelectFileDialog(
|
| + ui::SelectFileDialog::Listener* listener,
|
| + std::unique_ptr<ui::SelectFilePolicy> policy) override;
|
| + void ShowSelectFileDialogForWebContents(
|
| + scoped_refptr<ui::SelectFileDialog> dialog,
|
| + content::WebContents* web_contents,
|
| + ui::SelectFileDialog::Type type,
|
| + const base::FilePath& default_path,
|
| + const ui::SelectFileDialog::FileTypeInfo* file_types) override;
|
| + void ConfirmSensitiveDirectoryAccess(bool has_write_permission,
|
| + const base::string16& app_name,
|
| + content::WebContents* web_contents,
|
| + const base::Closure& on_accept,
|
| + const base::Closure& on_cancel) override;
|
| + bool GetDescriptionIdForAcceptType(const std::string& accept_type,
|
| + int* description_id) override;
|
| +#if defined(OS_CHROMEOS)
|
| + bool IsGrantable(content::BrowserContext* browser_context,
|
| + content::RenderFrameHost* render_frame_host,
|
| + const Extension& extension) override;
|
| + void RequestFileSystem(content::BrowserContext* browser_context,
|
| + scoped_refptr<UIThreadExtensionFunction> requester,
|
| + const Extension& extension,
|
| + std::string volume_id,
|
| + bool writable,
|
| + const FileSystemCallback& success_callback,
|
| + const ErrorCallback& error_callback) override;
|
| + void GetVolumeList(content::BrowserContext* browser_context,
|
| + const VolumeListCallback& success_callback,
|
| + const ErrorCallback& error_callback) override;
|
| +#endif // defined(OS_CHROMEOS)
|
| + std::unique_ptr<file_system_api::SavedFilesServiceDelegate>
|
| + CreateSavedFilesServiceDelegate(
|
| + content::BrowserContext* browser_context) 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 Extension& extension,
|
| - const base::WeakPtr<file_manager::Volume>& volume,
|
| - bool writable,
|
| - const file_system_api::ConsentProvider::ShowDialogCallback&
|
| - callback) override;
|
| - void ShowNotification(const Extension& extension,
|
| - const base::WeakPtr<file_manager::Volume>& volume,
|
| - bool writable) override;
|
| - bool IsAutoLaunched(const Extension& extension) override;
|
| - bool IsWhitelistedComponent(const Extension& extension) override;
|
| -
|
| - Profile* const profile_;
|
| - content::RenderFrameHost* const host_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(ConsentProviderDelegate);
|
| +#if defined(OS_CHROMEOS)
|
| + void OnConsentReceived(content::BrowserContext* browser_context,
|
| + scoped_refptr<UIThreadExtensionFunction> requester,
|
| + const FileSystemCallback& success_callback,
|
| + const ErrorCallback& error_callback,
|
| + const std::string& extension,
|
| + const base::WeakPtr<file_manager::Volume>& volume,
|
| + bool writable,
|
| + file_system_api::ConsentProvider::Consent result);
|
| +#endif // defined(OS_CHROMEOS)
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ChromeFileSystemDelegate);
|
| };
|
|
|
| -} // namespace file_system_api
|
| } // namespace extensions
|
|
|
| -#endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_CONSENT_PROVIDER_H_
|
| +#endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_CHROME_FILE_SYSTEM_DELEGATE_H_
|
|
|