blob: 7602d9dcb5918e9aee5f3701694b20ce8cfef766 [file] [log] [blame]
Takashi Toyoshima69579072018-11-19 07:10:501// Copyright 2018 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.
4
5#ifndef CHROME_BROWSER_EXTENSIONS_PERMISSIONS_TEST_UTIL_H_
6#define CHROME_BROWSER_EXTENSIONS_PERMISSIONS_TEST_UTIL_H_
7
Devlin Cronine342f4d2018-11-21 21:59:118#include <string>
9#include <vector>
10
Takashi Toyoshima69579072018-11-19 07:10:5011#include "chrome/browser/extensions/permissions_updater.h"
12
13namespace content {
14class BrowserContext;
15} // namespace content
16
17namespace extensions {
18
19class Extension;
20class PermissionSet;
Devlin Cronine342f4d2018-11-21 21:59:1121class URLPatternSet;
Takashi Toyoshima69579072018-11-19 07:10:5022
23namespace permissions_test_util {
24
Devlin Cronine342f4d2018-11-21 21:59:1125// Returns a list of |patterns| as strings, making it easy to compare for
26// equality with readable errors. This will omit the chrome://favicon host, if
27// present, from the result.
28std::vector<std::string> GetPatternsAsStrings(const URLPatternSet& patterns);
29
Takashi Toyoshima69579072018-11-19 07:10:5030// Calls corresponding PermissionsUpdater method respectively and wait for its
31// asynchronous completion.
32void GrantOptionalPermissionsAndWaitForCompletion(
33 content::BrowserContext* browser_context,
34 const Extension& extension,
35 const PermissionSet& permissions);
36void GrantRuntimePermissionsAndWaitForCompletion(
37 content::BrowserContext* browser_context,
38 const Extension& extension,
39 const PermissionSet& permissions);
40void RevokeOptionalPermissionsAndWaitForCompletion(
41 content::BrowserContext* browser_context,
42 const Extension& extension,
43 const PermissionSet& permissions,
44 PermissionsUpdater::RemoveType remove_type);
45void RevokeRuntimePermissionsAndWaitForCompletion(
46 content::BrowserContext* browser_context,
47 const Extension& extension,
48 const PermissionSet& permissions);
49
50} // namespace permissions_test_util
51} // namespace extensions
52
53#endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_TEST_UTIL_H_