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 file_system_api::ConsentProviderDelegate consent_provider_delegate_; | 395 file_system_api::ConsentProviderDelegate consent_provider_delegate_; |
387 file_system_api::ConsentProvider consent_provider_; | 396 file_system_api::ConsentProvider consent_provider_; |
388 }; | 397 }; |
389 | 398 |
390 // Requests a list of available volumes. | 399 // Requests a list of available volumes. |
391 class FileSystemGetVolumeListFunction : public UIThreadExtensionFunction { | 400 class FileSystemGetVolumeListFunction : public UIThreadExtensionFunction { |
(...skipping 11 matching lines...) Expand all Loading... |
403 private: | 412 private: |
404 ChromeExtensionFunctionDetails chrome_details_; | 413 ChromeExtensionFunctionDetails chrome_details_; |
405 file_system_api::ConsentProviderDelegate consent_provider_delegate_; | 414 file_system_api::ConsentProviderDelegate consent_provider_delegate_; |
406 file_system_api::ConsentProvider consent_provider_; | 415 file_system_api::ConsentProvider consent_provider_; |
407 }; | 416 }; |
408 #endif | 417 #endif |
409 | 418 |
410 } // namespace extensions | 419 } // namespace extensions |
411 | 420 |
412 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ | 421 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ |
OLD | NEW |