blob: f0abc10015cc9f4333212ef60e477167a1b6d6ee [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
Julie Jeongeun Kimf65376f2019-11-05 03:54:5510#include "mojo/public/cpp/bindings/pending_receiver.h"
Julie Jeongeun Kim6dd4c7b2019-11-18 05:56:3011#include "mojo/public/cpp/bindings/pending_remote.h"
Gyuyoung Kima6b76782020-01-17 00:56:0412#include "services/network/public/mojom/url_loader.mojom-forward.h"
Minggang Wangee5af392020-02-05 02:55:2813#include "third_party/blink/public/mojom/loader/resource_load_info.mojom-shared.h"
Ken Rockot6414c4d92017-11-08 19:58:3214#include "ui/base/page_transition_types.h"
15
16class GURL;
17
[email protected]1791e6c92014-04-11 08:29:0118namespace base {
19class FilePath;
20}
21
Ken Rockot33f8dfb2020-08-31 20:17:4022namespace network {
23struct ResourceRequest;
24}
25
[email protected]1791e6c92014-04-11 08:29:0126namespace extensions {
27class Extension;
Ken Rockot6414c4d92017-11-08 19:58:3228class ExtensionSet;
29class ProcessMap;
[email protected]1791e6c92014-04-11 08:29:0130
jamescook8816ae52014-09-05 17:02:3731// Utilities related to URLRequest jobs for extension resources. See
32// chrome/browser/extensions/extension_protocols_unittest.cc for related tests.
lfg048201a2014-09-16 19:09:3633namespace chrome_url_request_util {
[email protected]1791e6c92014-04-11 08:29:0134
lfg048201a2014-09-16 19:09:3635// Sets allowed=true to allow a chrome-extension:// resource request coming from
vivek.vg33f197b2014-09-17 15:26:1836// renderer A to access a resource in an extension running in renderer B.
lfg048201a2014-09-16 19:09:3637// Returns false when it couldn't determine if the resource is allowed or not
Ken Rockot6414c4d92017-11-08 19:58:3238bool AllowCrossRendererResourceLoad(const GURL& url,
Minggang Wangee5af392020-02-05 02:55:2839 blink::mojom::ResourceType resource_type,
Ken Rockot6414c4d92017-11-08 19:58:3240 ui::PageTransition page_transition,
41 int child_id,
lfg3be30332014-09-18 15:47:2642 bool is_incognito,
43 const Extension* extension,
Ken Rockot6414c4d92017-11-08 19:58:3244 const ExtensionSet& extensions,
45 const ProcessMap& process_map,
lfg3be30332014-09-18 15:47:2646 bool* allowed);
[email protected]1791e6c92014-04-11 08:29:0147
Chris Mumford8f812662018-02-22 00:27:5748// Return the |request|'s resource path relative to the Chromium resources path
49// (chrome::DIR_RESOURCES) *if* the request refers to a resource within the
50// Chrome resource bundle. If not then the returned file path will be empty.
dpapad669a89702019-05-10 18:00:4951// |resource_id| is used to check whether the requested resource is registered
52// as a component extensions resource, via
53// ChromeComponentExtensionResourceManager::IsComponentExtensionResource()
Chris Mumford8f812662018-02-22 00:27:5754base::FilePath GetBundleResourcePath(
55 const network::ResourceRequest& request,
56 const base::FilePath& extension_resources_path,
dpapad669a89702019-05-10 18:00:4957 int* resource_id);
Chris Mumford8f812662018-02-22 00:27:5758
59// Creates and starts a URLLoader for loading component extension resources out
60// of a Chrome resource bundle. This should only be called if
61// GetBundleResourcePath returns a valid path.
62void LoadResourceFromResourceBundle(
63 const network::ResourceRequest& request,
Julie Jeongeun Kimf65376f2019-11-05 03:54:5564 mojo::PendingReceiver<network::mojom::URLLoader> loader,
Chris Mumford8f812662018-02-22 00:27:5765 const base::FilePath& resource_relative_path,
dpapad669a89702019-05-10 18:00:4966 int resource_id,
Chris Mumford8f812662018-02-22 00:27:5767 const std::string& content_security_policy,
Julie Jeongeun Kim6dd4c7b2019-11-18 05:56:3068 mojo::PendingRemote<network::mojom::URLLoaderClient> client,
Chris Mumford8f812662018-02-22 00:27:5769 bool send_cors_header);
70
lfg048201a2014-09-16 19:09:3671} // namespace chrome_url_request_util
[email protected]1791e6c92014-04-11 08:29:0172} // namespace extensions
73
lfg048201a2014-09-16 19:09:3674#endif // CHROME_BROWSER_EXTENSIONS_CHROME_URL_REQUEST_UTIL_H_