Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / core / dom / ScopedWindowFocusAllowedIndicator.h
blob66e353b2372140699e32306e3d0f6a086747788a
1 // Copyright 2014 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 ScopedWindowFocusAllowedIndicator_h
6 #define ScopedWindowFocusAllowedIndicator_h
8 #include "core/dom/ContextLifecycleObserver.h"
9 #include "core/dom/ExecutionContext.h"
10 #include "wtf/Noncopyable.h"
12 namespace blink {
14 class ScopedWindowFocusAllowedIndicator final {
15 WTF_MAKE_FAST_ALLOCATED(ScopedWindowFocusAllowedIndicator);
16 WTF_MAKE_NONCOPYABLE(ScopedWindowFocusAllowedIndicator);
17 public:
18 explicit ScopedWindowFocusAllowedIndicator(ExecutionContext* executionContext)
19 : m_observer(adoptPtrWillBeNoop(new Observer(executionContext)))
22 ~ScopedWindowFocusAllowedIndicator()
24 m_observer->dispose();
27 private:
28 class Observer final : public NoBaseWillBeGarbageCollectedFinalized<Observer>, public ContextLifecycleObserver {
29 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Observer);
30 public:
31 explicit Observer(ExecutionContext* executionContext)
32 : ContextLifecycleObserver(executionContext)
34 if (executionContext)
35 executionContext->allowWindowInteraction();
38 void dispose()
40 if (executionContext())
41 executionContext()->consumeWindowInteraction();
44 DEFINE_INLINE_TRACE()
46 ContextLifecycleObserver::trace(visitor);
50 // In Oilpan, destructors are not allowed to touch other on-heap objects.
51 // The Observer indirection is needed to keep
52 // ScopedWindowFocusAllowedIndicator off-heap and thus allows its destructor
53 // to call executionContext()->consumeWindowInteraction().
54 OwnPtrWillBePersistent<Observer> m_observer;
57 } // namespace blink
59 #endif // ScopedWindowFocusAllowedIndicator_h