| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 std::vector<base::FilePath> GetGrayListedDirectories(); | 43 std::vector<base::FilePath> GetGrayListedDirectories(); |
| 44 | 44 |
| 45 #if defined(OS_CHROMEOS) | 45 #if defined(OS_CHROMEOS) |
| 46 | 46 |
| 47 // Requests consent for the chrome.fileSystem.requestFileSystem() method. | 47 // Requests consent for the chrome.fileSystem.requestFileSystem() method. |
| 48 class ConsentProvider { | 48 class ConsentProvider { |
| 49 public: | 49 public: |
| 50 enum Consent { CONSENT_GRANTED, CONSENT_REJECTED, CONSENT_IMPOSSIBLE }; | 50 enum Consent { CONSENT_GRANTED, CONSENT_REJECTED, CONSENT_IMPOSSIBLE }; |
| 51 | 51 |
| 52 typedef base::Callback<void(Consent)> ConsentCallback; | 52 typedef base::Callback<void(Consent)> ConsentCallback; |
| 53 typedef base::Callback< | 53 typedef base::Callback<void(const file_manager::VolumeInfo&, |
| 54 void(const file_manager::VolumeInfo&, bool, const ConsentCallback&)> | 54 bool, |
| 55 UserConsentRequestCallback; | 55 const ConsentCallback&)> AskUserCallback; |
| 56 typedef base::Callback<void(const file_manager::VolumeInfo&, bool)> |
| 57 NotifyUserCallback; |
| 56 typedef base::Callback<bool(const Extension&)> IsAutoLaunchedCallback; | 58 typedef base::Callback<bool(const Extension&)> IsAutoLaunchedCallback; |
| 57 | 59 |
| 58 explicit ConsentProvider( | 60 ConsentProvider(const AskUserCallback& ask_user_callback, |
| 59 const UserConsentRequestCallback& user_consent_request_callback); | 61 const NotifyUserCallback& notify_user_callback); |
| 60 ConsentProvider(); | 62 ConsentProvider(); |
| 61 ~ConsentProvider(); | 63 ~ConsentProvider(); |
| 62 | 64 |
| 63 // Requests consent for granting |writable| permissions to the |volume_info| | 65 // Requests consent for granting |writable| permissions to the |volume_info| |
| 64 // volume by the |extension|. | 66 // volume by the |extension|. |
| 65 void RequestConsent(const extensions::Extension& extension, | 67 void RequestConsent(const extensions::Extension& extension, |
| 66 const file_manager::VolumeInfo& volume_info, | 68 const file_manager::VolumeInfo& volume_info, |
| 67 bool writable, | 69 bool writable, |
| 68 const ConsentCallback& callback); | 70 const ConsentCallback& callback); |
| 69 | 71 |
| 70 // Checks whether the |extension| can be granted access. | 72 // Checks whether the |extension| can be granted access. |
| 71 bool IsGrantable(const extensions::Extension& extension); | 73 bool IsGrantable(const extensions::Extension& extension); |
| 72 | 74 |
| 73 // Fakes detection of auto-launch kiosk app for tests. | 75 // Fakes detection of auto-launch kiosk app for tests. |
| 74 void SetIsAutoLaunchedForTesting(const IsAutoLaunchedCallback& callback); | 76 void SetIsAutoLaunchedForTesting(const IsAutoLaunchedCallback& callback); |
| 75 | 77 |
| 76 // Sets custom list of whitelisted components for testing. | 78 // Sets custom list of whitelisted components for testing. |
| 77 void SetComponentWhitelistForTesting(const std::set<std::string>& whitelist); | 79 void SetComponentWhitelistForTesting(const std::set<std::string>& whitelist); |
| 78 | 80 |
| 79 private: | 81 private: |
| 80 const UserConsentRequestCallback user_consent_request_callback_; | 82 const AskUserCallback ask_user_callback_; |
| 83 const NotifyUserCallback notify_user_callback_; |
| 81 std::set<std::string> component_whitelist_; | 84 std::set<std::string> component_whitelist_; |
| 82 IsAutoLaunchedCallback is_auto_launched_callback_; | 85 IsAutoLaunchedCallback is_auto_launched_callback_; |
| 83 | 86 |
| 84 // Checks whether the |extension| is running in the auto-launch kiosk mode. | 87 // Checks whether the |extension| is running in the auto-launch kiosk mode. |
| 85 bool IsAutoLaunched(const Extension& extension); | 88 bool IsAutoLaunched(const Extension& extension); |
| 86 | 89 |
| 87 DISALLOW_COPY_AND_ASSIGN(ConsentProvider); | 90 DISALLOW_COPY_AND_ASSIGN(ConsentProvider); |
| 88 }; | 91 }; |
| 89 | 92 |
| 90 #endif | 93 #endif |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 | 318 |
| 316 private: | 319 private: |
| 317 ChromeExtensionFunctionDetails chrome_details_; | 320 ChromeExtensionFunctionDetails chrome_details_; |
| 318 #if defined(OS_CHROMEOS) | 321 #if defined(OS_CHROMEOS) |
| 319 scoped_ptr<file_system_api::ConsentProvider> consent_provider_; | 322 scoped_ptr<file_system_api::ConsentProvider> consent_provider_; |
| 320 #endif | 323 #endif |
| 321 static ui::DialogButton auto_dialog_button_for_testing_; | 324 static ui::DialogButton auto_dialog_button_for_testing_; |
| 322 | 325 |
| 323 #if defined(OS_CHROMEOS) | 326 #if defined(OS_CHROMEOS) |
| 324 // Requests user consent for accessing the volume identified by |name|. | 327 // Requests user consent for accessing the volume identified by |name|. |
| 325 void OnUserConsentRequested( | 328 void OnAskUser( |
| 326 const file_manager::VolumeInfo& volume_info, | 329 const file_manager::VolumeInfo& volume_info, |
| 327 bool writable, | 330 bool writable, |
| 328 const file_system_api::ConsentProvider::ConsentCallback& callback); | 331 const file_system_api::ConsentProvider::ConsentCallback& callback); |
| 329 | 332 |
| 333 // Notifies user about automatically granted permissions for a kiosk app. |
| 334 void OnNotifyUser(const file_manager::VolumeInfo& volume_info, bool writable); |
| 335 |
| 330 // Called when the consent dialog is classed, and executed |callback| with | 336 // Called when the consent dialog is classed, and executed |callback| with |
| 331 // a consent result. | 337 // a consent result. |
| 332 void OnUserConsentDialogClosed( | 338 void OnUserConsentDialogClosed( |
| 333 const file_system_api::ConsentProvider::ConsentCallback& callback, | 339 const file_system_api::ConsentProvider::ConsentCallback& callback, |
| 334 ui::DialogButton result); | 340 ui::DialogButton result); |
| 335 | 341 |
| 336 // Called when a user grants or rejects permissions for the file system | 342 // Called when a user grants or rejects permissions for the file system |
| 337 // access. | 343 // access. |
| 338 void OnConsentReceived(const std::string& volume_id, | 344 void OnConsentReceived(const std::string& volume_id, |
| 339 bool writable, | 345 bool writable, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 354 // UIThreadExtensionFunction overrides. | 360 // UIThreadExtensionFunction overrides. |
| 355 ExtensionFunction::ResponseAction Run() override; | 361 ExtensionFunction::ResponseAction Run() override; |
| 356 | 362 |
| 357 private: | 363 private: |
| 358 ChromeExtensionFunctionDetails chrome_details_; | 364 ChromeExtensionFunctionDetails chrome_details_; |
| 359 }; | 365 }; |
| 360 | 366 |
| 361 } // namespace extensions | 367 } // namespace extensions |
| 362 | 368 |
| 363 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ | 369 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ |
| OLD | NEW |