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 class ExtensionService
;
17 namespace extensions
{
19 // chrome.permissions.contains
20 class PermissionsContainsFunction
: public ChromeSyncExtensionFunction
{
22 DECLARE_EXTENSION_FUNCTION("permissions.contains", PERMISSIONS_CONTAINS
)
25 virtual ~PermissionsContainsFunction() {}
28 virtual bool RunSync() OVERRIDE
;
31 // chrome.permissions.getAll
32 class PermissionsGetAllFunction
: public ChromeSyncExtensionFunction
{
34 DECLARE_EXTENSION_FUNCTION("permissions.getAll", PERMISSIONS_GETALL
)
37 virtual ~PermissionsGetAllFunction() {}
40 virtual bool RunSync() OVERRIDE
;
43 // chrome.permissions.remove
44 class PermissionsRemoveFunction
: public ChromeSyncExtensionFunction
{
46 DECLARE_EXTENSION_FUNCTION("permissions.remove", PERMISSIONS_REMOVE
)
49 virtual ~PermissionsRemoveFunction() {}
52 virtual bool RunSync() OVERRIDE
;
55 // chrome.permissions.request
56 class PermissionsRequestFunction
: public ChromeAsyncExtensionFunction
,
57 public ExtensionInstallPrompt::Delegate
{
59 DECLARE_EXTENSION_FUNCTION("permissions.request", PERMISSIONS_REQUEST
)
61 PermissionsRequestFunction();
63 // FOR TESTS ONLY to bypass the confirmation UI.
64 static void SetAutoConfirmForTests(bool should_proceed
);
65 static void SetIgnoreUserGestureForTests(bool ignore
);
67 // ExtensionInstallPrompt::Delegate:
68 virtual void InstallUIProceed() OVERRIDE
;
69 virtual void InstallUIAbort(bool user_initiated
) OVERRIDE
;
72 virtual ~PermissionsRequestFunction();
75 virtual bool RunImpl() OVERRIDE
;
78 scoped_ptr
<ExtensionInstallPrompt
> install_ui_
;
79 scoped_refptr
<extensions::PermissionSet
> requested_permissions_
;
82 } // namespace extensions
84 #endif // CHROME_BROWSER_EXTENSIONS_API_PERMISSIONS_PERMISSIONS_API_H_