| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ScopedWindowFocusAllowedIndicator_h | 5 #ifndef ScopedWindowFocusAllowedIndicator_h |
| 6 #define ScopedWindowFocusAllowedIndicator_h | 6 #define ScopedWindowFocusAllowedIndicator_h |
| 7 | 7 |
| 8 #include "core/dom/ExecutionContext.h" | 8 #include "core/dom/ExecutionContext.h" |
| 9 #include "wtf/Noncopyable.h" | 9 #include "platform/wtf/Noncopyable.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 class ScopedWindowFocusAllowedIndicator final { | 13 class ScopedWindowFocusAllowedIndicator final { |
| 14 USING_FAST_MALLOC(ScopedWindowFocusAllowedIndicator); | 14 USING_FAST_MALLOC(ScopedWindowFocusAllowedIndicator); |
| 15 WTF_MAKE_NONCOPYABLE(ScopedWindowFocusAllowedIndicator); | 15 WTF_MAKE_NONCOPYABLE(ScopedWindowFocusAllowedIndicator); |
| 16 | 16 |
| 17 public: | 17 public: |
| 18 explicit ScopedWindowFocusAllowedIndicator( | 18 explicit ScopedWindowFocusAllowedIndicator( |
| 19 ExecutionContext* execution_context) | 19 ExecutionContext* execution_context) |
| 20 : execution_context_(execution_context) { | 20 : execution_context_(execution_context) { |
| 21 execution_context->AllowWindowInteraction(); | 21 execution_context->AllowWindowInteraction(); |
| 22 } | 22 } |
| 23 ~ScopedWindowFocusAllowedIndicator() { | 23 ~ScopedWindowFocusAllowedIndicator() { |
| 24 execution_context_->ConsumeWindowInteraction(); | 24 execution_context_->ConsumeWindowInteraction(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 private: | 27 private: |
| 28 // This doesn't create a cycle because ScopedWindowFocusAllowedIndicator | 28 // This doesn't create a cycle because ScopedWindowFocusAllowedIndicator |
| 29 // is used only on a machine stack. | 29 // is used only on a machine stack. |
| 30 Persistent<ExecutionContext> execution_context_; | 30 Persistent<ExecutionContext> execution_context_; |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 } // namespace blink | 33 } // namespace blink |
| 34 | 34 |
| 35 #endif // ScopedWindowFocusAllowedIndicator_h | 35 #endif // ScopedWindowFocusAllowedIndicator_h |
| OLD | NEW |