blob: 7af67c0c81e0c1bb1780d656be55818d1ffc1233 [file] [log] [blame]
Avi Drissman4e1b7bc32022-09-15 14:03:501// Copyright 2018 The Chromium Authors
Lukasz Anforowicz7359e0b2018-01-03 21:26:292// 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 Anforowicz7359e0b2018-01-03 21:26:298class GURL;
9
10namespace url {
11class Origin;
12} // namespace url
13
14namespace content {
15
16class FrameTreeNode;
17class RenderFrameHost;
18class RenderFrameProxyHost;
19class RenderViewHost;
20
21// ScopedActiveURL calls ContentClient::SetActiveURL when constructed
22// and calls it again with empty arguments when destructed.
23class 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öm828b9022021-09-21 02:28:4341 ScopedActiveURL(const ScopedActiveURL&) = delete;
42 ScopedActiveURL& operator=(const ScopedActiveURL&) = delete;
43
Lukasz Anforowicz7359e0b2018-01-03 21:26:2944 // Calls ContentClient::SetActiveURL with empty arguments (to reset the crash
45 // keys).
46 ~ScopedActiveURL();
47
48 private:
49 explicit ScopedActiveURL(FrameTreeNode* node);
Lukasz Anforowicz7359e0b2018-01-03 21:26:2950};
51
52} // namespace content
53
54#endif // CONTENT_BROWSER_SCOPED_ACTIVE_URL_H_