summaryrefslogtreecommitdiffstats
path: root/chromium/content/browser/scoped_active_url.h
blob: 58f649ae3d100f224f435eb8114da93acf2173f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_SCOPED_ACTIVE_URL_H_
#define CONTENT_BROWSER_SCOPED_ACTIVE_URL_H_

#include "base/macros.h"

class GURL;

namespace url {
class Origin;
}  // namespace url

namespace content {

class FrameTreeNode;
class RenderFrameHost;
class RenderFrameProxyHost;
class RenderViewHost;

// ScopedActiveURL calls ContentClient::SetActiveURL when constructed
// and calls it again with empty arguments when destructed.
class ScopedActiveURL {
 public:
  // Calls ContentClient::SetActiveURL with |active_url| and |top_origin| (to
  // set the crash keys).
  ScopedActiveURL(const GURL& active_url, const url::Origin& top_origin);

  // Convenience constructor, calculating |active_url| and |top_origin| based on
  // |frame|'s last committed origin and main frame.
  explicit ScopedActiveURL(RenderFrameHost* frame);

  // Convenience constructor, calculating |active_url| and |top_origin| based on
  // |proxy|'s last committed origin and main frame.
  explicit ScopedActiveURL(RenderFrameProxyHost* proxy);

  // Convenience constructor, calculating |active_url| and |top_origin| based on
  // the frame tree node of |view|'s main frame.
  explicit ScopedActiveURL(RenderViewHost* view);

  // Calls ContentClient::SetActiveURL with empty arguments (to reset the crash
  // keys).
  ~ScopedActiveURL();

 private:
  explicit ScopedActiveURL(FrameTreeNode* node);

  DISALLOW_COPY_AND_ASSIGN(ScopedActiveURL);
};

}  // namespace content

#endif  // CONTENT_BROWSER_SCOPED_ACTIVE_URL_H_