summaryrefslogtreecommitdiff
path: root/chromium/ui/views/view_tracker.h
blob: 4ac408a5e700cc880dce443afa1e7cc9a041cc3b (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
// Copyright 2017 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 UI_VIEWS_VIEW_TRACKER_H_
#define UI_VIEWS_VIEW_TRACKER_H_

#include "base/macros.h"
#include "ui/views/view_observer.h"
#include "ui/views/views_export.h"

namespace views {

// ViewTracker tracks a single View. When the View is deleted it's removed.
class VIEWS_EXPORT ViewTracker : public ViewObserver {
 public:
  explicit ViewTracker(View* view = nullptr);
  ~ViewTracker() override;

  void SetView(View* view);
  void Clear() { SetView(nullptr); }
  View* view() { return view_; }

  // ViewObserver:
  void OnViewIsDeleting(View* observed_view) override;

 private:
  View* view_;

  DISALLOW_COPY_AND_ASSIGN(ViewTracker);
};

}  // namespace views

#endif  // UI_VIEWS_VIEW_TRACKER_H_