danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 1 | // 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" |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 10 | #include "services/network/public/cpp/shared_url_loader_factory.h" |
| 11 | #include "third_party/blink/public/mojom/frame/frame.mojom.h" |
Minggang Wang | b9f3fa9 | 2021-07-01 15:30:31 | [diff] [blame] | 12 | #include "third_party/blink/public/mojom/navigation/navigation_params.mojom-forward.h" |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 13 | #include "url/gurl.h" |
| 14 | |
| 15 | namespace content { |
| 16 | |
| 17 | class SiteInstance; |
Yao Xiao | 1ac702d | 2022-06-08 17:20:49 | [diff] [blame^] | 18 | class RenderFrameHostImpl; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 19 | |
| 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. |
| 29 | bool 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 Xiao | 1ac702d | 2022-06-08 17:20:49 | [diff] [blame^] | 33 | // associated with |site_instance|. |current_rfh| represents the current frame |
| 34 | // on which OpenURL is being called |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 35 | // |
| 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 Xiao | 1ac702d | 2022-06-08 17:20:49 | [diff] [blame^] | 43 | bool VerifyOpenURLParams(RenderFrameHostImpl* current_rfh, |
| 44 | SiteInstance* site_instance, |
Yeunjoo Choi | 9232ea3 | 2021-03-08 16:25:17 | [diff] [blame] | 45 | const blink::mojom::OpenURLParamsPtr& params, |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 46 | 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. |
| 61 | bool VerifyBeginNavigationCommonParams( |
| 62 | SiteInstance* site_instance, |
Minggang Wang | b9f3fa9 | 2021-07-01 15:30:31 | [diff] [blame] | 63 | blink::mojom::CommonNavigationParams* common_params); |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 64 | |
Yao Xiao | 1ac702d | 2022-06-08 17:20:49 | [diff] [blame^] | 65 | // 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. |
| 76 | bool VerifyNavigationInitiator( |
| 77 | RenderFrameHostImpl* current_rfh, |
| 78 | const absl::optional<blink::LocalFrameToken>& initiator_frame_token, |
| 79 | int initiator_process_id); |
| 80 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 81 | } // namespace content |
| 82 | |
| 83 | #endif // CONTENT_BROWSER_RENDERER_HOST_IPC_UTILS_H_ |