blob: 15b07184a823d75e2534730ce1e04a3dfda52564 [file] [log] [blame]
lfg048201a2014-09-16 19:09:361// 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
5#ifndef EXTENSIONS_BROWSER_URL_REQUEST_UTIL_H_
6#define EXTENSIONS_BROWSER_URL_REQUEST_UTIL_H_
7
jam6adb8c22016-10-13 17:14:278#include <string>
9
Charlie Reise2c2c492018-06-15 21:34:0410#include "base/optional.h"
11#include "base/strings/string_piece.h"
Ken Rockot6414c4d92017-11-08 19:58:3212#include "content/public/common/resource_type.h"
jam6adb8c22016-10-13 17:14:2713#include "ui/base/page_transition_types.h"
14
Ken Rockot6414c4d92017-11-08 19:58:3215class GURL;
16
lfg048201a2014-09-16 19:09:3617namespace extensions {
18class Extension;
Ken Rockot6414c4d92017-11-08 19:58:3219class ExtensionSet;
20class ProcessMap;
lfg048201a2014-09-16 19:09:3621
22// Utilities related to URLRequest jobs for extension resources. See
23// chrome/browser/extensions/extension_protocols_unittest.cc for related tests.
24namespace url_request_util {
25
26// Sets allowed=true to allow a chrome-extension:// resource request coming from
vivek.vg33f197b2014-09-17 15:26:1827// renderer A to access a resource in an extension running in renderer B.
lfg048201a2014-09-16 19:09:3628// Returns false when it couldn't determine if the resource is allowed or not
Ken Rockot6414c4d92017-11-08 19:58:3229bool AllowCrossRendererResourceLoad(const GURL& url,
30 content::ResourceType resource_type,
31 ui::PageTransition page_transition,
32 int child_id,
lfg048201a2014-09-16 19:09:3633 bool is_incognito,
34 const Extension* extension,
Ken Rockot6414c4d92017-11-08 19:58:3235 const ExtensionSet& extensions,
36 const ProcessMap& process_map,
lfg048201a2014-09-16 19:09:3637 bool* allowed);
38
jam6adb8c22016-10-13 17:14:2739// Helper method that is called by both AllowCrossRendererResourceLoad and
40// ExtensionNavigationThrottle to share logic.
41// Sets allowed=true to allow a chrome-extension:// resource request coming from
42// renderer A to access a resource in an extension running in renderer B.
43// Returns false when it couldn't determine if the resource is allowed or not
44bool AllowCrossRendererResourceLoadHelper(bool is_guest,
45 const Extension* extension,
46 const Extension* owner_extension,
47 const std::string& partition_id,
Charlie Reise2c2c492018-06-15 21:34:0448 base::StringPiece resource_path,
jam6adb8c22016-10-13 17:14:2749 ui::PageTransition page_transition,
50 bool* allowed);
51
Charlie Reise2c2c492018-06-15 21:34:0452// Checks whether the given |extension| and |resource_path| are part of a
53// special case where an extension URL is permitted to load in any guest
54// process, rather than only in guests of a given platform app. If
55// |resource_path| is base::nullopt, then the check is based solely on which
56// extension is passed in, allowing this to be used for origin checks as well as
57// URL checks.
58// TODO(creis): Remove this method when the special cases (listed by bug number
59// in the definition of this method) are gone.
60bool AllowSpecialCaseExtensionURLInGuest(
61 const Extension* extension,
62 base::Optional<base::StringPiece> resource_path);
63
lfg048201a2014-09-16 19:09:3664} // namespace url_request_util
65} // namespace extensions
66
67#endif // EXTENSIONS_BROWSER_URL_REQUEST_UTIL_H_