summaryrefslogtreecommitdiffstats
path: root/chrome/browser/metrics/windowed_incognito_observer.h
blob: 30dd43133d471db8925f70e56f8d3ba211220778 (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
// Copyright 2015 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 CHROME_BROWSER_METRICS_WINDOWED_INCOGNITO_OBSERVER_H_
#define CHROME_BROWSER_METRICS_WINDOWED_INCOGNITO_OBSERVER_H_

#include "base/macros.h"
#include "chrome/browser/ui/browser_list_observer.h"

class Browser;

namespace metrics {

// This class watches for any incognito window being opened from the time it is
// instantiated to the time it is destroyed.
class WindowedIncognitoObserver : public chrome::BrowserListObserver {
 public:
  WindowedIncognitoObserver();
  ~WindowedIncognitoObserver() override;

  // This method can be checked to see whether any incognito window has been
  // opened since the time this object was created.
  bool incognito_launched() const {
    return incognito_launched_;
  }

 protected:
  // For testing.
  void set_incognito_launched(bool value) {
    incognito_launched_ = value;
  }

 private:
  // chrome::BrowserListObserver implementation.
  void OnBrowserAdded(Browser* browser) override;

  // Gets set if an incognito window was opened during the lifetime of the
  // object. Closing the window does not clear the flag.
  bool incognito_launched_;

  DISALLOW_COPY_AND_ASSIGN(WindowedIncognitoObserver);
};

}  // namespace metrics

#endif  // CHROME_BROWSER_METRICS_WINDOWED_INCOGNITO_OBSERVER_H_