[email protected] | 1791e6c9 | 2014-04-11 08:29:01 | [diff] [blame] | 1 | // Copyright 2014 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 | |
lfg | 048201a | 2014-09-16 19:09:36 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_EXTENSIONS_CHROME_URL_REQUEST_UTIL_H_ |
| 6 | #define CHROME_BROWSER_EXTENSIONS_CHROME_URL_REQUEST_UTIL_H_ |
[email protected] | 1791e6c9 | 2014-04-11 08:29:01 | [diff] [blame] | 7 | |
| 8 | #include <string> |
| 9 | |
Ken Rockot | 6414c4d9 | 2017-11-08 19:58:32 | [diff] [blame] | 10 | #include "content/public/common/resource_type.h" |
| 11 | #include "content/public/common/url_loader.mojom.h" |
| 12 | #include "ui/base/page_transition_types.h" |
| 13 | |
| 14 | class GURL; |
| 15 | |
[email protected] | 1791e6c9 | 2014-04-11 08:29:01 | [diff] [blame] | 16 | namespace base { |
| 17 | class FilePath; |
| 18 | } |
| 19 | |
| 20 | namespace net { |
| 21 | class NetworkDelegate; |
| 22 | class URLRequest; |
| 23 | class URLRequestJob; |
| 24 | } |
| 25 | |
| 26 | namespace extensions { |
| 27 | class Extension; |
Ken Rockot | 6414c4d9 | 2017-11-08 19:58:32 | [diff] [blame] | 28 | class ExtensionSet; |
| 29 | class ProcessMap; |
[email protected] | 1791e6c9 | 2014-04-11 08:29:01 | [diff] [blame] | 30 | |
jamescook | 8816ae5 | 2014-09-05 17:02:37 | [diff] [blame] | 31 | // Utilities related to URLRequest jobs for extension resources. See |
| 32 | // chrome/browser/extensions/extension_protocols_unittest.cc for related tests. |
lfg | 048201a | 2014-09-16 19:09:36 | [diff] [blame] | 33 | namespace chrome_url_request_util { |
[email protected] | 1791e6c9 | 2014-04-11 08:29:01 | [diff] [blame] | 34 | |
lfg | 048201a | 2014-09-16 19:09:36 | [diff] [blame] | 35 | // Sets allowed=true to allow a chrome-extension:// resource request coming from |
vivek.vg | 33f197b | 2014-09-17 15:26:18 | [diff] [blame] | 36 | // renderer A to access a resource in an extension running in renderer B. |
lfg | 048201a | 2014-09-16 19:09:36 | [diff] [blame] | 37 | // Returns false when it couldn't determine if the resource is allowed or not |
Ken Rockot | 6414c4d9 | 2017-11-08 19:58:32 | [diff] [blame] | 38 | bool AllowCrossRendererResourceLoad(const GURL& url, |
| 39 | content::ResourceType resource_type, |
| 40 | ui::PageTransition page_transition, |
| 41 | int child_id, |
lfg | 3be3033 | 2014-09-18 15:47:26 | [diff] [blame] | 42 | bool is_incognito, |
| 43 | const Extension* extension, |
Ken Rockot | 6414c4d9 | 2017-11-08 19:58:32 | [diff] [blame] | 44 | const ExtensionSet& extensions, |
| 45 | const ProcessMap& process_map, |
lfg | 3be3033 | 2014-09-18 15:47:26 | [diff] [blame] | 46 | bool* allowed); |
[email protected] | 1791e6c9 | 2014-04-11 08:29:01 | [diff] [blame] | 47 | |
| 48 | // Creates a URLRequestJob for loading component extension resources out of |
| 49 | // a Chrome resource bundle. Returns NULL if the requested resource is not a |
| 50 | // component extension resource. |
| 51 | net::URLRequestJob* MaybeCreateURLRequestResourceBundleJob( |
| 52 | net::URLRequest* request, |
| 53 | net::NetworkDelegate* network_delegate, |
| 54 | const base::FilePath& directory_path, |
| 55 | const std::string& content_security_policy, |
| 56 | bool send_cors_header); |
| 57 | |
lfg | 048201a | 2014-09-16 19:09:36 | [diff] [blame] | 58 | } // namespace chrome_url_request_util |
[email protected] | 1791e6c9 | 2014-04-11 08:29:01 | [diff] [blame] | 59 | } // namespace extensions |
| 60 | |
lfg | 048201a | 2014-09-16 19:09:36 | [diff] [blame] | 61 | #endif // CHROME_BROWSER_EXTENSIONS_CHROME_URL_REQUEST_UTIL_H_ |