blob: f3b1fe9aaad65cc6027f782a2fe7c755b55b5b09 [file] [log] [blame]
[email protected]1791e6c92014-04-11 08:29:011// 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
lfg048201a2014-09-16 19:09:365#ifndef CHROME_BROWSER_EXTENSIONS_CHROME_URL_REQUEST_UTIL_H_
6#define CHROME_BROWSER_EXTENSIONS_CHROME_URL_REQUEST_UTIL_H_
[email protected]1791e6c92014-04-11 08:29:017
8#include <string>
9
Ken Rockot6414c4d92017-11-08 19:58:3210#include "content/public/common/resource_type.h"
Chris Mumford8f812662018-02-22 00:27:5711#include "services/network/public/mojom/url_loader.mojom.h"
Ken Rockot6414c4d92017-11-08 19:58:3212#include "ui/base/page_transition_types.h"
13
14class GURL;
15
[email protected]1791e6c92014-04-11 08:29:0116namespace base {
17class FilePath;
18}
19
[email protected]1791e6c92014-04-11 08:29:0120namespace extensions {
21class Extension;
Ken Rockot6414c4d92017-11-08 19:58:3222class ExtensionSet;
23class ProcessMap;
[email protected]1791e6c92014-04-11 08:29:0124
jamescook8816ae52014-09-05 17:02:3725// Utilities related to URLRequest jobs for extension resources. See
26// chrome/browser/extensions/extension_protocols_unittest.cc for related tests.
lfg048201a2014-09-16 19:09:3627namespace chrome_url_request_util {
[email protected]1791e6c92014-04-11 08:29:0128
lfg048201a2014-09-16 19:09:3629// Sets allowed=true to allow a chrome-extension:// resource request coming from
vivek.vg33f197b2014-09-17 15:26:1830// renderer A to access a resource in an extension running in renderer B.
lfg048201a2014-09-16 19:09:3631// Returns false when it couldn't determine if the resource is allowed or not
Ken Rockot6414c4d92017-11-08 19:58:3232bool AllowCrossRendererResourceLoad(const GURL& url,
33 content::ResourceType resource_type,
34 ui::PageTransition page_transition,
35 int child_id,
lfg3be30332014-09-18 15:47:2636 bool is_incognito,
37 const Extension* extension,
Ken Rockot6414c4d92017-11-08 19:58:3238 const ExtensionSet& extensions,
39 const ProcessMap& process_map,
lfg3be30332014-09-18 15:47:2640 bool* allowed);
[email protected]1791e6c92014-04-11 08:29:0141
Chris Mumford8f812662018-02-22 00:27:5742// Return the |request|'s resource path relative to the Chromium resources path
43// (chrome::DIR_RESOURCES) *if* the request refers to a resource within the
44// Chrome resource bundle. If not then the returned file path will be empty.
dpapad669a89702019-05-10 18:00:4945// |resource_id| is used to check whether the requested resource is registered
46// as a component extensions resource, via
47// ChromeComponentExtensionResourceManager::IsComponentExtensionResource()
Chris Mumford8f812662018-02-22 00:27:5748base::FilePath GetBundleResourcePath(
49 const network::ResourceRequest& request,
50 const base::FilePath& extension_resources_path,
dpapad669a89702019-05-10 18:00:4951 int* resource_id);
Chris Mumford8f812662018-02-22 00:27:5752
53// Creates and starts a URLLoader for loading component extension resources out
54// of a Chrome resource bundle. This should only be called if
55// GetBundleResourcePath returns a valid path.
56void LoadResourceFromResourceBundle(
57 const network::ResourceRequest& request,
58 network::mojom::URLLoaderRequest loader,
59 const base::FilePath& resource_relative_path,
dpapad669a89702019-05-10 18:00:4960 int resource_id,
Chris Mumford8f812662018-02-22 00:27:5761 const std::string& content_security_policy,
62 network::mojom::URLLoaderClientPtr client,
63 bool send_cors_header);
64
lfg048201a2014-09-16 19:09:3665} // namespace chrome_url_request_util
[email protected]1791e6c92014-04-11 08:29:0166} // namespace extensions
67
lfg048201a2014-09-16 19:09:3668#endif // CHROME_BROWSER_EXTENSIONS_CHROME_URL_REQUEST_UTIL_H_