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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PERMISSIONS_PERMISSIONS_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_PERMISSIONS_PERMISSIONS_API_H_
10 #include "base/compiler_specific.h"
11 #include "chrome/browser/extensions/chrome_extension_function.h"
12 #include "chrome/browser/extensions/extension_install_prompt.h"
13 #include "extensions/common/permissions/permission_set.h"
15 namespace extensions
{
17 // chrome.permissions.contains
18 class PermissionsContainsFunction
: public ChromeSyncExtensionFunction
{
20 DECLARE_EXTENSION_FUNCTION("permissions.contains", PERMISSIONS_CONTAINS
)
23 ~PermissionsContainsFunction() override
{}
26 bool RunSync() override
;
29 // chrome.permissions.getAll
30 class PermissionsGetAllFunction
: public ChromeSyncExtensionFunction
{
32 DECLARE_EXTENSION_FUNCTION("permissions.getAll", PERMISSIONS_GETALL
)
35 ~PermissionsGetAllFunction() override
{}
38 bool RunSync() override
;
41 // chrome.permissions.remove
42 class PermissionsRemoveFunction
: public ChromeSyncExtensionFunction
{
44 DECLARE_EXTENSION_FUNCTION("permissions.remove", PERMISSIONS_REMOVE
)
47 ~PermissionsRemoveFunction() override
{}
50 bool RunSync() override
;
53 // chrome.permissions.request
54 class PermissionsRequestFunction
: public ChromeAsyncExtensionFunction
,
55 public ExtensionInstallPrompt::Delegate
{
57 DECLARE_EXTENSION_FUNCTION("permissions.request", PERMISSIONS_REQUEST
)
59 PermissionsRequestFunction();
61 // FOR TESTS ONLY to bypass the confirmation UI.
62 static void SetAutoConfirmForTests(bool should_proceed
);
63 static void SetIgnoreUserGestureForTests(bool ignore
);
65 // ExtensionInstallPrompt::Delegate:
66 void InstallUIProceed() override
;
67 void InstallUIAbort(bool user_initiated
) override
;
70 ~PermissionsRequestFunction() override
;
73 bool RunAsync() override
;
76 scoped_ptr
<ExtensionInstallPrompt
> install_ui_
;
77 scoped_refptr
<extensions::PermissionSet
> requested_permissions_
;
80 } // namespace extensions
82 #endif // CHROME_BROWSER_EXTENSIONS_API_PERMISSIONS_PERMISSIONS_API_H_