| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 public: | 54 public: |
| 55 enum Consent { CONSENT_GRANTED, CONSENT_REJECTED, CONSENT_IMPOSSIBLE }; | 55 enum Consent { CONSENT_GRANTED, CONSENT_REJECTED, CONSENT_IMPOSSIBLE }; |
| 56 typedef base::Callback<void(Consent)> ConsentCallback; | 56 typedef base::Callback<void(Consent)> ConsentCallback; |
| 57 typedef base::Callback<void(ui::DialogButton)> ShowDialogCallback; | 57 typedef base::Callback<void(ui::DialogButton)> ShowDialogCallback; |
| 58 | 58 |
| 59 // Interface for delegating user interaction for granting permissions. | 59 // Interface for delegating user interaction for granting permissions. |
| 60 class DelegateInterface { | 60 class DelegateInterface { |
| 61 public: | 61 public: |
| 62 // Shows a dialog for granting permissions. | 62 // Shows a dialog for granting permissions. |
| 63 virtual void ShowDialog(const extensions::Extension& extension, | 63 virtual void ShowDialog(const extensions::Extension& extension, |
| 64 base::WeakPtr<file_manager::Volume> volume, | 64 const base::WeakPtr<file_manager::Volume>& volume, |
| 65 bool writable, | 65 bool writable, |
| 66 const ShowDialogCallback& callback) = 0; | 66 const ShowDialogCallback& callback) = 0; |
| 67 | 67 |
| 68 // Shows a notification about permissions automatically granted access. |
| 69 virtual void ShowNotification( |
| 70 const extensions::Extension& extension, |
| 71 const base::WeakPtr<file_manager::Volume>& volume, |
| 72 bool writable) = 0; |
| 73 |
| 68 // Checks if the extension was launched in auto-launch kiosk mode. | 74 // Checks if the extension was launched in auto-launch kiosk mode. |
| 69 virtual bool IsAutoLaunched(const extensions::Extension& extension) = 0; | 75 virtual bool IsAutoLaunched(const extensions::Extension& extension) = 0; |
| 70 | 76 |
| 71 // Checks if the extension is a whitelisted component extension or app. | 77 // Checks if the extension is a whitelisted component extension or app. |
| 72 virtual bool IsWhitelistedComponent( | 78 virtual bool IsWhitelistedComponent( |
| 73 const extensions::Extension& extension) = 0; | 79 const extensions::Extension& extension) = 0; |
| 74 }; | 80 }; |
| 75 | 81 |
| 76 explicit ConsentProvider(DelegateInterface* delegate); | 82 explicit ConsentProvider(DelegateInterface* delegate); |
| 77 ~ConsentProvider(); | 83 ~ConsentProvider(); |
| 78 | 84 |
| 79 // Requests consent for granting |writable| permissions to the |volume| | 85 // Requests consent for granting |writable| permissions to the |volume| |
| 80 // volume by the |extension|. Must be called only if the extension is | 86 // volume by the |extension|. Must be called only if the extension is |
| 81 // grantable, which can be checked with IsGrantable(). | 87 // grantable, which can be checked with IsGrantable(). |
| 82 void RequestConsent(const extensions::Extension& extension, | 88 void RequestConsent(const extensions::Extension& extension, |
| 83 base::WeakPtr<file_manager::Volume> volume, | 89 const base::WeakPtr<file_manager::Volume>& volume, |
| 84 bool writable, | 90 bool writable, |
| 85 const ConsentCallback& callback); | 91 const ConsentCallback& callback); |
| 86 | 92 |
| 87 // Checks whether the |extension| can be granted access. | 93 // Checks whether the |extension| can be granted access. |
| 88 bool IsGrantable(const extensions::Extension& extension); | 94 bool IsGrantable(const extensions::Extension& extension); |
| 89 | 95 |
| 90 private: | 96 private: |
| 91 DelegateInterface* const delegate_; | 97 DelegateInterface* const delegate_; |
| 92 | 98 |
| 93 // Converts the clicked button to a consent result and passes it via the | 99 // Converts the clicked button to a consent result and passes it via the |
| (...skipping 13 matching lines...) Expand all Loading... |
| 107 | 113 |
| 108 private: | 114 private: |
| 109 friend ScopedSkipRequestFileSystemDialog; | 115 friend ScopedSkipRequestFileSystemDialog; |
| 110 | 116 |
| 111 // Sets a fake result for the user consent dialog. If ui::DIALOG_BUTTON_NONE | 117 // Sets a fake result for the user consent dialog. If ui::DIALOG_BUTTON_NONE |
| 112 // then disabled. | 118 // then disabled. |
| 113 static void SetAutoDialogButtonForTest(ui::DialogButton button); | 119 static void SetAutoDialogButtonForTest(ui::DialogButton button); |
| 114 | 120 |
| 115 // ConsentProvider::DelegateInterface overrides: | 121 // ConsentProvider::DelegateInterface overrides: |
| 116 void ShowDialog(const extensions::Extension& extension, | 122 void ShowDialog(const extensions::Extension& extension, |
| 117 base::WeakPtr<file_manager::Volume> volume, | 123 const base::WeakPtr<file_manager::Volume>& volume, |
| 118 bool writable, | 124 bool writable, |
| 119 const file_system_api::ConsentProvider::ShowDialogCallback& | 125 const file_system_api::ConsentProvider::ShowDialogCallback& |
| 120 callback) override; | 126 callback) override; |
| 127 void ShowNotification(const extensions::Extension& extension, |
| 128 const base::WeakPtr<file_manager::Volume>& volume, |
| 129 bool writable) override; |
| 121 bool IsAutoLaunched(const extensions::Extension& extension) override; | 130 bool IsAutoLaunched(const extensions::Extension& extension) override; |
| 122 bool IsWhitelistedComponent(const extensions::Extension& extension) override; | 131 bool IsWhitelistedComponent(const extensions::Extension& extension) override; |
| 123 | 132 |
| 124 Profile* const profile_; | 133 Profile* const profile_; |
| 125 content::RenderViewHost* const host_; | 134 content::RenderViewHost* const host_; |
| 126 | 135 |
| 127 DISALLOW_COPY_AND_ASSIGN(ConsentProviderDelegate); | 136 DISALLOW_COPY_AND_ASSIGN(ConsentProviderDelegate); |
| 128 }; | 137 }; |
| 129 #endif | 138 #endif |
| 130 | 139 |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 | 380 |
| 372 protected: | 381 protected: |
| 373 ~FileSystemRequestFileSystemFunction() override; | 382 ~FileSystemRequestFileSystemFunction() override; |
| 374 | 383 |
| 375 // UIThreadExtensionFunction overrides. | 384 // UIThreadExtensionFunction overrides. |
| 376 ExtensionFunction::ResponseAction Run() override; | 385 ExtensionFunction::ResponseAction Run() override; |
| 377 | 386 |
| 378 private: | 387 private: |
| 379 // Called when a user grants or rejects permissions for the file system | 388 // Called when a user grants or rejects permissions for the file system |
| 380 // access. | 389 // access. |
| 381 void OnConsentReceived(base::WeakPtr<file_manager::Volume> volume, | 390 void OnConsentReceived(const base::WeakPtr<file_manager::Volume>& volume, |
| 382 bool writable, | 391 bool writable, |
| 383 file_system_api::ConsentProvider::Consent result); | 392 file_system_api::ConsentProvider::Consent result); |
| 384 | 393 |
| 385 ChromeExtensionFunctionDetails chrome_details_; | 394 ChromeExtensionFunctionDetails chrome_details_; |
| 386 }; | 395 }; |
| 387 | 396 |
| 388 // Requests a list of available volumes. | 397 // Requests a list of available volumes. |
| 389 class FileSystemGetVolumeListFunction : public UIThreadExtensionFunction { | 398 class FileSystemGetVolumeListFunction : public UIThreadExtensionFunction { |
| 390 public: | 399 public: |
| 391 DECLARE_EXTENSION_FUNCTION("fileSystem.getVolumeList", | 400 DECLARE_EXTENSION_FUNCTION("fileSystem.getVolumeList", |
| 392 FILESYSTEM_GETVOLUMELIST); | 401 FILESYSTEM_GETVOLUMELIST); |
| 393 FileSystemGetVolumeListFunction(); | 402 FileSystemGetVolumeListFunction(); |
| 394 | 403 |
| 395 protected: | 404 protected: |
| 396 ~FileSystemGetVolumeListFunction() override; | 405 ~FileSystemGetVolumeListFunction() override; |
| 397 | 406 |
| 398 // UIThreadExtensionFunction overrides. | 407 // UIThreadExtensionFunction overrides. |
| 399 ExtensionFunction::ResponseAction Run() override; | 408 ExtensionFunction::ResponseAction Run() override; |
| 400 | 409 |
| 401 private: | 410 private: |
| 402 ChromeExtensionFunctionDetails chrome_details_; | 411 ChromeExtensionFunctionDetails chrome_details_; |
| 403 }; | 412 }; |
| 404 #endif | 413 #endif |
| 405 | 414 |
| 406 } // namespace extensions | 415 } // namespace extensions |
| 407 | 416 |
| 408 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ | 417 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ |
| OLD | NEW |