| 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_PERMISSIONS_PERMISSIONS_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PERMISSIONS_PERMISSIONS_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_PERMISSIONS_PERMISSIONS_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_PERMISSIONS_PERMISSIONS_API_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/macros.h" |
| 11 #include "chrome/browser/extensions/chrome_extension_function.h" | 12 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 12 #include "chrome/browser/extensions/extension_install_prompt.h" | 13 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 13 #include "extensions/common/permissions/permission_set.h" | 14 #include "extensions/common/permissions/permission_set.h" |
| 14 | 15 |
| 15 namespace extensions { | 16 namespace extensions { |
| 16 | 17 |
| 17 // chrome.permissions.contains | 18 // chrome.permissions.contains |
| 18 class PermissionsContainsFunction : public ChromeSyncExtensionFunction { | 19 class PermissionsContainsFunction : public ChromeSyncExtensionFunction { |
| 19 public: | 20 public: |
| 20 DECLARE_EXTENSION_FUNCTION("permissions.contains", PERMISSIONS_CONTAINS) | 21 DECLARE_EXTENSION_FUNCTION("permissions.contains", PERMISSIONS_CONTAINS) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 44 DECLARE_EXTENSION_FUNCTION("permissions.remove", PERMISSIONS_REMOVE) | 45 DECLARE_EXTENSION_FUNCTION("permissions.remove", PERMISSIONS_REMOVE) |
| 45 | 46 |
| 46 protected: | 47 protected: |
| 47 ~PermissionsRemoveFunction() override {} | 48 ~PermissionsRemoveFunction() override {} |
| 48 | 49 |
| 49 // ExtensionFunction: | 50 // ExtensionFunction: |
| 50 bool RunSync() override; | 51 bool RunSync() override; |
| 51 }; | 52 }; |
| 52 | 53 |
| 53 // chrome.permissions.request | 54 // chrome.permissions.request |
| 54 class PermissionsRequestFunction : public ChromeAsyncExtensionFunction, | 55 class PermissionsRequestFunction : public ChromeAsyncExtensionFunction { |
| 55 public ExtensionInstallPrompt::Delegate { | |
| 56 public: | 56 public: |
| 57 DECLARE_EXTENSION_FUNCTION("permissions.request", PERMISSIONS_REQUEST) | 57 DECLARE_EXTENSION_FUNCTION("permissions.request", PERMISSIONS_REQUEST) |
| 58 | 58 |
| 59 PermissionsRequestFunction(); | 59 PermissionsRequestFunction(); |
| 60 | 60 |
| 61 // FOR TESTS ONLY to bypass the confirmation UI. | 61 // FOR TESTS ONLY to bypass the confirmation UI. |
| 62 static void SetAutoConfirmForTests(bool should_proceed); | 62 static void SetAutoConfirmForTests(bool should_proceed); |
| 63 static void SetIgnoreUserGestureForTests(bool ignore); | 63 static void SetIgnoreUserGestureForTests(bool ignore); |
| 64 | 64 |
| 65 // ExtensionInstallPrompt::Delegate: | |
| 66 void InstallUIProceed() override; | |
| 67 void InstallUIAbort(bool user_initiated) override; | |
| 68 | |
| 69 protected: | 65 protected: |
| 70 ~PermissionsRequestFunction() override; | 66 ~PermissionsRequestFunction() override; |
| 71 | 67 |
| 72 // ExtensionFunction: | 68 // ExtensionFunction: |
| 73 bool RunAsync() override; | 69 bool RunAsync() override; |
| 74 | 70 |
| 75 private: | 71 private: |
| 72 void OnInstallPromptDone(ExtensionInstallPrompt::Result result); |
| 73 |
| 76 scoped_ptr<ExtensionInstallPrompt> install_ui_; | 74 scoped_ptr<ExtensionInstallPrompt> install_ui_; |
| 77 scoped_ptr<const PermissionSet> requested_permissions_; | 75 scoped_ptr<const PermissionSet> requested_permissions_; |
| 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(PermissionsRequestFunction); |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 } // namespace extensions | 80 } // namespace extensions |
| 81 | 81 |
| 82 #endif // CHROME_BROWSER_EXTENSIONS_API_PERMISSIONS_PERMISSIONS_API_H_ | 82 #endif // CHROME_BROWSER_EXTENSIONS_API_PERMISSIONS_PERMISSIONS_API_H_ |
| OLD | NEW |