Avi Drissman | 4e1b7bc3 | 2022-09-15 14:03:50 | [diff] [blame] | 1 | // Copyright 2018 The Chromium Authors |
Lukasz Anforowicz | 7359e0b | 2018-01-03 21:26:29 | [diff] [blame] | 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_SCOPED_ACTIVE_URL_H_ |
| 6 | #define CONTENT_BROWSER_SCOPED_ACTIVE_URL_H_ |
| 7 | |
Lukasz Anforowicz | 7359e0b | 2018-01-03 21:26:29 | [diff] [blame] | 8 | class GURL; |
| 9 | |
| 10 | namespace url { |
| 11 | class Origin; |
| 12 | } // namespace url |
| 13 | |
| 14 | namespace content { |
| 15 | |
| 16 | class FrameTreeNode; |
| 17 | class RenderFrameHost; |
| 18 | class RenderFrameProxyHost; |
| 19 | class RenderViewHost; |
| 20 | |
| 21 | // ScopedActiveURL calls ContentClient::SetActiveURL when constructed |
| 22 | // and calls it again with empty arguments when destructed. |
| 23 | class ScopedActiveURL { |
| 24 | public: |
| 25 | // Calls ContentClient::SetActiveURL with |active_url| and |top_origin| (to |
| 26 | // set the crash keys). |
| 27 | ScopedActiveURL(const GURL& active_url, const url::Origin& top_origin); |
| 28 | |
| 29 | // Convenience constructor, calculating |active_url| and |top_origin| based on |
| 30 | // |frame|'s last committed origin and main frame. |
| 31 | explicit ScopedActiveURL(RenderFrameHost* frame); |
| 32 | |
| 33 | // Convenience constructor, calculating |active_url| and |top_origin| based on |
| 34 | // |proxy|'s last committed origin and main frame. |
| 35 | explicit ScopedActiveURL(RenderFrameProxyHost* proxy); |
| 36 | |
| 37 | // Convenience constructor, calculating |active_url| and |top_origin| based on |
| 38 | // the frame tree node of |view|'s main frame. |
| 39 | explicit ScopedActiveURL(RenderViewHost* view); |
| 40 | |
Peter Boström | 828b902 | 2021-09-21 02:28:43 | [diff] [blame] | 41 | ScopedActiveURL(const ScopedActiveURL&) = delete; |
| 42 | ScopedActiveURL& operator=(const ScopedActiveURL&) = delete; |
| 43 | |
Lukasz Anforowicz | 7359e0b | 2018-01-03 21:26:29 | [diff] [blame] | 44 | // Calls ContentClient::SetActiveURL with empty arguments (to reset the crash |
| 45 | // keys). |
| 46 | ~ScopedActiveURL(); |
| 47 | |
| 48 | private: |
| 49 | explicit ScopedActiveURL(FrameTreeNode* node); |
Lukasz Anforowicz | 7359e0b | 2018-01-03 21:26:29 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | } // namespace content |
| 53 | |
| 54 | #endif // CONTENT_BROWSER_SCOPED_ACTIVE_URL_H_ |