blob: 902a42c7e00683ea49b65f1fd55165e29690fbcb [file] [log] [blame]
danakjc492bf82020-09-09 20:02:441// Copyright 2019 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 CONTENT_BROWSER_RENDERER_HOST_IPC_UTILS_H_
6#define CONTENT_BROWSER_RENDERER_HOST_IPC_UTILS_H_
7
8#include "base/memory/ref_counted.h"
9#include "content/common/frame.mojom.h"
danakjc492bf82020-09-09 20:02:4410#include "services/network/public/cpp/shared_url_loader_factory.h"
11#include "third_party/blink/public/mojom/frame/frame.mojom.h"
Minggang Wangb9f3fa92021-07-01 15:30:3112#include "third_party/blink/public/mojom/navigation/navigation_params.mojom-forward.h"
danakjc492bf82020-09-09 20:02:4413#include "url/gurl.h"
14
15namespace content {
16
17class SiteInstance;
Yao Xiao1ac702d2022-06-08 17:20:4918class RenderFrameHostImpl;
danakjc492bf82020-09-09 20:02:4419
20// Verifies that |params| are valid and can be accessed by the renderer process
21// associated with |site_instance|.
22//
23// If the |params| are valid, returns true.
24//
25// Otherwise, terminates the renderer associated with |site_instance| and
26// returns false.
27//
28// This function has to be called on the UI thread.
29bool VerifyDownloadUrlParams(SiteInstance* site_instance,
30 const blink::mojom::DownloadURLParams& params);
31
32// Verifies that |params| are valid and can be accessed by the renderer process
Yao Xiao1ac702d2022-06-08 17:20:4933// associated with |site_instance|. |current_rfh| represents the current frame
34// on which OpenURL is being called
danakjc492bf82020-09-09 20:02:4435//
36// Returns true if the |params| are valid. As a side-effect of the verification
37// |out_validated_url| and |out_blob_url_loader_factory| will be populated.
38//
39// Terminates the renderer the process associated with |site_instance| and
40// returns false if the |params| are invalid.
41//
42// This function has to be called on the UI thread.
Yao Xiao1ac702d2022-06-08 17:20:4943bool VerifyOpenURLParams(RenderFrameHostImpl* current_rfh,
44 SiteInstance* site_instance,
Yeunjoo Choi9232ea32021-03-08 16:25:1745 const blink::mojom::OpenURLParamsPtr& params,
danakjc492bf82020-09-09 20:02:4446 GURL* out_validated_url,
47 scoped_refptr<network::SharedURLLoaderFactory>*
48 out_blob_url_loader_factory);
49
50// Verifies that CommonNavigationParams are valid and can be accessed by the
51// renderer process associated with |site_instance|.
52//
53// Returns true if the CommonNavigationParams are valid. As a side-effect of
54// the verification parts of |common_params| will be rewritten (e.g. some
55// URLs will be filtered).
56//
57// Terminates the renderer the process associated with |site_instance| and
58// returns false if the CommonNavigationParams are invalid.
59//
60// This function has to be called on the UI thread.
61bool VerifyBeginNavigationCommonParams(
62 SiteInstance* site_instance,
Minggang Wangb9f3fa92021-07-01 15:30:3163 blink::mojom::CommonNavigationParams* common_params);
danakjc492bf82020-09-09 20:02:4464
Yao Xiao1ac702d2022-06-08 17:20:4965// Verify that the initiator frame identified by `initiator_frame_token` and
66// `initiator_process_id` can navigate `current_rfh`.
67//
68// This is best effort: the frame with the corresponding frame token may have
69// been deleted before the navigation begins.
70//
71// Returns true if the navigation is valid, or if the an initiator frame is not
72// found. Terminates the renderer the process associated with
73// |initiator_process_id| and returns false if the navigation is not allowed.
74//
75// This function has to be called on the UI thread.
76bool VerifyNavigationInitiator(
77 RenderFrameHostImpl* current_rfh,
78 const absl::optional<blink::LocalFrameToken>& initiator_frame_token,
79 int initiator_process_id);
80
danakjc492bf82020-09-09 20:02:4481} // namespace content
82
83#endif // CONTENT_BROWSER_RENDERER_HOST_IPC_UTILS_H_