Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / core / dom / DocumentVisibilityObserver.h
blob967de8b2767baa7d291d1f087da699bfd7d7ddc4
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef DocumentVisibilityObserver_h
6 #define DocumentVisibilityObserver_h
8 #include "core/CoreExport.h"
9 #include "core/page/PageVisibilityState.h"
10 #include "platform/heap/Handle.h"
12 namespace blink {
14 class Document;
16 class CORE_EXPORT DocumentVisibilityObserver : public WillBeGarbageCollectedMixin {
17 WTF_MAKE_NONCOPYABLE(DocumentVisibilityObserver);
18 public:
19 explicit DocumentVisibilityObserver(Document&);
20 virtual ~DocumentVisibilityObserver();
22 virtual void didChangeVisibilityState(PageVisibilityState) = 0;
24 // Classes that inherit Node and DocumentVisibilityObserver must have a
25 // virtual override of Node::didMoveToNewDocument that calls
26 // DocumentVisibilityObserver::setDocument
27 void setObservedDocument(Document&);
29 protected:
30 DECLARE_VIRTUAL_TRACE();
32 private:
33 void registerObserver(Document&);
34 void unregisterObserver();
36 RawPtrWillBeMember<Document> m_document;
39 } // namespace blink
41 #endif // DocumentVisibilityObserver_h