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.
6 #include "core/dom/ScriptForbiddenScope.h"
8 #include "wtf/Assertions.h"
9 #include "wtf/MainThread.h"
15 static unsigned s_scriptForbiddenCount = 0;
17 ScriptForbiddenScope::ScriptForbiddenScope()
19 ASSERT(isMainThread());
20 ++s_scriptForbiddenCount;
23 ScriptForbiddenScope::~ScriptForbiddenScope()
25 ASSERT(isMainThread());
26 --s_scriptForbiddenCount;
29 bool ScriptForbiddenScope::isScriptForbidden()
31 return isMainThread() && s_scriptForbiddenCount;
34 ScriptForbiddenScope::AllowUserAgentScript::AllowUserAgentScript()
35 : m_change(s_scriptForbiddenCount, 0)
39 ScriptForbiddenScope::AllowUserAgentScript::~AllowUserAgentScript()
41 ASSERT(!s_scriptForbiddenCount);
46 } // namespace WebCore