1 // 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 8 #include <string> 9 #include <vector> 10 11 #include "chrome/browser/extensions/permissions_updater.h" 12 13 namespace content { 14 class BrowserContext; 15 } // namespace content 16 17 namespace extensions { 18 19 class Extension; 20 class PermissionSet; 21 class URLPatternSet; 22 23 namespace permissions_test_util { 24 25 // 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. 28 std::vector<std::string> GetPatternsAsStrings(const URLPatternSet& patterns); 29 30 // Calls corresponding PermissionsUpdater method respectively and wait for its 31 // asynchronous completion. 32 void GrantOptionalPermissionsAndWaitForCompletion( 33 content::BrowserContext* browser_context, 34 const Extension& extension, 35 const PermissionSet& permissions); 36 void GrantRuntimePermissionsAndWaitForCompletion( 37 content::BrowserContext* browser_context, 38 const Extension& extension, 39 const PermissionSet& permissions); 40 void RevokeOptionalPermissionsAndWaitForCompletion( 41 content::BrowserContext* browser_context, 42 const Extension& extension, 43 const PermissionSet& permissions, 44 PermissionsUpdater::RemoveType remove_type); 45 void 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_ 54